/**
 * Tadoch Lightbox Gallery - Video Styles
 * Styles for video wrappers, overlays, and players
 * 
 * @package Tadoch_Lightbox_Gallery
 * @since 1.2.0
 * @file assets/css/video.css
 */

/* ==========================================================================
   VIDEO WRAPPER AND OVERLAY STYLES
   ========================================================================== */

.tadoch-video-wrapper {
    position: relative; /* FIXED: Added position relative for overlay positioning */
    display: inline-block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
}

.tadoch-video-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: all 0.3s ease;
}

.tadoch-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    border-radius: 8px;
}

.tadoch-video-wrapper:hover .tadoch-video-overlay {
    opacity: 1;
}

.tadoch-video-play-icon {
    width: 15% !important;
    height: auto !important;
    max-width: 80px;
    min-width: 40px;
    object-fit: contain !important;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: all 0.3s ease;
}

.tadoch-video-wrapper:hover .tadoch-video-play-icon {
    transform: scale(1.1);
}

/* ==========================================================================
   SPECIFIC VIDEO TYPE STYLES
   ========================================================================== */

/* YouTube Video Styling */
.video-type-video-youtube .tadoch-video-overlay {
    background: rgba(196, 48, 43, 0.2); /* YouTube red tint */
}

.video-type-video-youtube:hover .tadoch-video-overlay {
    background: rgba(196, 48, 43, 0.4);
}

.video-type-video-youtube .tadoch-video-play-icon {
    filter: drop-shadow(0 4px 8px rgba(196, 48, 43, 0.5));
}

/* Generic Video Styling */
.video-type-video-generic .tadoch-video-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.video-type-video-generic:hover .tadoch-video-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.video-type-video-generic .tadoch-video-play-icon {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

/* ==========================================================================
   LIGHTBOX VIDEO PLAYERS
   ========================================================================== */

.lightbox-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 90vw;
    max-height: 90vh;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    /* FIXED: Ensure container behaves like lightbox-image for responsive behavior */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FIXED: Target lightbox containers with YouTube videos specifically */
.lightbox-container:has(.tadoch-youtube-player) {
    width: 90vw !important;
    min-width: 800px !important;
    max-width: 1200px !important;
    height: auto !important;
    min-height: 450px !important;
    max-height: 675px !important; /* 16:9 ratio of min-width */
}

/* Ensure the video container within takes full space */
.lightbox-container:has(.tadoch-youtube-player) .lightbox-video-container {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
}

.lightbox-video-thumbnail {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    /* FIXED: Make thumbnail responsive like regular images */
    max-width: 100%;
    max-height: 100%;
}

.lightbox-video-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    /* FIXED: Ensure thumbnail scales properly on resize */
    display: block;
}

.lightbox-video-thumbnail .tadoch-video-overlay {
    opacity: 1;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
}

.lightbox-video-thumbnail:hover .tadoch-video-overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* FIXED: Much larger play icon in lightbox */
.lightbox-video-thumbnail .tadoch-video-overlay .tadoch-video-play-icon {
    width: 120px !important;
    height: auto !important;
    max-width: 120px !important;
    min-width: 80px !important;
}

/* YouTube Player in Lightbox - FIXED: Proper sizing */
.tadoch-youtube-player {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    /* FIXED: Set aspect ratio and proper sizing */
    aspect-ratio: 16/9;
    min-width: 100%;
    min-height: 100%;
}

.tadoch-youtube-player iframe {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: none;
    outline: none;
}

/* Generic Video Player in Lightbox - FIXED: Proper sizing (keep flexible for now) */
.tadoch-video-player {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Keep generic videos flexible for now - we'll fix later */
    max-width: 90vw;
    max-height: 90vh;
}

.tadoch-video-player video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    outline: none;
}

.tadoch-video-player video:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* ==========================================================================
   LAYOUT-SPECIFIC VIDEO ADJUSTMENTS
   ========================================================================== */

/* Masonry Layout */
.layout-masonry .tadoch-video-wrapper {
    border-radius: 12px;
}

.layout-masonry .tadoch-video-overlay {
    border-radius: 12px;
}

/* Carousel Layout */
.layout-carousel .tadoch-video-wrapper {
    height: 250px;
    border-radius: 8px;
}

/* Polaroid Layout */
.layout-polaroid .tadoch-video-wrapper {
    border-radius: 4px;
}

/* Circle Layout */
.layout-circle .tadoch-video-wrapper {
    border-radius: 50%;
    overflow: hidden;
}

.layout-circle .tadoch-video-overlay {
    border-radius: 50%;
}

/* Film Strip Layout */
.layout-film-strip .tadoch-video-wrapper {
    border-radius: 0;
}

.layout-film-strip .tadoch-video-overlay {
    border-radius: 0;
}

/* Magazine Layout */
.layout-magazine .tadoch-video-wrapper {
    border-radius: 8px;
}

/* ==========================================================================
   RESPONSIVE VIDEO STYLES - ENHANCED
   ========================================================================== */

@media (max-width: 1200px) {
    .lightbox-container:has(.tadoch-youtube-player) {
        width: 95vw !important;
        min-width: 700px !important;
        max-width: 1000px !important;
        min-height: 394px !important; /* 16:9 ratio of min-width */
        max-height: 563px !important;
    }
    
    .lightbox-video-container {
        max-width: 95vw;
        max-height: 80vh;
    }
}

