/* ============================================
   Jeex Product Videos - Frontend Styles
   Fully RTL Compatible + Elessi Theme Ready
   ============================================ */

/* Section Container */
.jpv-videos-section {
    padding: 40px 15px;
    margin: 30px auto;
    clear: both;
    width: 100%;
    max-width: 1200px !important;
    box-sizing: border-box;
}

/* Force max-width in all contexts */
div.jpv-videos-section,
.woocommerce div.jpv-videos-section,
.woocommerce-page div.jpv-videos-section,
.single-product div.jpv-videos-section,
body .jpv-videos-section {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
    padding-left: 15px;
    padding-right: 15px;
}

/* When inside Elessi's container or any wrapper - still respect max-width */
.container .jpv-videos-section,
.nasa-container .jpv-videos-section,
.row .jpv-videos-section,
.col-12 .jpv-videos-section,
.product-info .jpv-videos-section,
.entry-summary .jpv-videos-section,
.summary .jpv-videos-section,
.nasa-product-content-wrap .jpv-videos-section,
.product-content-wrap .jpv-videos-section {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Section Title */
.jpv-section-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 24px 0;
    padding: 0;
    text-align: center;
    letter-spacing: -0.3px;
    line-height: 1.3;
    color: #1a1a1a;
}

/* Shortcode section: minimal top spacing */
.jpv-tiktok-section {
    padding-top: 10px;
    margin-top: 10px;
}

/* When section has no title, reduce spacing further */
.jpv-videos-section:not(:has(.jpv-section-title)) {
    padding-top: 10px;
}

/* Carousel Wrapper */
.jpv-carousel-wrapper {
    position: relative;
    padding: 0 40px;
}

/* Swiper Container */
.jpv-swiper {
    overflow: hidden;
    padding: 4px 0;
}

/* Video Card */
.jpv-video-card {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #f5f5f5;
    position: relative;
}

.jpv-video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Video Thumbnail */
.jpv-video-thumb {
    position: relative;
    width: 100%;
    padding-bottom: 177.78%; /* 9:16 aspect ratio */
    background-size: cover;
    background-position: center;
    background-color: #e8e8e8;
    border-radius: 12px;
    overflow: hidden;
}

/* Placeholder (when no thumbnail) */
.jpv-video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.jpv-placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
}

.jpv-placeholder-icon svg {
    width: 48px;
    height: 48px;
}

/* Play Overlay */
.jpv-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    border-radius: 12px;
    z-index: 2;
}

.jpv-video-card:hover .jpv-play-overlay {
    background: rgba(0, 0, 0, 0.3);
}

