/**
 * WP Video Popup Manager - Frontend Styles
 *
 * Responsive modal overlay, 16:9 video container, and animations.
 *
 * @package WP_Video_Popup_Manager
 */

/* Modal Container (Overlay) */
.wpvp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), 
                visibility 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Modal Open State */
.wpvp-modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Modal Content Wrapper */
.wpvp-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: #000000;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.92) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.wpvp-modal-overlay.is-active .wpvp-modal-dialog {
    transform: scale(1) translateY(0);
}

/* Close Button (X) */
.wpvp-modal-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
    z-index: 10;
}

.wpvp-modal-close:hover,
.wpvp-modal-close:focus-visible {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
    color: #ffffff;
}

.wpvp-modal-close:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5);
}

.wpvp-modal-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 0.5;
}

/* 16:9 Responsive Aspect Ratio Container */
.wpvp-video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* Fallback 16:9 ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #000000;
}

@supports (aspect-ratio: 16 / 9) {
    .wpvp-video-wrapper {
        aspect-ratio: 16 / 9;
        height: auto;
        padding-bottom: 0;
    }
}

/* Video & Iframe Elements fill container */
.wpvp-video-wrapper iframe,
.wpvp-video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    object-fit: contain;
}

/* Shortcode Trigger Button Styles (Default fallback) */
.wpvp-trigger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: #2563eb;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-weight: 600;
    font-size: 15px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2), 0 2px 4px -2px rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
}

.wpvp-trigger-button:hover {
    background: #1d4ed8;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.wpvp-trigger-button:active {
    transform: translateY(0);
}

/* Audio Interaction Overlay (captures clicks on video to unmute) */
.wpvp-audio-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 25;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.001); /* Invisible click target covering video */
}

.wpvp-audio-overlay.is-hidden {
    display: none !important;
    pointer-events: none !important;
}

/* Floating Unmute Button */
.wpvp-unmute-button {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    cursor: pointer;
    z-index: 30;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(37, 99, 235, 0.6);
    animation: wpvp-pulse-audio 2s infinite cubic-bezier(0.66, 0, 0, 1);
    transition: all 0.25s ease;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.wpvp-unmute-button.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.wpvp-unmute-button.is-hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(-50%) translateY(10px) !important;
}

.wpvp-unmute-button:hover {
    background: #2563eb;
    border-color: #60a5fa;
    transform: translateX(-50%) scale(1.06);
    box-shadow: 0 15px 30px rgba(37, 99, 235, 0.4);
}

.wpvp-unmute-button svg {
    flex-shrink: 0;
}

@keyframes wpvp-pulse-audio {
    0% {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(37, 99, 235, 0.7);
    }
    70% {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 0 16px rgba(37, 99, 235, 0);
    }
    100% {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 0 0 rgba(37, 99, 235, 0);
    }
}

/* Responsive adjustments for mobile */
@media (max-width: 600px) {
    .wpvp-modal-overlay {
        padding: 12px;
    }

    .wpvp-modal-close {
        top: -40px;
        right: 0;
        width: 34px;
        height: 34px;
    }

    .wpvp-unmute-button {
        bottom: 15px;
        padding: 9px 18px;
        font-size: 13px;
        gap: 8px;
    }

    .wpvp-unmute-button svg {
        width: 18px;
        height: 18px;
    }
}

/* Ocultar temporalmente chatbots y botones flotantes mientras el video se reproduce */
body.wpvp-modal-open {
    overflow: hidden !important;
}

body.wpvp-modal-open .ccw_plugin,
body.wpvp-modal-open .joinchat,
body.wpvp-modal-open #chat-widget-container,
body.wpvp-modal-open .tidio-chat-iframe,
body.wpvp-modal-open #crisp-chatbox,
body.wpvp-modal-open [class*="chatbot"],
body.wpvp-modal-open [class*="whatsapp-btn"],
body.wpvp-modal-open [id*="chat-widget"] {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

