/**
 * Video Gallery Block Styles
 * Modern responsive video gallery layout similar to dangcongsan.vn
 */

/* CSS Custom Properties for Consistent Theming */
:root {
    /* Primary Colors */
    --vg-primary-color: #d32f2f;
    --vg-primary-dark: #b71c1c;
    --vg-primary-light: #ff5722;
    --vg-secondary-color: #333;
    --vg-text-muted: #666;
    
    /* Background Colors */
    --vg-bg-primary: #fff;
    --vg-bg-secondary: #f8f9fa;
    --vg-bg-tertiary: #e9ecef;
    --vg-bg-hover-primary: #e3f2fd;
    --vg-bg-hover-secondary: #e8f5e8;
    --vg-bg-active: #d4edda;
    
    /* Spacing */
    --vg-spacing-xs: 6px;
    --vg-spacing-sm: 8px;
    --vg-spacing-md: 12px;
    --vg-spacing-lg: 15px;
    --vg-spacing-xl: 20px;
    --vg-spacing-xxl: 25px;
    --vg-spacing-xxxl: 30px;
    
    /* Typography */
    --vg-font-size-xs: 0.75rem;
    --vg-font-size-sm: 0.8rem;
    --vg-font-size-base: 0.9rem;
    --vg-font-size-md: 1rem;
    --vg-font-size-lg: 1.1rem;
    --vg-font-size-xl: 1.2rem;
    --vg-font-size-xxl: 1.3rem;
    --vg-font-size-xxxl: 1.5rem;
    --vg-font-weight-normal: 500;
    --vg-font-weight-semibold: 600;
    --vg-font-weight-bold: 700;
    --vg-line-height-tight: 1.3;
    --vg-line-height-normal: 1.4;
    
    /* Borders & Radius */
    --vg-border-radius-sm: 4px;
    --vg-border-radius-md: 6px;
    --vg-border-radius-lg: 8px;
    --vg-border-radius-circle: 50%;
    --vg-border-width: 2px;
    --vg-border-width-thick: 3px;
    --vg-border-width-active: 4px;
    
    /* Shadows */
    --vg-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.1);
    --vg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --vg-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --vg-shadow-primary: 0 4px 12px rgba(211, 47, 47, 0.3);
    --vg-shadow-primary-sm: 0 2px 6px rgba(211, 47, 47, 0.3);
    
    /* Transitions */
    --vg-transition-fast: 0.2s ease;
    --vg-transition-normal: 0.3s ease;
    --vg-transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --vg-transition-bounce: 0.6s ease-out;
    
    /* Layout */
    --vg-container-max-height: 500px;
    --vg-container-max-height-md: 400px;
    --vg-container-max-height-sm: 300px;
    --vg-thumbnail-size-lg: 80px;
    --vg-thumbnail-size-md: 70px;
    --vg-thumbnail-size-sm: 60px;
    --vg-thumbnail-height-lg: 60px;
    --vg-thumbnail-height-md: 50px;
    --vg-thumbnail-height-sm: 40px;
    --vg-control-size: 40px;
    --vg-play-icon-size: 24px;
    --vg-play-icon-size-sm: 20px;
    --vg-play-icon-size-xs: 16px;
    
    /* Z-Index */
    --vg-z-index-base: 1;
    --vg-z-index-overlay: 2;
    --vg-z-index-controls: 3;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --vg-bg-primary: #1a1a1a;
        --vg-bg-secondary: #2d2d2d;
        --vg-bg-tertiary: #404040;
        --vg-secondary-color: #e0e0e0;
        --vg-text-muted: #b0b0b0;
        --vg-bg-hover-primary: #333;
        --vg-bg-hover-secondary: #404040;
        --vg-bg-active: #4a4a4a;
        --vg-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
        --vg-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
        --vg-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}

.video-gallery-zone {
    background: #fff;
    padding: var(--vg-spacing-xl);
    margin-bottom: var(--vg-spacing-xxxl);
    border-radius: var(--vg-border-radius-lg);
    box-shadow: var(--vg-shadow-sm);
}

