/**
 * Video Hero Widget Styles
 */

/* Container - Adapts to parent container */
.cda-tv-hero-container {
    position: relative;
    width: 100%;
    height: 100%; /* Takes full height of parent container */
    min-height: 60vh; /* Ensure minimum height */
    overflow: hidden;
    background: #000;
}

/* Ensure YouTube iframe is visible in playerBox */
[id^="playerBox_"] iframe {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

/* Force height when parent has no explicit height */
.elementor-widget-cda-tv-video-hero .cda-tv-hero-container {
    position: relative;
    height: auto;
    min-height: 60vh;
}

.cda-tv-hero-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    --transition-duration: 1s; /* Default fallback */
}

/* Transition for contain mode */
.cda-tv-hero-player.transitioning-to-contain {
    transition: background-color var(--transition-duration) ease;
}

.cda-tv-hero-player.transitioning-to-contain iframe {
    transition: all var(--transition-duration) ease !important;
}

.cda-tv-hero-video {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    container-type: inline-size;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    overflow: hidden !important;
}

/* Video element styling - keep as is for HTML5 video */
.cda-tv-hero-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* YouTube iframe - mb.YTPlayer inspired solution */
.cda-tv-hero-video iframe {
    pointer-events: none;
    border: none;
    max-width: none !important;
}

/* Override any external styles */
.cda-tv-hero-video iframe[style] {
    /* Styles applied via JavaScript will take precedence */
}

/* Container for video */
.cda-tv-hero-video {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* mb.YTPlayer structure */
[id^="wrapper_"] {
    position: absolute !important;
    z-index: 0 !important;
    min-width: 100% !important;
    min-height: 100% !important;
    left: 0 !important;
    top: 0 !important;
    overflow: hidden !important;
}

[id^="playerBox_"] {
    position: absolute !important;
    z-index: 0 !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    overflow: hidden !important;
}

.YTPOverlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10 !important;
    background: transparent !important;
    pointer-events: none !important;
}

/* Ensure all parent containers have proper height */
.elementor-widget-cda-tv-video-hero {
    height: 100%;
}

/* Fullscreen cover toggle button */
.cda-tv-fullscreen-cover-toggle {
    display: none;
}

.cda-tv-hero-container.is-fullscreen .cda-tv-fullscreen-cover-toggle {
    display: flex;
}

.cda-tv-fullscreen-cover-toggle.is-active {
    background: rgba(255, 255, 255, 0.3);
}

/* Simulated fullscreen styles */
.cda-tv-hero-container.is-fullscreen.is-simulated {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: #000 !important;
}

/* Mobile fullscreen controls adjustment */
@media (max-width: 768px) {
    .cda-tv-hero-container.is-fullscreen .cda-tv-hero-controls {
        padding: 8px;
        gap: 8px;
    }
    
    .cda-tv-hero-container.is-fullscreen .cda-tv-hero-controls button {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .cda-tv-hero-container.is-fullscreen .cda-tv-hero-info-overlay {
        padding: 20px;
    }
    
    .cda-tv-hero-container.is-fullscreen .cda-tv-hero-info-overlay h2 {
        font-size: 20px;
    }
    
    .cda-tv-hero-container.is-fullscreen .cda-tv-hero-info-overlay .cda-tv-hero-description {
        font-size: 14px;
    }
}

.elementor-widget-cda-tv-video-hero .elementor-widget-container {
    height: 100%;
    min-height: 60vh;
}

/* YouTube blocker layer - completely blocks YouTube UI */
.cda-tv-youtube-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: auto;
    cursor: default;
    background: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* YouTube overlay for our controls */
.cda-tv-youtube-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9;
    pointer-events: none;
}

/* Block all mouse events on iframe container during hover */
.cda-tv-hero-video:hover iframe {
    pointer-events: none !important;
}

/* Pseudo element to catch all events */
.cda-tv-hero-video::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    pointer-events: auto;
}

