/**
 * ALD Video Player Enhanced Styles
 * Supports modal popup and fullscreen playback
 */

/* Video container wrapper */
.ald-video-wrapper {
    position: relative;
    display: block;
    width: 480px;
    max-width: 480px;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 16/9;
    background: #000;
    margin: 0;
}

/* Play button overlay for triggering modal/fullscreen */
.ald-video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    border-radius: 8px;
    box-sizing: border-box;
}

.ald-video-play-overlay:hover {
    background: rgba(0, 0, 0, 0.5);
}

.ald-video-play-overlay.hidden {
    display: none;
}

/* Large play button */
.ald-video-play-button {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
}

.ald-video-play-button:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.ald-video-play-button::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 25px solid #333;
    border-top: 15px solid transparent;
    border-bottom: 15px solid transparent;
    margin-left: 5px;
}

/* Video thumbnail styles */
.ald-video-thumbnail {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* Ensure all video elements have proper poster display */
video[poster] {
    object-fit: contain;
    object-position: center;
}

video::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

/* Video should be visible with overlay on top */
.ald-video-with-overlay .ald-hls-video,
.ald-video-with-overlay .ald-product-video-shortcode {
    opacity: 1;
    pointer-events: none;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    background-color: #000;
}

/* Force poster visibility for all video elements */
.ald-hls-video[poster],
.ald-product-video-shortcode[poster],
.ald-video-with-overlay video[poster] {
    background-size: contain !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Video element base styles */
.ald-hls-video,
.ald-product-video-shortcode {
    background-color: #000;
    border-radius: 8px;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* Ensure video elements show poster properly */
video.ald-hls-video,
video.ald-product-video-shortcode {
    object-fit: contain;
    object-position: center;
}

/* Loading state */
.ald-video-loading {
    position: relative;
}

.ald-video-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: ald-video-spin 1s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 20;
}

@keyframes ald-video-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .ald-video-wrapper {
        width: auto;
        max-width: none;
        min-width: 0;
        aspect-ratio: auto;
        margin: 0;
    }
    
    .ald-video-with-overlay .ald-hls-video,
    .ald-video-with-overlay .ald-product-video-shortcode {
        position: static;
        width: 100%;
        height: auto;
    }
    
    .ald-video-play-button {
        width: 60px;
        height: 60px;
    }
    
    .ald-video-play-button::before {
        border-left-width: 18px;
        border-top-width: 11px;
        border-bottom-width: 11px;
        margin-left: 4px;
    }
    
    .ald-video-modal .ald-modal-video {
        max-width: 98vw !important;
        max-height: 90vh !important;
        min-width: auto !important;
        min-height: auto !important;
    }
    
    .ald-video-modal {
        padding: 10px !important;
    }
    
    .ald-video-modal .ald-modal-content {
        width: 95vw !important;
        height: 85vh !important;
        max-width: none !important;
        max-height: none !important;
        min-width: auto !important;
        min-height: auto !important;
    }
    
    /* Mobile fullscreen video styles */
    video:fullscreen {
        width: 100vw !important;
        height: 100vh !important;
        object-fit: contain !important;
    }
    
    video:-webkit-full-screen {
        width: 100vw !important;
        height: 100vh !important;
        object-fit: contain !important;
    }
    
    video:-moz-full-screen {
        width: 100vw !important;
        height: 100vh !important;
        object-fit: contain !important;
    }
}

/* Medium screen adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .ald-video-wrapper {
        width: 420px;
        max-width: 420px;
        margin: 0;
    }
}

/* Large screen adjustments */
@media (min-width: 1200px) {
    .ald-video-wrapper {
        width: 560px;
        max-width: 560px;
        margin: 0;
    }
}

/* Custom video modal styles */
.ald-video-modal {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.ald-video-modal .ald-modal-content {
    animation: aldModalFadeIn 0.3s ease-out;
}

.ald-video-modal .ald-modal-video {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    outline: none;
    max-width: 90vw;
    max-height: 80vh;
    min-width: 800px;
    min-height: 450px;
    width: auto;
    height: auto;
}

.ald-video-modal .ald-modal-close {
    transition: all 0.2s ease;
}

.ald-video-modal .ald-modal-close:hover {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.1);
}

@keyframes aldModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Prevent scrolling when modal is open */
body.ald-modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* Custom styles for inline video mode (when not using overlay) */
.ald-video-inline {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    height: auto;
    max-width: 480px;
    aspect-ratio: 16/9;
    object-fit: contain;
    display: block;
    margin: 0;
}

/* Ensure video maintains aspect ratio */
.ald-video-responsive {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
}

.ald-video-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Device-specific adjustments */
.ald-is-mobile .ald-video-wrapper {
    cursor: pointer;
}

.ald-is-desktop .ald-video-wrapper {
    cursor: pointer;
}

/* Accessibility improvements */
.ald-video-play-overlay:focus,
.ald-video-play-button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Screen reader text */
.ald-sr-only {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    padding: 0 !important;
    border: 0 !important;
    height: 1px !important;
    width: 1px !important;
    overflow: hidden;
}