/* Header Section */
.video-gallery-header {
    margin-bottom: var(--vg-spacing-xxl);
    padding-bottom: var(--vg-spacing-lg);
    border-bottom: var(--vg-border-width-thick) solid var(--vg-primary-color);
    position: relative;
}

.video-gallery-title {
    margin: 0;
    font-size: var(--vg-font-size-xxxl);
    font-weight: var(--vg-font-weight-bold);
    /* color: var(--vg-secondary-color); */
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.title-text {
    position: relative;
    z-index: var(--vg-z-index-base);
}

.title-accent {
    position: absolute;
    bottom: -15px;
    left: 0;
    width: 60px;
    height: var(--vg-border-width-thick);
    background: linear-gradient(90deg, var(--vg-primary-color) 0%, var(--vg-primary-light) 100%);
    border-radius: 2px;
}

/* Main Content Layout */
.video-gallery-content {
    display: flex;
    gap: var(--vg-spacing-xl);
    align-items: flex-start;
}

/* Main Video Player (Left Column - 65-70%) */
.video-main-player {
    flex: 0 0 68%;
    max-width: 68%;
}

.video-featured {
    width: 100%;
}

.video-thumbnail-wrapper {
    position: relative;
    width: 100%;
    border-radius: var(--vg-border-radius-lg);
    overflow: hidden;
    box-shadow: var(--vg-shadow-md);
    transition: transform var(--vg-transition-normal), box-shadow var(--vg-transition-normal);
}

.video-thumbnail-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: var(--vg-shadow-lg);
}

.video-thumbnail-link {
    display: block;
    position: relative;
}

.video-thumbnail {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity var(--vg-transition-normal);
    z-index: var(--vg-z-index-overlay);
}

.video-thumbnail-wrapper:hover .video-play-overlay {
    opacity: 1;
}

.play-button {
    transform: scale(1);
    transition: transform var(--vg-transition-normal);
}

.video-thumbnail-wrapper:hover .play-button {
    transform: scale(1.1);
}

.video-featured-info {
    padding: var(--vg-spacing-xl) 0;
}

.video-featured-title {
    margin: 0 0 10px 0;
    font-size: var(--vg-font-size-xl);
    font-weight: var(--vg-font-weight-bold);
    line-height: var(--vg-line-height-normal);
}

.video-featured-title a {
    /* color: var(--vg-secondary-color); */
    text-decoration: none;
    transition: color var(--vg-transition-normal);
}

.video-featured-title a:hover {
    color: var(--vg-primary-color);
}

.video-featured-meta {
    color: var(--vg-text-muted);
    font-size: var(--vg-font-size-base);
}

.video-date {
    font-weight: var(--vg-font-weight-normal);
}

/* Progressive Image Enhancement */
.video-thumbnail-picture,
.playlist-thumbnail-picture {
    display: block;
    width: 100%;
    height: 100%;
}

.video-thumbnail,
.playlist-thumbnail-img {
    transition: opacity var(--vg-transition-normal), filter var(--vg-transition-normal);
    will-change: opacity, filter;
}

/* Blur-up effect for progressive loading */
.video-thumbnail.loading,
.playlist-thumbnail-img.loading {
    filter: blur(5px);
    opacity: 0.8;
}

.video-thumbnail.loaded,
.playlist-thumbnail-img.loaded {
    filter: blur(0);
    opacity: 1;
}

/* Low-quality placeholder styles */
.video-thumbnail[data-low-src],
.playlist-thumbnail-img[data-low-src] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--vg-bg-tertiary);
}

/* WebP fallback indicator */
.no-webp .video-thumbnail-picture source[type="image/webp"],
.no-webp .playlist-thumbnail-picture source[type="image/webp"] {
    display: none;
}

