/* ============================================================
   Product Video Gallery v3 - pvg-style.css
   Path: /wp-content/themes/flatsome-child/product-video-gallery/pvg-style.css
   ============================================================ */

/* ── 1. GALLERY CHÍNH: ảnh 900x900 cân đối ─────────────────────────────── */

.woocommerce-product-gallery .woocommerce-product-gallery__image img,
.woocommerce-product-gallery .flex-viewport img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
    background: #fff;
}

/* Đảm bảo container giữ tỷ lệ 1:1 cho ảnh vuông */
.woocommerce-product-gallery .flex-viewport {
    aspect-ratio: 1 / 1 !important;
    max-height: none !important;
}

/* Mobile: gallery to hơn, chiếm nhiều màn hình hơn */
@media (max-width: 768px) {
    .woocommerce-product-gallery {
        width: 100% !important;
        max-width: 100% !important;
    }

    .woocommerce-product-gallery .flex-viewport {
        /* Ép chiều cao lớn hơn trên mobile */
        min-height: 75vw !important;
    }

    /* Summary bên dưới gallery trên mobile */
    .woocommerce div.product div.images,
    .woocommerce div.product div.summary {
        float: none !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ── 2. VIDEO SLIDE CHÍNH trong gallery ─────────────────────────────────── */

.pvg-video-main-slide {
    cursor: pointer !important;
    position: relative;
}

.pvg-main-video-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-size: cover;
    background-position: center;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Overlay tối nhẹ */
.pvg-main-video-thumb::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.18);
    transition: background 0.2s;
}

.pvg-video-main-slide:hover .pvg-main-video-thumb::before {
    background: rgba(0,0,0,0.08);
}

.pvg-main-play {
    position: relative;
    z-index: 1;
}

.pvg-main-play svg {
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 3px 10px rgba(0,0,0,0.5));
    transition: transform 0.2s, filter 0.2s;
}

.pvg-video-main-slide:hover .pvg-main-play svg {
    transform: scale(1.12);
    filter: drop-shadow(0 4px 16px rgba(0,0,0,0.6));
}

/* ── 3. NAV THUMBNAIL VIDEO (strip .product-thumbnails của Flatsome) ────── */

/* div.col là item của Flickity nav trong Flatsome */
.product-thumbnails .pvg-video-nav-thumb {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

/* Match border style khi active — Flatsome dùng .is-nav-selected */
.product-thumbnails .pvg-video-nav-thumb.is-nav-selected a,
.product-thumbnails .pvg-video-nav-thumb:hover a {
    border-color: currentColor;
    opacity: 1;
}

.product-thumbnails .pvg-video-nav-thumb a {
    display: block;
    position: relative;
    overflow: hidden;
}

.product-thumbnails .pvg-video-nav-thumb img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    aspect-ratio: 1 / 1;
}

.pvg-nav-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.12);
    pointer-events: none;
}

.pvg-nav-play-icon svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* ── 4. LIGHTBOX POPUP ──────────────────────────────────────────────────── */

.pvg-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
}

.pvg-lightbox.pvg-is-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pvg-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 8, 0.94);
}

.pvg-lb-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 8px 16px 12px;
    box-sizing: border-box;
    gap: 8px;
}

/* Top bar */
.pvg-lb-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.pvg-lb-label {
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 65%;
}

.pvg-lb-close {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    font-family: inherit;
}

.pvg-lb-close:hover { background: rgba(255,255,255,0.2); }

/* Stage — view chiếm toàn bộ, arrows overlay lên trên */
.pvg-lb-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* View box — tự động đổi ratio theo loại nội dung */
.pvg-lb-view {
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 6px;
    background: #000;
}

/* Ảnh 1:1 */
.pvg-lb-view.pvg-view--image {
    aspect-ratio: 1 / 1;
    max-height: 72vh;
    max-width: 72vh; /* giữ vuông không bị kéo rộng */
}

/* Video 16:9 */
.pvg-lb-view.pvg-view--video {
    aspect-ratio: 16 / 9;
    max-height: 72vh;
}