/* Play Button */
.jpv-play-btn {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.jpv-video-card:hover .jpv-play-btn {
    opacity: 1;
    transform: scale(1);
}

.jpv-play-btn svg {
    fill: #1a1a1a;
    margin-left: 3px; /* offset for visual centering */
}

[dir="rtl"] .jpv-play-btn svg {
    margin-left: 0;
    margin-right: 3px;
}

/* Source Badge */
.jpv-source-badge {
    position: absolute;
    top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* LTR: badge on the left */
.jpv-source-badge {
    left: 10px;
    right: auto;
}

/* RTL: badge on the right */
[dir="rtl"] .jpv-source-badge {
    right: 10px;
    left: auto;
}

.jpv-source-badge svg {
    width: 16px;
    height: 16px;
    fill: white;
    color: white;
}

/* ============================================
   Navigation Buttons
   ============================================ */
.jpv-nav-btn {
    width: 36px !important;
    height: 36px !important;
    background: #fff !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease !important;
}

.jpv-nav-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    transform: scale(1.05);
}

.jpv-nav-btn::after {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: #333 !important;
}

.swiper-button-next.jpv-nav-btn {
    right: 0 !important;
}

.swiper-button-prev.jpv-nav-btn {
    left: 0 !important;
}

[dir="rtl"] .swiper-button-next.jpv-nav-btn {
    left: 0 !important;
    right: auto !important;
}

[dir="rtl"] .swiper-button-prev.jpv-nav-btn {
    right: 0 !important;
    left: auto !important;
}

.swiper-button-disabled.jpv-nav-btn {
    opacity: 0.3 !important;
}

/* ============================================
   Popup / Modal
   ============================================ */
.jpv-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.jpv-popup-overlay.jpv-popup-visible {
    display: flex !important;
}

.jpv-popup-overlay.jpv-popup-active {
    opacity: 1;
}

.jpv-popup-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.jpv-popup-overlay.jpv-popup-active .jpv-popup-container {
    transform: scale(1);
}

.jpv-popup-close {
    position: absolute;
    top: 12px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.jpv-popup-close {
    right: 12px;
}

[dir="rtl"] .jpv-popup-close {
    right: auto;
    left: 12px;
}

.jpv-popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.jpv-popup-content {
    width: 100%;
    position: relative;
    overflow: hidden;
    background: #000;
    border-radius: 0 0 16px 16px;
}

.jpv-popup-content iframe {
    width: 100%;
    height: 80vh;
    max-height: 800px;
    min-height: 500px;
    border: none;
    display: block;
    background: #000;
}

/* Source-specific popup styles */

/* Instagram: crop the header and footer chrome */
.jpv-source-instagram .jpv-popup-content {
    max-height: 80vh;
    overflow: hidden;
}

/* Facebook: clean display */
.jpv-source-facebook .jpv-popup-content {
    background: #000;
}

/* TikTok: already clean */
.jpv-source-tiktok .jpv-popup-content {
    background: #000;
}

/* YouTube: played via YT iframe API */
.jpv-source-youtube .jpv-popup-content {
    background: #000;
}

.jpv-source-youtube .jpv-popup-content iframe {
    width: 100% !important;
    height: 80vh !important;
    max-height: 800px;
    min-height: 480px;
}

/* Loading state - sits behind the iframe */
.jpv-popup-content .jpv-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 16px;
    z-index: 1;
}

.jpv-popup-content iframe {
    position: relative;
    z-index: 2;
}

.jpv-popup-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: jpv-spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes jpv-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Responsive
   ============================================ */
@media screen and (max-width: 1024px) {
    .jpv-carousel-wrapper {
        padding: 0 16px;
    }

    .jpv-section-title {
        font-size: 22px;
    }
}

@media screen and (max-width: 768px) {
    .jpv-videos-section {
        padding: 20px 0;
        margin: 15px 0;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Remove all side padding on mobile */
    div.jpv-videos-section,
    .woocommerce div.jpv-videos-section,
    body .jpv-videos-section {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
    }

    .jpv-carousel-wrapper {
        padding: 0 8px;
    }

    .jpv-section-title {
        font-size: 20px;
        margin-bottom: 14px;
        padding: 0 12px;
    }

    .jpv-play-btn {
        width: 44px;
        height: 44px;
        opacity: 1;
        transform: scale(1);
    }

    .jpv-play-btn svg {
        width: 24px;
        height: 24px;
    }

    .jpv-popup-container {
        max-width: 95vw;
        border-radius: 12px;
    }

    .jpv-popup-content iframe {
        height: 75vh;
        min-height: 400px;
    }

    .jpv-popup-overlay {
        padding: 10px;
    }

    /* Navigation arrows tighter on mobile */
    .swiper-button-next.jpv-nav-btn {
        right: 2px !important;
    }
    .swiper-button-prev.jpv-nav-btn {
        left: 2px !important;
    }
    [dir="rtl"] .swiper-button-next.jpv-nav-btn {
        left: 2px !important;
        right: auto !important;
    }
    [dir="rtl"] .swiper-button-prev.jpv-nav-btn {
        right: 2px !important;
        left: auto !important;
    }
}

@media screen and (max-width: 480px) {
    .jpv-carousel-wrapper {
        padding: 0 4px;
    }

    .jpv-nav-btn {
        width: 28px !important;
        height: 28px !important;
    }

    .jpv-nav-btn::after {
        font-size: 11px !important;
    }

    .jpv-source-badge {
        width: 26px;
        height: 26px;
        border-radius: 6px;
        top: 8px;
    }

    .jpv-source-badge svg {
        width: 14px;
        height: 14px;
    }

    /* LTR mobile */
    .jpv-source-badge {
        left: 8px;
    }

    /* RTL mobile */
    [dir="rtl"] .jpv-source-badge {
        right: 8px;
        left: auto;
    }

    .jpv-popup-content iframe {
        height: 70vh;
        min-height: 350px;
    }

    .jpv-video-card {
        border-radius: 10px;
    }

    .jpv-video-thumb {
        border-radius: 10px;
    }

    .jpv-play-overlay {
        border-radius: 10px;
    }
}

/* ============================================
   Elessi Theme Compatibility
   ============================================ */

/* Elessi theme containers */
.elsuspended .jpv-videos-section,
.elessi-theme .jpv-videos-section,
body[class*="theme-elessi"] .jpv-videos-section {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Override any Elessi max-width constraints */
.jpv-videos-section .swiper-wrapper {
    box-sizing: border-box;
}

/* Ensure Elessi tabs don't interfere */
.woocommerce-Tabs-panel .jpv-videos-section {
    margin-top: 20px;
}

/* Popup must escape any container */
body > .jpv-popup-overlay {
    position: fixed !important;
    z-index: 9999999 !important;
}

/* ============================================
   Print: Hide videos section
   ============================================ */
@media print {
    .jpv-videos-section,
    .jpv-popup-overlay {
        display: none !important;
    }
}

/* ============================================
   Body scroll lock when popup is open
   ============================================ */
body.jpv-body-no-scroll {
    overflow: hidden !important;
    position: relative !important;
}

/* ============================================
   Popup transition states
   ============================================ */
.jpv-popup-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.jpv-popup-overlay.jpv-popup-visible {
    display: flex !important;
}

.jpv-popup-overlay.jpv-popup-visible.jpv-popup-active {
    opacity: 1;
}