/* Image loading skeleton animation */
@keyframes imageLoading {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.video-thumbnail.loading,
.playlist-thumbnail-img.loading {
    animation: imageLoading 1.5s ease-in-out infinite;
}

/* Image error fallback */
.video-thumbnail.error,
.playlist-thumbnail-img.error {
    background: linear-gradient(135deg, var(--vg-bg-tertiary) 0%, var(--vg-bg-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--vg-text-muted);
    font-size: var(--vg-font-size-sm);
}

.video-thumbnail.error::before,
.playlist-thumbnail-img.error::before {
    content: "📷";
    font-size: var(--vg-font-size-xl);
    opacity: 0.5;
}

/* Video Playlist (Right Column - 30-35%) */
.video-playlist {
    flex: 0 0 32%;
    max-width: 32%;
}

.playlist-container {
    /* background: var(--vg-bg-secondary); */
    border-radius: var(--vg-border-radius-lg);
    padding: var(--vg-spacing-lg);
    max-height: var(--vg-container-max-height);
    overflow: hidden;
    position: relative;
}

.playlist-slider {
    display: flex;
    flex-direction: column;
    gap: var(--vg-spacing-sm);
    transition: transform var(--vg-transition-slow);
    will-change: transform;
}

/* Custom scrollbar */
.playlist-container::-webkit-scrollbar {
    width: var(--vg-spacing-xs);
}

.playlist-container::-webkit-scrollbar-track {
    background: var(--vg-bg-tertiary);
    border-radius: var(--vg-border-radius-sm);
}

.playlist-container::-webkit-scrollbar-thumb {
    background: var(--vg-primary-color);
    border-radius: var(--vg-border-radius-sm);
}

.playlist-container::-webkit-scrollbar-thumb:hover {
    background: var(--vg-primary-dark);
}

.playlist-item {
    display: flex;
    align-items: flex-start;
    gap: var(--vg-spacing-md);
    padding: var(--vg-spacing-md);
    border-radius: var(--vg-border-radius-md);
    cursor: pointer;
    transition: background-color var(--vg-transition-normal), transform var(--vg-transition-fast);
    margin-bottom: var(--vg-spacing-sm);
}

.playlist-item:last-child {
    margin-bottom: 0;
}

.playlist-item:hover {
    background-color: var(--vg-bg-hover-primary);
    transform: translateX(3px);
}

.playlist-item.active {
    /* background-color: var(--vg-bg-hover-secondary); */
    border-left: var(--vg-border-width-active) solid var(--vg-primary-color);
    padding-left: var(--vg-spacing-sm);
}

.playlist-item.active:hover {
    background-color: var(--vg-bg-active);
}

.playlist-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: var(--vg-thumbnail-size-lg);
    height: var(--vg-thumbnail-height-lg);
    border-radius: var(--vg-border-radius-sm);
    overflow: hidden;
    box-shadow: var(--vg-shadow-sm);
}

.playlist-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.playlist-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--vg-border-radius-circle);
    width: var(--vg-play-icon-size);
    height: var(--vg-play-icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity var(--vg-transition-normal);
}

.playlist-item:hover .playlist-play-icon {
    opacity: 1;
}

.playlist-content {
    flex: 1;
    min-width: 0;
}

.playlist-title {
    margin: 0 0 var(--vg-spacing-xs) 0;
    font-size: var(--vg-font-size-base);
    font-weight: var(--vg-font-weight-semibold);
    line-height: var(--vg-line-height-tight);
    color: var(--vg-secondary-color);
}

.playlist-title a {
    /* color: inherit; */
    text-decoration: none;
    transition: color var(--vg-transition-normal);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.playlist-item:hover .playlist-title a {
    color: var(--vg-primary-color);
}

.playlist-date {
    font-size: var(--vg-font-size-sm);
    color: var(--vg-text-muted);
    font-weight: var(--vg-font-weight-normal);
}

/* Playlist Navigation Controls */
.playlist-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: var(--vg-spacing-lg);
    padding: 0 var(--vg-spacing-lg);
    z-index: var(--vg-z-index-controls);
}

