/* Articles List View Styles */

/* Fix black background for articles page only - Maximum specificity */
html body.page-articles,
body.page-articles {
    background-color: var(--background-light, #f6f6f6) !important;
    background: var(--background-light, #f6f6f6) !important;
}

/* Ensure main content has proper background */
html body.page-articles main#main-content,
body.page-articles main#main-content {
    background-color: var(--background-light, #f6f6f6) !important;
    background: var(--background-light, #f6f6f6) !important;
    min-height: 100vh;
}

/* Articles content section background */
html body.page-articles .articles-content-section,
body.page-articles .articles-content-section {
    background-color: var(--background-light, #f6f6f6) !important;
    background: var(--background-light, #f6f6f6) !important;
    min-height: 100vh;
    padding-top: 20px;
}

/* Container background */
html body.page-articles .articles-content-section .container,
body.page-articles .articles-content-section .container {
    background-color: transparent !important;
    background: transparent !important;
}

/* Filters container layout */
.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    margin-bottom: 24px;
}

/* View Toggle Controls - Inside filters */
.view-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto; /* Push to right on desktop */
}

.view-toggle-label {
    font-size: 14px;
    color: var(--text-secondary, #666);
    font-weight: 500;
    display: none; /* Hide label by default */
}

.view-toggle {
    display: flex;
    background: var(--background-light, #f8fafc);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--border-color, #e2e8f0);
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    color: var(--text-secondary, #666);
}

.view-toggle-btn.active {
    background: var(--primary-color, #0066cc);
    color: var(--text-white);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.2);
}

.view-toggle-btn:hover:not(.active) {
    background: transparent !important;
    color: var(--text-primary, #333) !important;
}

/* Ensure no background on hover */
.view-toggle-btn:hover {
    background-color: transparent !important;
}

.view-toggle-btn.active:hover {
    background: var(--primary-color, #0066cc) !important;
    color: var(--text-white) !important;
}

/* List View Styles */
.articles-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Desktop List View Styles */
.articles-grid.list-view .article-thumbnail {
    width: 100%;
    height: auto;
    display: flex;
    background: var(--background-light, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid var(--border-color, #e2e8f0);
    transition: border-color 0.2s ease;
}

.articles-grid.list-view .article-thumbnail:hover {
    border-color: var(--primary-color, #0066cc) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    transform: none !important;
}

.articles-grid.list-view .article-thumbnail img {
    width: 200px;
    height: 140px;
    object-fit: cover;
    flex-shrink: 0;
}

.articles-grid.list-view .article-overlay {
    position: static;
    background: transparent;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 1;
    transform: none;
    text-align: left;
}

.articles-grid.list-view .article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary, #666);
}

.articles-grid.list-view .article-date,
.articles-grid.list-view .article-reading-time {
    font-weight: 500;
}

.articles-grid.list-view .article-separator {
    display: none;
}

/* Hide separator in card view as well */
.articles-grid:not(.list-view) .article-separator {
    display: none;
}

.articles-grid.list-view .article-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #1a202c);
    line-height: 1.4;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.articles-grid.list-view .article-excerpt {
    display: none !important;
}

.articles-grid.list-view .article-read-btn {
    align-self: flex-start;
    background: var(--primary-color, #0066cc);
    color: var(--text-white);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    opacity: 1 !important;
    visibility: visible !important;
}

.articles-grid.list-view .article-read-btn:hover {
    background: var(--primary-color-dark, #0052a3);
}

/* Category Badge for List View */
.articles-grid.list-view .article-category {
    display: inline-block;
    background: var(--primary-color-light, #e6f3ff);
    color: var(--primary-color, #0066cc);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
    margin-bottom: 8px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Hide view toggle completely on mobile */
    .view-toggle-container {
        display: none !important;
    }
    
    /* On mobile, filters take full width */
    .filters-container {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Force list view on mobile - always apply list view styles */
    .articles-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    /* Mobile - force list view layout for all articles */
    .articles-grid .article-thumbnail {
        flex-direction: column !important;
        width: 100% !important;
        height: auto !important;
        display: flex !important;
        background: var(--background-light, #ffffff) !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid var(--border-color, #e2e8f0) !important;
        margin-bottom: 16px !important;
    }
    
    /* Hide images when no featured image */
    .articles-grid .article-thumbnail img[src=""],
    .articles-grid .article-thumbnail img[src*="placeholder"],
    .articles-grid .article-thumbnail img[src*="default"] {
        display: none !important;
    }
    
    /* Show images only when they have valid src */
    .articles-grid .article-thumbnail img:not([src=""]):not([src*="placeholder"]):not([src*="default"]) {
        width: 100% !important;
        height: 200px !important;
        object-fit: cover !important;
        flex-shrink: 0 !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    /* Article content styling */
    .articles-grid .article-overlay {
        padding: 16px !important;
        position: static !important;
        background: transparent !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    .articles-grid .article-title {
        font-size: 16px !important;
        margin-bottom: 8px !important;
        line-height: 1.4 !important;
        font-weight: 600 !important;
        color: var(--text-primary, #1a202c) !important;
    }
    
    .articles-grid .article-excerpt {
        font-size: 14px !important;
        margin-bottom: 12px !important;
        line-height: 1.5 !important;
        color: var(--text-secondary, #666) !important;
    }
    
    .articles-grid .article-meta {
        font-size: 12px !important;
        margin-bottom: 10px !important;
        color: var(--text-secondary, #666) !important;
    }
    
    .articles-grid .article-read-btn {
        align-self: flex-start !important;
        margin-top: 8px !important;
        background: var(--primary-color, #0066cc) !important;
        color: var(--text-white) !important;
        border: none !important;
        padding: 8px 16px !important;
        border-radius: 6px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
    }
    
    /* Fix mobile hover text alignment */
    .articles-grid .article-thumbnail:hover .article-overlay {
        text-align: left !important;
        justify-content: flex-start !important;
    }
}

@media (max-width: 480px) {
    .articles-grid .article-thumbnail img:not([src=""]):not([src*="placeholder"]):not([src*="default"]) {
        height: 180px !important;
    }
    
    .articles-grid .article-overlay {
        padding: 14px !important;
    }
    
    .articles-grid .article-title {
        font-size: 15px !important;
    }
    
    .articles-grid .article-excerpt {
        font-size: 13px !important;
    }
}

/* Additional mobile fixes - handle articles without images */
@media (max-width: 768px) {
    /* Articles without images - full border radius */
    .articles-grid .article-thumbnail.no-image,
    .articles-grid .article-thumbnail:has(img[style*="display: none"]) {
        border-radius: 12px !important;
    }
    
    .articles-grid .article-thumbnail.no-image .article-overlay,
    .articles-grid .article-thumbnail:has(img[style*="display: none"]) .article-overlay {
        border-radius: 12px !important;
        padding: 16px !important;
    }
    
    /* Articles with visible images - split border radius */
    .articles-grid .article-thumbnail:has(img:not([style*="display: none"])) .article-overlay {
        border-radius: 0 0 12px 12px !important;
    }
    
    /* Hide empty or placeholder images */
    .articles-grid .article-thumbnail img[src=""],
    .articles-grid .article-thumbnail img[src*="placeholder"],
    .articles-grid .article-thumbnail img[src*="default"],
    .articles-grid .article-thumbnail img[src*="data:image/svg+xml"] {
        display: none !important;
    }
}

/* Smooth transitions for view switching */
.articles-grid {
    transition: all 0.3s ease;
}

.articles-grid .article-thumbnail {
    transition: all 0.3s ease;
}

/* Simplified hover effects for list view - only border highlight */
.articles-grid.list-view .article-thumbnail:hover .article-title {
    color: var(--primary-color, #0066cc);
}

/* Fix: Prevent title centering on hover in list view */
.articles-grid.list-view .article-thumbnail:hover .article-overlay {
    text-align: left !important;
    justify-content: flex-start !important;
    padding: 20px !important;
}

/* Focus states for accessibility */
.view-toggle-btn:focus {
    outline: 2px solid var(--primary-color, #0066cc);
    outline-offset: 2px;
}

.articles-grid.list-view .article-read-btn:focus {
    outline: 2px solid var(--primary-color, #0066cc);
    outline-offset: 2px;
}

/* Card view article titles - INCREASED font size */
.articles-grid:not(.list-view) .article-title {
    font-size: 18px !important;
    font-weight: 600;
    line-height: 1.4;
}

.articles-grid:not(.list-view) .article-thumbnail:hover .article-title {
    font-size: 20px !important;
}

/* Mobile card view title size */
@media (max-width: 768px) {
    .articles-grid:not(.list-view) .article-title {
        font-size: 16px !important;
    }
    
    .articles-grid:not(.list-view) .article-thumbnail:hover .article-title {
        font-size: 18px !important;
    }
}

/*
 Videos Grid List View */
.videos-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.videos-grid.list-view .video-thumbnail {
    width: 100%;
    height: auto;
    display: flex;
    background: var(--background-light, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid var(--border-color, #e2e8f0);
    transition: border-color 0.2s ease;
}

.videos-grid.list-view .video-thumbnail:hover {
    border-color: var(--primary-color, #0066cc) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    transform: none !important;
}

.videos-grid.list-view .video-thumbnail img {
    width: 200px;
    height: 140px;
    object-fit: cover;
    flex-shrink: 0;
}

.videos-grid.list-view .video-overlay {
    position: static;
    background: transparent;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 1;
    transform: none;
    text-align: left;
}

.videos-grid.list-view .video-title {
    color: var(--text-primary, #1a202c) !important;
    font-size: 14px !important;
    margin-bottom: 8px;
    font-weight: 600 !important;
}

.videos-grid.list-view .video-overlay * {
    color: var(--text-primary, #333) !important;
}

.videos-grid.list-view .video-overlay .video-title {
    color: var(--text-primary, #1a202c) !important;
    font-weight: 600;
}

.videos-grid.list-view .video-play-btn {
    align-self: flex-start;
    margin-top: 12px;
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    padding: 10px 20px;
    font-size: 15px;
}

/* Speaking/Events Grid List View */
.speaking-grid.list-view,
.events-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.speaking-grid.list-view .speaking-thumbnail,
.events-grid.list-view .event-thumbnail {
    width: 100%;
    height: auto;
    display: flex;
    background: var(--background-light, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 2px solid var(--border-color, #e2e8f0);
    transition: border-color 0.2s ease;
}

.speaking-grid.list-view .speaking-thumbnail:hover,
.events-grid.list-view .event-thumbnail:hover {
    border-color: var(--primary-color, #0066cc) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    transform: none !important;
}

.speaking-grid.list-view .speaking-thumbnail img,
.events-grid.list-view .event-thumbnail img {
    width: 200px;
    height: 140px;
    object-fit: cover;
    flex-shrink: 0;
}

.speaking-grid.list-view .speaking-overlay,
.events-grid.list-view .event-overlay {
    position: static;
    background: transparent;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 1;
    transform: none;
    text-align: left;
}

.speaking-grid.list-view .speaking-title,
.events-grid.list-view .event-title {
    color: var(--text-primary, #1a202c) !important;
    font-size: 14px !important;
    margin-bottom: 8px;
    font-weight: 600 !important;
}

.speaking-grid.list-view .speaking-overlay *,
.events-grid.list-view .event-overlay * {
    color: var(--text-primary, #333) !important;
}

.speaking-grid.list-view .speaking-overlay .speaking-title,
.events-grid.list-view .event-overlay .event-title {
    color: var(--text-primary, #1a202c) !important;
    font-weight: 600;
}

.speaking-grid.list-view .speaking-details-btn,
.events-grid.list-view .event-details-btn {
    align-self: flex-start;
    margin-top: 12px;
    display: inline-flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    padding: 10px 20px;
    font-size: 15px;
}

/* Excerpt styles for videos and speaking */
.video-excerpt,
.speaking-excerpt,
.event-excerpt {
    color: var(--text-secondary, #666) !important;
    font-size: 14px;
    line-height: 1.6;
    margin: 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* List view metadata and labels */
.videos-grid.list-view .video-date,
.events-grid.list-view .event-date,
.events-grid.list-view .event-location,
.events-grid.list-view .upcoming-label,
.events-grid.list-view .completed-label {
    color: var(--text-secondary, #666) !important;
    display: inline-block !important;
    opacity: 1 !important;
    visibility: visible !important;
    font-size: 14px !important;
    margin-bottom: 8px !important;
}

/* Hide video duration in list view */
.videos-grid.list-view .video-duration {
    display: none !important;
}

/* Ensure buttons remain visible */
.videos-grid.list-view .video-play-btn,
.events-grid.list-view .event-details-btn,
.speaking-grid.list-view .speaking-details-btn {
    color: var(--text-white) !important;
    background: var(--primary-color, #0066cc) !important;
}

/* Mobile: Force list view for videos and speaking too */
@media (max-width: 768px) {
    .videos-grid,
    .speaking-grid,
    .events-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 20px !important;
    }
    
    .videos-grid .video-thumbnail,
    .speaking-grid .speaking-thumbnail,
    .events-grid .event-thumbnail {
        width: 100% !important;
        height: auto !important;
        display: flex !important;
        flex-direction: row !important;
    }
    
    .videos-grid .video-thumbnail img,
    .speaking-grid .speaking-thumbnail img {
        width: 120px !important;
        height: 100px !important;
        object-fit: cover !important;
        flex-shrink: 0 !important;
    }
    
    .videos-grid .video-overlay,
    .speaking-grid .speaking-overlay,
    .events-grid .event-overlay {
        position: static !important;
        background: transparent !important;
        padding: 12px !important;
        flex: 1 !important;
        opacity: 1 !important;
        transform: none !important;
        text-align: left !important;
    }
}