.cda-tv-hero-container.allow-interaction .cda-tv-hero-video iframe {
    pointer-events: auto;
}

/* Controls */
.cda-tv-hero-controls {
    position: absolute;
    z-index: 15; /* Above YouTube blocker */
    display: flex;
    align-items: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Prevent blocking when hidden */
}

.cda-tv-hero-container:hover .cda-tv-hero-controls {
    opacity: 1;
    pointer-events: auto; /* Enable interaction when visible */
}

.cda-tv-hero-controls button {
    position: relative; /* For tooltip positioning */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 5px;
}

.cda-tv-hero-controls button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}



.cda-tv-hero-controls .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Control positions */
.cda-tv-hero-container.controls-top-left .cda-tv-hero-controls {
    top: 0;
    left: 0;
}

.cda-tv-hero-container.controls-top-right .cda-tv-hero-controls {
    top: 0;
    right: 0;
}

.cda-tv-hero-container.controls-bottom-left .cda-tv-hero-controls {
    bottom: 0;
    left: 0;
}

.cda-tv-hero-container.controls-bottom-right .cda-tv-hero-controls {
    bottom: 0;
    right: 0;
}

/* Info Overlay */
.cda-tv-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    pointer-events: auto; /* Ensure it's clickable */
}

.cda-tv-hero-overlay-content {
    max-width: 800px;
    width: 90%;
    text-align: center;
    padding: 40px;
    color: #fff;
}

.cda-tv-hero-category {
    display: inline-block;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
}

.cda-tv-hero-title {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 20px 0;
}

.cda-tv-hero-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 16px;
    opacity: 0.8;
}

.cda-tv-hero-meta span {
    display: flex;
    align-items: center;
}

.cda-tv-hero-meta span:not(:last-child):after {
    content: '•';
    margin-left: 20px;
    opacity: 0.5;
}

.cda-tv-hero-description {
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 30px;
    opacity: 0.9;
}

.cda-tv-hero-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.cda-tv-hero-actions a {
    padding: 12px 30px;
    text-decoration: none;
    transition: all 0.3s ease;
}

/* Live Indicator */
.cda-tv-hero-live-indicator {
    position: absolute;
    z-index: 15;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.cda-tv-hero-container.live-top-left .cda-tv-hero-live-indicator {
    top: 0;
    left: 0;
}

.cda-tv-hero-container.live-top-right .cda-tv-hero-live-indicator {
    top: 0;
    right: 0;
}

.cda-tv-live-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 20px;
    background: #ff0000;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
    animation: pulse 2s infinite;
}

.cda-tv-live-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

/* Loading */
.cda-tv-hero-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

.cda-tv-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Spot Overlay */
.cda-tv-hero-spot-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cda-tv-spot-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.cda-tv-spot-info {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10;
}

.cda-tv-spot-label {
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cda-tv-spot-skip {
    color: #fff;
    font-size: 14px;
}

.cda-tv-spot-skip-button {
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cda-tv-spot-skip-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.cda-tv-spot-player {
    width: 100%;
    height: 100%;
}

.cda-tv-spot-player iframe,
.cda-tv-spot-player video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 0, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .cda-tv-hero-title {
        font-size: 32px;
    }
    
    .cda-tv-hero-description {
        font-size: 16px;
    }
    
    .cda-tv-hero-overlay-content {
        padding: 20px;
    }
    
    .cda-tv-hero-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .cda-tv-hero-actions a {
        width: 100%;
        text-align: center;
    }
    
    .cda-tv-hero-controls {
        padding: 10px;
    }
    
    .cda-tv-hero-controls button {
        width: 35px;
        height: 35px;
    }
    
    .cda-tv-hero-controls .dashicons {
        font-size: 20px;
        width: 20px;
        height: 20px;
    }
    
    .cda-tv-live-badge {
        padding: 6px 15px;
        font-size: 12px;
    }
    
    .cda-tv-live-title {
        display: none;
    }
}

/* Fullscreen specific */
.cda-tv-hero-container.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    background: #000 !important;
}