.playlist-controls button {
    /* background: var(--vg-bg-primary); */
    border: var(--vg-border-width) solid var(--vg-primary-color);
    border-radius: var(--vg-border-radius-circle);
    width: var(--vg-control-size);
    height: var(--vg-control-size);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--vg-transition-normal);
    color: var(--vg-primary-color);
}

.playlist-controls button:hover {
    background: var(--vg-primary-color);
    color: var(--vg-bg-primary);
    transform: translateY(-2px);
    box-shadow: var(--vg-shadow-primary);
}

.playlist-controls button:active {
    transform: translateY(0);
    box-shadow: var(--vg-shadow-primary-sm);
}

/* Infinite sliding - buttons are always active */
.playlist-controls button:disabled {
    opacity: 1;
    cursor: pointer;
}

.playlist-controls button:disabled:hover {
    background: var(--vg-primary-color);
    color: var(--vg-bg-primary);
    transform: translateY(-2px);
    box-shadow: var(--vg-shadow-primary);
}

.playlist-controls svg {
    transition: transform var(--vg-transition-normal);
}

.playlist-controls button:hover svg {
    transform: scale(1.1);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .video-gallery-content {
        gap: var(--vg-spacing-lg);
    }
    
    .video-main-player {
        flex: 0 0 65%;
        max-width: 65%;
    }
    
    .video-playlist {
        flex: 0 0 35%;
        max-width: 35%;
    }
    
    .playlist-container {
        max-height: var(--vg-container-max-height-md);
    }
}

@media (max-width: 768px) {
    .video-gallery-zone {
        padding: var(--vg-spacing-lg);
    }
    
    .video-gallery-content {
        flex-direction: column;
        gap: var(--vg-spacing-xl);
    }
    
    .video-main-player,
    .video-playlist {
        flex: none;
        max-width: 100%;
    }
    
    .video-featured-title {
        font-size: var(--vg-font-size-lg);
    }
    
    .playlist-container {
        max-height: var(--vg-container-max-height-sm);
        padding: var(--vg-spacing-md);
    }
    
    .playlist-item {
        gap: 10px;
        padding: 10px;
    }
    
    .playlist-thumbnail {
        width: var(--vg-thumbnail-size-md);
        height: var(--vg-thumbnail-height-md);
    }
    
    .playlist-title {
        font-size: 0.85rem;
    }
    
    .playlist-date {
        font-size: var(--vg-font-size-xs);
    }
}

@media (max-width: 480px) {
    .video-gallery-zone {
        padding: 10px;
        margin-bottom: var(--vg-spacing-xl);
    }
    
    .video-gallery-title {
        font-size: var(--vg-font-size-xxl);
    }
    
    .video-featured-info {
        padding: var(--vg-spacing-lg) 0;
    }
    
    .video-featured-title {
        font-size: var(--vg-font-size-md);
    }
    
    .playlist-item {
        padding: var(--vg-spacing-sm);
        gap: var(--vg-spacing-sm);
    }
    
    .playlist-thumbnail {
        width: var(--vg-thumbnail-size-sm);
        height: var(--vg-thumbnail-height-sm);
    }
    
    .playlist-play-icon {
        width: var(--vg-play-icon-size-sm);
        height: var(--vg-play-icon-size-sm);
    }
    
    .playlist-play-icon svg {
        width: var(--vg-play-icon-size-xs);
        height: var(--vg-play-icon-size-xs);
    }
}

/* Animation for smooth transitions */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-gallery-zone {
    animation: fadeInUp 0.6s ease-out;
}

/* Focus states for accessibility */
.video-thumbnail-link:focus,
.playlist-item:focus {
    outline: 2px solid #d32f2f;
    outline-offset: 2px;
}

.playlist-title a:focus {
    outline: 1px solid #d32f2f;
    outline-offset: 1px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .video-gallery-zone {
        border: 2px solid #000;
    }
    
    .playlist-item.active {
        border-left-color: #000;
        background-color: #f0f0f0;
    }
    
    .title-accent {
        background: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .video-thumbnail-wrapper,
    .play-button,
    .playlist-item,
    .video-gallery-zone {
        transition: none;
        animation: none;
    }
}
