/* Lightbox ảnh dùng chung — bố cục + hiệu ứng trượt như trang chi tiết sản phẩm */

.pil-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 99999;
    z-index: var(--z-product-image-lightbox, 99999);
    display: none;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
}

.pil-lightbox.is-open {
    display: flex;
}

body.pil-lightbox-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

@supports (-webkit-touch-callout: none) {
    body.pil-lightbox-open {
        position: fixed !important;
        overflow: hidden !important;
    }
}

.pil-lightbox .pil-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    max-width: 100vw;
}

.pil-lightbox .pil-image-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

.pil-lightbox .pil-track {
    --slide-gap: 16px;
    position: relative;
    display: block;
    will-change: transform;
    touch-action: pinch-zoom;
}

.pil-lightbox .pil-track.is-swipeable {
    cursor: grab;
}

.pil-lightbox .pil-track.is-dragging {
    cursor: grabbing;
}

.pil-lightbox .pil-slide.is-prev,
.pil-lightbox .pil-slide.is-next {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0;
}

.pil-lightbox .pil-slide.is-prev {
    right: calc(100% + var(--slide-gap));
}

.pil-lightbox .pil-slide.is-next {
    left: calc(100% + var(--slide-gap));
}

.pil-lightbox .pil-slide {
    max-width: calc(100vw - 170px);
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: auto;
    position: relative;
    background: none;
    border-radius: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: pinch-zoom;
    -webkit-touch-callout: none;
}

.pil-lightbox .pil-close {
    position: absolute;
    top: 18px;
    right: 32px;
    color: #fff;
    font-size: 2.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.pil-lightbox .pil-close:hover,
.pil-lightbox .pil-close:focus-visible {
    background: #0d6efd;
    color: #fff;
    outline: none;
}

.pil-lightbox .pil-topbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.pil-lightbox .pil-topbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pil-lightbox .pil-counter {
    color: #fff;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 5px 12px;
    white-space: nowrap;
    pointer-events: none;
}

.pil-lightbox .pil-hd-btn {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 32px;
    padding: 0 10px;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.75);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
}

.pil-lightbox .pil-hd-btn:hover:not(:disabled) {
    background: #0d6efd;
    border-color: #0d6efd;
}

.pil-lightbox .pil-hd-btn.is-active {
    background: #0d6efd;
    border-color: #0d6efd;
}

.pil-lightbox .pil-hd-btn.is-loading {
    cursor: progress;
    animation: pilHdPulse 1s ease-in-out infinite;
}

.pil-lightbox .pil-hd-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@keyframes pilHdPulse {
    50% { opacity: 0.45; }
}

.pil-lightbox .pil-hd-status {
    display: none;
    align-items: center;
    gap: 6px;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.82rem;
    white-space: nowrap;
    pointer-events: none;
}

.pil-lightbox .pil-hd-status i {
    color: #22c55e;
}

.pil-lightbox .pil-arrow {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: background 0.2s;
    color: #fff;
    padding: 0;
}

.pil-lightbox .pil-arrow:hover,
.pil-lightbox .pil-arrow:focus-visible {
    background: #0d6efd;
    outline: none;
}

.pil-lightbox .pil-arrow[hidden] {
    display: none !important;
}

@media (max-width: 767.98px) {
    .pil-lightbox .pil-slide {
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
    }
    .pil-lightbox .pil-stage {
        gap: 0;
        max-width: 100vw;
    }
    .pil-lightbox .pil-arrow {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 46px;
        height: 46px;
        z-index: 2;
    }
    .pil-lightbox .pil-arrow.left {
        left: 4px;
    }
    .pil-lightbox .pil-arrow.right {
        right: 4px;
    }
    .pil-lightbox .pil-topbar {
        left: 8px;
        top: 8px;
        gap: 5px;
    }
    .pil-lightbox .pil-counter {
        font-size: 0.85rem;
        padding: 4px 10px;
    }
    .pil-lightbox .pil-hd-btn {
        height: 28px;
        min-width: 38px;
        padding: 0 9px;
        font-size: 0.8rem;
    }
    .pil-lightbox .pil-hd-status {
        font-size: 0.78rem;
        padding: 3px 9px;
    }
    .pil-lightbox .pil-close {
        right: 10px;
        top: 8px;
        font-size: 2rem;
        width: 36px;
        height: 36px;
    }
}
