/**
 * Aura Product Videos - Frontend Styles
 */

/* ============================== */
/* DESKTOP - HOVER VIDEO          */
/* ============================== */

/* Product with video */
.apv-has-video .woocommerce-image__wrapper,
.apv-has-video .woocommerce-LoopProduct-link {
    position: relative;
    overflow: hidden;
}

/* All product thumbnails - border radius */
ul.products li.product img.attachment-woocommerce_thumbnail,
ul.products li.product .woocommerce-image__wrapper img,
.woocommerce-LoopProduct-link img {
    border-radius: 12px;
}

/* Product image transition (for video products) */
.apv-has-video .woocommerce-image__wrapper > a > img,
.apv-has-video .woocommerce-LoopProduct-link > img,
.apv-has-video img.attachment-woocommerce_thumbnail {
    transition: opacity 0.15s ease;
}

/* Hover video - hidden by default */
.apv-hover-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    display: none;
    transition: opacity 0.15s ease;
    z-index: 2;
    pointer-events: none;
    border-radius: 12px;
}

/* ============================== */
/* MOBILE - VIDEO BUTTON          */
/* ============================== */

/* Video button - visible only on mobile */
.apv-video-button {
    display: none;
}

@media (max-width: 768px) {
    /* Hide hover video on mobile completely */
    .apv-hover-video {
        display: none !important;
    }

    /* Show video button - MINIMAL */
    .apv-video-button {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        position: absolute;
        bottom: 18px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(255, 255, 255, 0.9);
        border: none;
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 14px !important;
        font-weight: 500;
        color: #333;
        cursor: pointer;
        z-index: 10;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        font-family: inherit;
        line-height: 1;
        white-space: nowrap;
    }

    .apv-video-button:hover,
    .apv-video-button:focus {
        background: rgba(255, 255, 255, 0.95);
        outline: none;
    }

    .apv-video-button svg {
        width: 14px;
        height: 14px;
        fill: #417B1B;
        flex-shrink: 0;
    }

    .apv-video-button span {
        white-space: nowrap;
    }
}

/* ============================== */
/* POPUP OVERLAY                  */
/* ============================== */

.apv-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: apvFadeIn 0.2s ease;
}

.apv-popup-overlay.apv-popup-closing {
    animation: apvFadeOut 0.2s ease forwards;
}

@keyframes apvFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes apvFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ============================== */
/* POPUP CONTAINER - MINIMAL      */
/* ============================== */

.apv-popup-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: apvScaleIn 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.apv-popup-closing .apv-popup-container {
    animation: apvScaleOut 0.2s ease forwards;
}

@keyframes apvScaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes apvScaleOut {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(0.95); opacity: 0; }
}

/* ============================== */
/* CLOSE BUTTON - FLOATING        */
/* ============================== */

.apv-popup-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.2s ease;
    z-index: 10;
}

.apv-popup-close:hover,
.apv-popup-close:focus {
    background: rgba(255, 255, 255, 0.25);
    outline: none;
}

.apv-popup-close svg {
    width: 18px;
    height: 18px;
}

/* ============================== */
/* VIDEO - ORIGINAL RESOLUTION    */
/* ============================== */