.pvg-lb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.pvg-lb-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Arrows OVERLAY lên trên ảnh/video */
.pvg-lb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    backdrop-filter: blur(2px);
}

.pvg-lb-prev { left: 10px; }
.pvg-lb-next { right: 10px; }

.pvg-lb-arrow:hover {
    background: rgba(0,0,0,0.7);
    transform: translateY(-50%) scale(1.08);
}

/* Counter */
.pvg-lb-counter {
    text-align: center;
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    flex-shrink: 0;
}

/* ── 5. THUMBNAIL STRIP — căn giữa khi ít item ──────────────────────────── */

.pvg-lb-thumbstrip {
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.pvg-lb-thumbstrip::-webkit-scrollbar { display: none; }

.pvg-lb-thumbtrack {
    display: flex;
    gap: 7px;
    /* justify-content được set bởi JS: center hoặc flex-start */
    justify-content: center; /* default căn giữa */
    min-width: 100%;         /* đảm bảo flex center hoạt động */
    box-sizing: border-box;
    padding: 2px 0;
}

.pvg-lb-thumb {
    flex-shrink: 0;
    width: 68px;
    height: 68px;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.5;
    position: relative;
    background: #1a1a1a;
    transition: opacity 0.2s, border-color 0.2s;
}

.pvg-lb-thumb:hover { opacity: 0.8; }

.pvg-lb-thumb.pvg-active {
    border-color: #fff;
    opacity: 1;
}

.pvg-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pvg-lb-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
}

.pvg-lb-thumb-play svg { width: 22px; height: 22px; }

/* ── 6. MOBILE ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .pvg-lb-shell {
        padding: 4px 6px 8px;
        gap: 5px;
    }

    /* View TO hơn — chiếm đa số màn hình */
    .pvg-lb-view.pvg-view--image {
        max-height: 80vw;   /* ảnh vuông 900x900 → dùng 80vw */
        aspect-ratio: 1 / 1;
    }

    .pvg-lb-view.pvg-view--video {
        max-height: 56vw;   /* video 16:9 → 56vw chiều cao */
        aspect-ratio: 16 / 9;
    }

    /* Arrows nhỏ gọn hơn nhưng vẫn nằm NGOÀI view */
    .pvg-lb-arrow {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    /* Stage giữ flex row — arrows vẫn ngoài view */
    .pvg-lb-stage {
        gap: 6px;
    }

    .pvg-lb-thumb {
        width: 54px;
        height: 54px;
    }

    .pvg-main-play svg {
        width: 50px;
        height: 50px;
    }

    /* Thumbnail strip popup: scroll khi nhiều item */
    .pvg-lb-thumbtrack {
        justify-content: flex-start;
    }
}

/* ── Nav thumbnail VIDEO col ── */
.product-thumbnails .pvg-video-nav-thumb {
    position: relative;
    cursor: pointer;
}

.product-thumbnails .pvg-video-nav-thumb a {
    display: block;
    position: relative;
    overflow: hidden;
}

.product-thumbnails .pvg-video-nav-thumb img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.pvg-nav-play-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.1);
    pointer-events: none;
}

.pvg-nav-play-icon svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
}

.pvg-nav-label {
    display: block;
    text-align: center;
    font-size: 11px;
    color: #666;
    margin-top: 3px;
    line-height: 1.2;
}

/* Video thumb trong main slider */
.pvg-video-main-slide {
    cursor: pointer;
    width: 100%;
}

.pvg-main-video-thumb {
    width: 100%;
    padding-bottom: 75%;  /* ratio thumbnail YouTube hqdefault là 4:3 */
    background-size: cover;
    background-position: center;
    background-color: #000;
    position: relative;
}

.pvg-main-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pvg-main-play svg {
    width: 72px;
    height: 72px;
    filter: drop-shadow(0 3px 12px rgba(0,0,0,0.5));
    transition: transform 0.2s;
}

.pvg-video-main-slide:hover .pvg-main-play svg {
    transform: scale(1.1);
}
