/**
 * Qvio Floating Button - Modal Styles
 *
 * Styles for the video modal overlay.
 * These styles are loaded only on the frontend.
 *
 * @package Qvio_WP
 */

// Body state when modal is open
body.qvio-modal-open {
    overflow: hidden;
}

// Modal backdrop
.qvio-modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, var(--qvio-backdrop-opacity, 0.7)) !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    animation: qvio-fade-in 0.2s ease;
    box-sizing: border-box !important;

    &--closing {
        animation: qvio-fade-out 0.2s ease forwards;
    }
}

// Modal container
.qvio-modal {
    position: relative !important;
    background: #000 !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    max-width: 95vw !important;
    max-height: 95vh !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;

    // Centered modal animation
    &--centered {
        animation: qvio-scale-in 0.3s ease;

        &.qvio-modal--closing {
            animation: qvio-scale-out 0.2s ease forwards;
        }
    }

    // Slide-in from left
    &--slide-left {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0 12px 12px 0;
        animation: qvio-slide-in-left 0.3s ease;

        &.qvio-modal--closing {
            animation: qvio-slide-out-left 0.2s ease forwards;
        }
    }

    // Slide-in from right
    &--slide-right {
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        max-height: 100vh;
        border-radius: 12px 0 0 12px;
        animation: qvio-slide-in-right 0.3s ease;

        &.qvio-modal--closing {
            animation: qvio-slide-out-right 0.2s ease forwards;
        }
    }

    // Size variants
    &--small {
        width: 400px;
    }

    &--medium {
        width: 600px;
    }

    &--large {
        width: 900px;
    }

    &--custom {
        width: var(--qvio-modal-width, 800px);
    }

    // Slide panels use fixed width
    &--slide-left,
    &--slide-right {
        &.qvio-modal--small {
            width: 350px;
        }

        &.qvio-modal--medium {
            width: 450px;
        }

        &.qvio-modal--large {
            width: 550px;
        }

        &.qvio-modal--custom {
            width: var(--qvio-modal-width, 500px);
        }
    }

    // Content area
    &__content {
        position: relative !important;
        width: 100% !important;
        // 16:9 aspect ratio for video modals
        padding-bottom: 56.25% !important;
        margin: 0 !important;
        box-sizing: border-box !important;

        iframe {
            position: absolute !important;
            top: 0 !important;
            left: 0 !important;
            width: 100% !important;
            height: 100% !important;
            border: none !important;
            margin: 0 !important;
            padding: 0 !important;
        }
    }

    // QnA mode - taller aspect ratio (closer to 4:3 or taller)
    &--qna &__content {
        // Use a taller container for QnA - approximately 4:5 aspect ratio
        padding-bottom: 125% !important;
    }

    // QnA with specific sizes - use fixed heights
    &--qna.qvio-modal--small &__content {
        padding-bottom: 0 !important;
        height: 500px !important;
    }

    &--qna.qvio-modal--medium &__content {
        padding-bottom: 0 !important;
        height: 600px !important;
    }

    &--qna.qvio-modal--large &__content {
        padding-bottom: 0 !important;
        height: 700px !important;
    }

    &--qna.qvio-modal--custom &__content {
        padding-bottom: 0 !important;
        height: var(--qvio-modal-height, 600px) !important;
    }

    // Slide panels have different sizing - full height
    &--slide-left &__content,
    &--slide-right &__content {
        padding-bottom: 0;
        // 60px = close button (40px) + top margin (12px) + bottom padding (8px)
        height: calc(100vh - 60px);

        iframe {
            position: static;
            height: 100%;
        }
    }

    // Close button
    &__close {
        position: absolute;
        top: 12px;
        right: 12px;
        z-index: 1;
        background: rgba(0, 0, 0, 0.6);
        border: none;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #fff;
        transition: background 0.2s ease, transform 0.2s ease;
        padding: 0;

        &:hover {
            background: rgba(0, 0, 0, 0.8);
            transform: scale(1.1);
        }

        &:focus {
            outline: 2px solid #fff;
            outline-offset: 2px;
        }

        .dashicons {
            font-size: 24px;
            width: 24px;
            height: 24px;
            line-height: 24px;
        }
    }

    // For slide panels, position close button differently
    &--slide-left &__close,
    &--slide-right &__close {
        top: 10px;
    }
}

// Animations
@keyframes qvio-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes qvio-fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

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

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

@keyframes qvio-slide-in-left {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes qvio-slide-out-left {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}

@keyframes qvio-slide-in-right {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes qvio-slide-out-right {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

// Responsive adjustments
@media (max-width: 768px) {
    .qvio-modal {
        border-radius: 12px 12px 0 0;
        max-width: 100vw;
        width: 100vw !important;

        // On mobile, all modals slide up from bottom
        &--centered,
        &--slide-left,
        &--slide-right {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            top: auto;
            height: auto;
            max-height: 80vh;
            animation: qvio-slide-up 0.3s ease;

            &.qvio-modal--closing {
                animation: qvio-slide-down 0.2s ease forwards;
            }
        }

        &__content {
            padding-bottom: 56.25%; // Keep aspect ratio
        }

        // Reset slide panel specific styles on mobile
        &--slide-left &__content,
        &--slide-right &__content {
            padding-bottom: 56.25%;
            height: auto;

            iframe {
                position: absolute;
            }
        }
    }

    @keyframes qvio-slide-up {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    @keyframes qvio-slide-down {
        from {
            transform: translateY(0);
        }
        to {
            transform: translateY(100%);
        }
    }
}

// High contrast mode support
@media (prefers-contrast: high) {
    .qvio-modal__close {
        background: #000;
        border: 2px solid #fff;
    }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {
    .qvio-modal-backdrop,
    .qvio-modal,
    .qvio-modal__close {
        animation: none !important;
        transition: none !important;
    }
}