.apv-popup-content {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.apv-popup-content video {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    outline: none;
    border-radius: 12px;
}

/* ============================== */
/* MOBILE                         */
/* ============================== */

@media (max-width: 768px) {
    .apv-popup-overlay {
        padding: 12px;
    }

    .apv-popup-container {
        max-width: 100%;
        max-height: 100%;
    }

    .apv-popup-close {
        top: -36px;
        right: 4px;
        width: 28px;
        height: 28px;
    }

    .apv-popup-close svg {
        width: 16px;
        height: 16px;
    }

    /* Video in popup - support for both 16:9 and 9:16 formats */
    .apv-popup-content {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 90vh;
    }

    .apv-popup-content video {
        max-width: calc(100vw - 24px);
        max-height: 85vh;
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 10px;
    }
}

/* ============================== */
/* SMALL MOBILE                   */
/* ============================== */

@media (max-width: 480px) {
    .apv-video-button {
        font-size: 12px !important;
        gap: 4px;
        padding: 6px 12px;
        bottom: 18px;
    }

    .apv-video-button svg {
        width: 11px;
        height: 11px;
    }
}

/* ============================== */
/* HIDE THEME TOOLTIPS            */
/* ============================== */

/* SHOPTIMIZER THEME - Hide image alt overlay */
ul.products li.product .woocommerce-LoopProduct-link .secondary-image-hover,
ul.products li.product .woocommerce-image__wrapper .image-overlay,
ul.products li.product .product-image-overlay,
ul.products li.product .shoptimizer-product-overlay,
ul.products li.product .product-thumbnail-overlay,
ul.products li.product figcaption,
ul.products li.product .wp-post-image + *:not(.apv-hover-video):not(.apv-video-button),
.woocommerce ul.products li.product .image-wrap .overlay,
.woocommerce ul.products li.product .overlay {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Hide any custom tooltip overlays from theme */
ul.products li.product .woocommerce-image__wrapper::before,
ul.products li.product .woocommerce-image__wrapper::after,
ul.products li.product .woocommerce-LoopProduct-link::before,
ul.products li.product .woocommerce-LoopProduct-link::after,
ul.products li.product .product-image-wrapper::before,
ul.products li.product .product-image-wrapper::after {
    display: none !important;
    content: none !important;
}

/* Hide any tooltip/overlay elements */
.product-tooltip,
.image-tooltip,
.product-overlay-text,
.woocommerce-image-tooltip,
ul.products li.product .overlay-text {
    display: none !important;
}

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

.apv-video-button:focus-visible,
.apv-popup-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .apv-popup-overlay,
    .apv-popup-container,
    .apv-hover-video,
    .apv-video-button {
        animation: none;
        transition: none;
    }
}

/* ============================== */
/* FULLSCREEN PLAYER (MOBILE)     */
/* ============================== */

.apv-fullscreen-player {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: #000;
    animation: apvSlideUp 0.3s ease;
}

.apv-fullscreen-player.apv-player-closing {
    animation: apvSlideDown 0.25s ease forwards;
}

@keyframes apvSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes apvSlideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.apv-fullscreen-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
}

/* Fullscreen Video */
.apv-fullscreen-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 1;
}

/* Player UI Overlay */
.apv-player-ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
}

.apv-player-ui > * {
    pointer-events: auto;
}

/* Close Button - Top Right */
.apv-player-close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top, 16px));
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.apv-player-close:hover,
.apv-player-close:focus {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.apv-player-close svg {
    width: 20px;
    height: 20px;
}

/* Sound Controls - Right Side */
.apv-player-controls {
    position: absolute;
    right: 16px;
    bottom: 140px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.apv-player-sound {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.apv-player-sound:hover,
.apv-player-sound:focus {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

.apv-player-sound svg {
    width: 22px;
    height: 22px;
}

/* Product Info - Bottom */
.apv-player-product {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 16px;
    padding-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
    display: flex;
    align-items: center;
    gap: 12px;
}

.apv-player-product-img {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.2);
}

.apv-player-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.apv-player-product-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apv-player-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #CEF34E;
}

.apv-player-product-btn {
    flex-shrink: 0;
    padding: 12px 24px;
    background: #417B1B;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 24px;
    transition: all 0.2s ease;
}

.apv-player-product-btn:hover,
.apv-player-product-btn:focus {
    background: #2e5c0b;
    color: #fff;
    transform: scale(1.02);
}

/* Pause Icon - Center */
.apv-player-pause-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 5;
}

.apv-player-pause-icon svg {
    width: 32px;
    height: 32px;
}

.apv-player-pause-icon.apv-visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