/* Fullscreen video scaling */
.cda-tv-hero-container.is-fullscreen .cda-tv-hero-video {
    width: 100vw !important;
    height: 100vh !important;
    position: relative !important;
}

/* Fullscreen wrapper and playerBox */
.cda-tv-hero-container.is-fullscreen [id^="wrapper_"] {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
}

.cda-tv-hero-container.is-fullscreen [id^="playerBox_"] {
    width: 100vw !important;
    height: 100vh !important;
}

/* Let JavaScript handle iframe sizing in fullscreen */
.cda-tv-hero-container.is-fullscreen .cda-tv-hero-video iframe,
.cda-tv-hero-container.is-fullscreen [id^="playerBox_"] iframe {
    /* Remove all constraints - let JS handle it */
}

/* Ensure blockers work in fullscreen */
.cda-tv-hero-container.is-fullscreen .cda-tv-youtube-blocker {
    z-index: 100002 !important;
    pointer-events: auto !important;
    background: transparent !important;
    /* Block all YouTube interactions */
}

.cda-tv-hero-container.is-fullscreen .cda-tv-youtube-overlay {
    z-index: 100003 !important;
    pointer-events: none !important;
}

/* Fullscreen click catcher to trigger controls */
.cda-tv-hero-container.is-fullscreen .cda-tv-hero-video::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100003 !important;
    pointer-events: auto;
    cursor: default;
}

/* Fullscreen interaction layer - remove to avoid conflicts */
/* The YouTube blocker should handle this */

.cda-tv-hero-container.is-fullscreen .cda-tv-hero-controls {
    opacity: 0;
    z-index: 100004 !important;
    transition: opacity 0.3s ease;
    pointer-events: auto !important; /* Always enable pointer events */
}

.cda-tv-hero-container.is-fullscreen:hover .cda-tv-hero-controls,
.cda-tv-hero-container.is-fullscreen.controls-visible .cda-tv-hero-controls {
    opacity: 1 !important;
}

.cda-tv-hero-container.is-fullscreen .cda-tv-hero-controls button {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Mobile: always show controls in fullscreen */
@media (max-width: 768px) {
    .cda-tv-hero-container.is-fullscreen .cda-tv-hero-controls {
        opacity: 1 !important;
    }
}

.cda-tv-hero-container.is-fullscreen .cda-tv-hero-overlay {
    z-index: 100005 !important;
}

/* Editor specific */
.elementor-editor .cda-tv-hero-container {
    min-height: 400px; /* Ensure visibility in editor */
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.elementor-editor .cda-tv-hero-loading {
    display: none;
}

/* Editor overlay with background and text */
.elementor-editor .cda-tv-hero-container::after {
    content: 'VIDEO HERO';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="0.5" opacity="0.1"><polygon points="5 3 19 12 5 21 5 3"></polygon></svg>') center/200px no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 32px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    pointer-events: none;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.elementor-editor .cda-tv-hero-container[data-source]::after {
    content: 'VIDEO HERO\A' attr(data-source);
    white-space: pre-line;
    line-height: 1.5;
}

.elementor-editor .cda-tv-hero-container[data-source]::after {
    font-size: 24px;
}

/* Ensure widget fills parent container */
.elementor-widget-cda-tv-video-hero .elementor-widget-container {
    height: 100%;
}

/* Ensure container is always visible */
.elementor-widget-cda-tv-video-hero .cda-tv-hero-container {
    height: 100%; /* Use parent height when available */
}

/* Fallback when parent has no explicit height */
.elementor-widget-cda-tv-video-hero:not(.has-explicit-height) .cda-tv-hero-container {
    height: clamp(320px, 60vh, 900px); /* Same as min-height for consistency */
}
