/* Latest Posts Section Styles */

.latest-posts-section {
    padding: 2rem 0;
    margin-top: 80px; /* Account for fixed header */
}

.latest-posts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.latest-posts-title {
    font-size: 2rem;
    font-weight: 600;
    color: #1e3a8a;
    margin: 0;
}

.toolbar-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar-controls .form-select {
    min-width: 150px;
}

/* Post Grid */
.post-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .post-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .post-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Post Card */
.post-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Post Thumbnail */
.post-thumb {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
}

.thumb-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-card:hover .thumb-image {
    transform: scale(1.05);
}

.thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.8);
    font-size: 3rem;
}

.video-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Post Content */
.post-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.post-title {
    margin: 0 0 0.75rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.post-title a {
    color: #1e3a8a;
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-title a:hover {
    color: #4A90E2;
}

/* Post Meta */
.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.post-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.post-meta i {
    font-size: 0.75rem;
    width: 12px;
}

/* Post Excerpt */
.post-excerpt {
    color: #4b5563;
    line-height: 1.5;
    margin: 0;
    flex-grow: 1;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #d1d5db;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #374151;
}

/* Load More Button */
.load-more-container {
    text-align: center;
    margin-top: 2rem;
}

.load-more-btn {
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
    border: none;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
    color: white;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Skeleton Loader */
.skeleton-loader {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .skeleton-loader {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .skeleton-loader {
        grid-template-columns: repeat(3, 1fr);
    }
}

.skeleton-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.skeleton-thumb {
    aspect-ratio: 16/9;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.skeleton-title {
    height: 1.5rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-meta {
    height: 1rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    width: 60%;
}

.skeleton-excerpt {
    height: 1rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    flex-grow: 1;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Category Page Styles */
.category-header {
    padding: 2rem 0 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.category-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e3a8a;
    margin: 0 0 0.5rem 0;
}

.category-description {
    font-size: 1.1rem;
    color: #64748b;
    margin: 0;
}

.category-posts {
    padding: 2rem 0;
}

/* 4-Column Grid Layout */
.posts-grid-4 {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    align-items: start;
}

/* Ensure grid items take full width */
.posts-grid-4 > .post-card-grid {
    width: 100% !important;
    max-width: 100% !important;
}

/* Override any conflicting styles */
.category-posts .posts-grid-4 {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 1.5rem !important;
    margin-bottom: 2rem !important;
    width: 100% !important;
    align-items: start !important;
}

@media (max-width: 1200px) {
    .category-posts .posts-grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 992px) {
    .category-posts .posts-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 576px) {
    .category-posts .posts-grid-4 {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 1200px) {
    .posts-grid-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 992px) {
    .posts-grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 576px) {
    .posts-grid-4 {
        grid-template-columns: 1fr !important;
    }
}

/* Post Card Grid (for general use - Post.cshtml, etc.) */
.post-card-grid {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 200px;
}

.post-card-grid:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.post-card-grid-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.post-card-grid-image-container {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
}

.post-card-grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-card-grid-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 2rem;
}

.post-card-grid:hover .post-card-grid-image {
    transform: scale(1.05);
}

.post-card-grid-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    min-height: 60px;
    position: relative;
    z-index: 2;
    background: #fff;
}

.post-card-grid-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 0.5rem 0;
    color: #1e3a8a !important;
    display: block !important;
    visibility: visible !important;
}

.post-card-grid-meta {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280 !important;
    margin-top: auto;
    visibility: visible !important;
}

.post-card-grid-meta small {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Pagination for Category Page */
.pagination-nav {
    padding: 2rem 0;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-btn {
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
    color: white;
    text-decoration: none;
}

.pagination-info {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

/* ===========================================
   CATEGORY PAGE SPECIFIC STYLES
   ===========================================
   These styles are specifically for the category page listing
   and are isolated to prevent affecting other pages.
   =========================================== */

/* Category Posts Grid Layout */
.category-posts-grid {
    margin-bottom: 2rem;
}

/* Category Post Card - Enhanced styling based on _CategorySection.cshtml */
.category-post-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid #e2e8f0;
}

.category-post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #4A90E2;
}

/* Category Post Link */
.category-post-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* Category Post Image Container */
.category-post-image-container {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
}

.category-post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.category-post-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #4A90E2 0%, #1E3A8A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 2rem;
}

.category-post-card:hover .category-post-image {
    transform: scale(1.05);
}

/* Category Post Content */
.category-post-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: #fff;
}

/* Category Post Title */
.category-post-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 0.75rem 0;
    color: #1e3a8a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6rem; /* Ensure consistent height for 2 lines */
}

.category-post-link:hover .category-post-title {
    color: #4A90E2;
}

/* Category Post Meta */
.category-post-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: auto;
}

.category-post-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.category-post-meta i {
    font-size: 0.7rem;
    width: 12px;
    color: #9ca3af;
}

/* Specific meta styling */
.category-post-author {
    color: #4b5563;
}

.category-post-date {
    color: #6b7280;
}

.category-post-views {
    color: #9ca3af;
    font-weight: 500;
}

/* Responsive adjustments for category page */
@media (max-width: 1200px) {
    .category-posts-grid .col-lg-3 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }
}

@media (max-width: 992px) {
    .category-posts-grid .col-lg-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

@media (max-width: 576px) {
    .category-posts-grid .col-lg-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .category-post-content {
        padding: 0.75rem;
    }
    
    .category-post-title {
        font-size: 0.9rem;
        min-height: 2.4rem;
    }
    
    .category-post-meta {
        font-size: 0.75rem;
    }
}

/* Empty State for Category */
.empty-category {
    padding: 4rem 0;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: #d1d5db;
}

.empty-state h3 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: #374151;
    font-weight: 600;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: #64748b;
}

.empty-state .btn {
    padding: 0.75rem 2rem;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .latest-posts-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-controls {
        justify-content: center;
    }
    
    .latest-posts-title {
        text-align: center;
        font-size: 1.75rem;
    }
    
    .category-title {
        font-size: 2rem;
        text-align: center;
    }
    
    .pagination-wrapper {
        flex-direction: column;
        text-align: center;
    }
    
    .pagination-btn {
        width: 100%;
        justify-content: center;
    }
}