@media (max-width: 768px) {
    .tadoch-video-play-icon {
        width: 20% !important;
        max-width: 60px;
        min-width: 30px;
    }
    
    .lightbox-video-thumbnail .tadoch-video-play-icon {
        width: 100px !important;
        max-width: 100px !important;
        min-width: 60px !important;
    }
    
    .lightbox-container:has(.tadoch-youtube-player) {
        width: 95vw !important;
        min-width: 500px !important;
        max-width: 95vw !important;
        min-height: 281px !important; /* 16:9 ratio of min-width */
        max-height: 70vh !important;
    }
    
    .lightbox-video-container {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .tadoch-video-player {
        max-width: 95vw;
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .tadoch-video-play-icon {
        width: 25% !important;
        max-width: 50px;
        min-width: 25px;
    }
    
    .lightbox-video-thumbnail .tadoch-video-play-icon {
        width: 80px !important;
        max-width: 80px !important;
        min-width: 40px !important;
    }
    
    .lightbox-container:has(.tadoch-youtube-player) {
        width: 98vw !important;
        min-width: 320px !important;
        max-width: 98vw !important;
        min-height: 180px !important; /* 16:9 ratio of min-width */
        max-height: 50vh !important;
    }
    
    .tadoch-video-player {
        max-width: 98vw;
        max-height: 50vh;
    }
}

/* ==========================================================================
   VIDEO LOADING AND ERROR STATES
   ========================================================================== */

.tadoch-video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    z-index: 10;
}

.tadoch-video-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    border-radius: 4px;
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

.tadoch-video-wrapper:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

.lightbox-video-thumbnail:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* ==========================================================================
   ENSURE VIDEO CONTAINERS BEHAVE LIKE IMAGES IN LAYOUTS
   ========================================================================== */

/* Make video containers behave exactly like images in all layouts */
.tadoch-gallery-item .tadoch-video-wrapper {
    width: 100%;
    height: 100%;
    display: block;
}

/* Ensure video wrappers inherit the same styling as images */
.tadoch-custom-gallery .tadoch-video-wrapper {
    transition: all 0.3s ease;
}

/* Apply hover effects to video wrappers too */
.tadoch-custom-gallery.hover-zoom .tadoch-video-wrapper:hover {
    transform: scale(1.05);
}

.tadoch-custom-gallery.hover-fade .tadoch-video-wrapper:hover {
    opacity: 0.8;
}

.tadoch-custom-gallery.hover-lift .tadoch-video-wrapper:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.tadoch-custom-gallery.hover-glow .tadoch-video-wrapper:hover {
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.6);
    transform: scale(1.02);
}

.tadoch-custom-gallery.hover-border .tadoch-video-wrapper {
    border: 3px solid transparent;
}

.tadoch-custom-gallery.hover-border .tadoch-video-wrapper:hover {
    border-color: #3498db;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .tadoch-video-wrapper img,
    .tadoch-video-overlay,
    .tadoch-video-play-icon,
    .tadoch-video-wrapper {
        transition: none;
    }
}

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (prefers-contrast: high) {
    .tadoch-video-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .video-type-video-youtube .tadoch-video-overlay {
        background: rgba(196, 48, 43, 0.8);
    }
    
    .tadoch-video-play-icon {
        filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.8));
    }
}
    border-radius: 0;
}

.layout-film-strip .tadoch-video-overlay {
    border-radius: 0;
}

/* Magazine Layout */
.layout-magazine .tadoch-video-wrapper {
    border-radius: 8px;
}

/* ==========================================================================
   RESPONSIVE VIDEO STYLES
   ========================================================================== */

@media (max-width: 768px) {
    .tadoch-video-play-icon {
        width: 20% !important;
        max-width: 60px;
        min-width: 30px;
    }
    
    .lightbox-video-thumbnail .tadoch-video-play-icon {
        width: 25% !important;
        max-width: 80px;
        min-width: 40px;
    }
    
    .lightbox-video-container {
        max-width: 95vw;
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    .tadoch-video-play-icon {
        width: 25% !important;
        max-width: 50px;
        min-width: 25px;
    }
    
    .lightbox-video-thumbnail .tadoch-video-play-icon {
        width: 30% !important;
        max-width: 60px;
        min-width: 30px;
    }
}

/* ==========================================================================
   VIDEO LOADING AND ERROR STATES
   ========================================================================== */

.tadoch-video-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    z-index: 10;
}

.tadoch-video-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff6b6b;
    font-size: 14px;
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 15px;
    border-radius: 4px;
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

.tadoch-video-wrapper:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

.lightbox-video-thumbnail:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .tadoch-video-wrapper img,
    .tadoch-video-overlay,
    .tadoch-video-play-icon {
        transition: none;
    }
}

/* ==========================================================================
   HIGH CONTRAST MODE SUPPORT
   ========================================================================== */

@media (prefers-contrast: high) {
    .tadoch-video-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .video-type-video-youtube .tadoch-video-overlay {
        background: rgba(196, 48, 43, 0.8);
    }
    
    .tadoch-video-play-icon {
        filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.8));
    }
}