/* ============================================================
   BDSTOT GALLERY — Standalone Plugin CSS
   Dùng chung toàn trang, không phụ thuộc framework
   ============================================================ */

:root {
    --gallery-primary:   #53b966;
    --gallery-secondary: #004238;
    --gallery-overlay:   rgba(0, 0, 0, 0.96);
    --gallery-glass:     rgba(0, 0, 0, 0.45);
    --gallery-radius:    2.5rem;
    --gallery-speed:     0.35s;
}

/* ── Prevent body scroll when gallery is open ── */
body.gallery-open {
    overflow: hidden;
}

/* ============================================================
   LIGHTBOX BACKDROP
   ============================================================ */
#bds-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: var(--gallery-overlay);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--gallery-speed) ease,
                visibility var(--gallery-speed) ease;
}

#bds-gallery-lightbox.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Entrance animation for slides ── */
#bds-gallery-lightbox.is-open #bds-gallery-slider {
    animation: galleryFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes galleryFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   HEADER UI
   ============================================================ */
#bds-gallery-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 9050;
    transition: opacity var(--gallery-speed) ease,
                visibility var(--gallery-speed) ease;
}

#bds-gallery-header.ui-hidden,
#bds-gallery-footer.ui-hidden,
.bds-gallery-nav.ui-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── Close button ── */
#bds-gallery-close {
    background: var(--gallery-glass);
    backdrop-filter: blur(12px);
    border: none;
    color: #fff;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}
#bds-gallery-close:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.08);
}

/* ── Right side header controls ── */
.bds-gallery-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
}

/* ── Counter badge ── */
#bds-gallery-counter {
    background: var(--gallery-glass);
    backdrop-filter: blur(12px);
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #fff;
    white-space: nowrap;
}

/* ── Zoom control strip ── */
.bds-zoom-strip {
    display: flex;
    background: var(--gallery-glass);
    backdrop-filter: blur(12px);
    border-radius: 999px;
    padding: 0.2rem;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.bds-zoom-btn {
    background: none;
    border: none;
    color: #fff;
    padding: 0.45rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    line-height: 1;
}
.bds-zoom-btn:hover { color: var(--gallery-primary); }

/* ── Thumbnail tray toggle ── */
#bds-gallery-tray-btn {
    background: var(--gallery-glass);
    backdrop-filter: blur(12px);
    border: none;
    color: #fff;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
#bds-gallery-tray-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.08);
}

/* ============================================================
   MAIN SLIDER — transform-based (no native scroll, supports loop)
   ============================================================ */
#bds-gallery-slider {
    flex: 1;
    overflow: hidden;
    position: relative;
    cursor: grab;
    user-select: none;
}
#bds-gallery-slider:active { cursor: grabbing; }

#bds-gallery-track {
    display: flex;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.bds-slide {
    flex: 0 0 100vw;
    width: 100vw;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* ── Image slide ── */
.bds-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    pointer-events: none;
    display: block;
}

/* ── Video slide (YouTube embed) ── */
.bds-slide .bds-video-wrap {
    position: relative;
    width: min(90vw, 1200px);
    aspect-ratio: 16 / 9;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.bds-slide .bds-video-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ============================================================
   NAVIGATION ARROWS (Desktop only)
   ============================================================ */
.bds-gallery-nav {
    position: absolute;
    top: 0; bottom: 0;
    display: none;
    align-items: center;
    padding: 0 1rem;
    z-index: 9040;
    pointer-events: none;
    transition: opacity var(--gallery-speed) ease,
                visibility var(--gallery-speed) ease;
}
.bds-gallery-nav.left  { left: 0; }
.bds-gallery-nav.right { right: 0; }

@media (min-width: 768px) {
    .bds-gallery-nav { display: flex; }
}

.bds-nav-btn {
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    border: none;
    color: rgba(255,255,255,0.8);
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.bds-nav-btn:hover {
    background: var(--gallery-secondary);
    color: #fff;
    transform: scale(1.1);
}

/* ============================================================
   FOOTER / CAPTION
   ============================================================ */
#bds-gallery-footer {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    padding: 5rem 1.5rem 1.75rem;
    z-index: 9030;
    pointer-events: none;
    transition: opacity var(--gallery-speed) ease,
                visibility var(--gallery-speed) ease;
}

#bds-gallery-caption {
    font-size: 0.95rem;
    font-weight: 300;
    line-height: 1.6;
    max-width: 56rem;
    margin: 0 auto;
    text-align: center;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

@media (min-width: 768px) {
    #bds-gallery-caption { font-size: 1.1rem; }
    #bds-gallery-footer  { padding-bottom: 2.25rem; }
}

/* ============================================================
   THUMBNAIL TRAY (Bottom Sheet)
   ============================================================ */
#bds-gallery-tray {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(18, 18, 20, 0.97);
    backdrop-filter: blur(20px);
    border-radius: var(--gallery-radius) var(--gallery-radius) 0 0;
    box-shadow: 0 -12px 48px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    z-index: 9060;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
#bds-gallery-tray.is-open {
    transform: translateY(0);
}

/* ── Drag handle ── */
.bds-tray-handle {
    width: 3.5rem;
    height: 0.35rem;
    background: #3f3f46;
    border-radius: 999px;
    margin: 1.1rem auto 0.5rem;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Tray header ── */
.bds-tray-header {
    padding: 0.5rem 1.75rem 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.bds-tray-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 0.1rem;
}
.bds-tray-header p {
    font-size: 0.72rem;
    color: #71717a;
    margin: 0;
}
.bds-tray-close {
    background: none;
    border: none;
    color: var(--gallery-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}
.bds-tray-close:hover { color: var(--gallery-secondary); }

/* ── Thumbnail grid ── */
#bds-gallery-thumbs {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    padding: 1rem 1.25rem;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
#bds-gallery-thumbs::-webkit-scrollbar { display: none; }

@media (min-width: 576px)  { #bds-gallery-thumbs { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 768px)  { #bds-gallery-thumbs { grid-template-columns: repeat(8, 1fr); } }
@media (min-width: 1200px) { #bds-gallery-thumbs { grid-template-columns: repeat(10, 1fr); } }

/* ── Thumb item ── */
.bds-thumb {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #27272a;
    border-radius: 0.6rem;
    overflow: hidden;
    opacity: 0.38;
    cursor: pointer;
    transition: opacity 0.25s ease, outline 0.2s ease, transform 0.25s ease;
    outline: 2px solid transparent;
    outline-offset: 2px;
}
.bds-thumb:hover { opacity: 1; }
.bds-thumb img,
.bds-thumb .bds-thumb-video-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.45s ease;
}
.bds-thumb:hover img,
.bds-thumb:hover .bds-thumb-video-cover { transform: scale(1.1); }

/* Video play overlay on thumb */
.bds-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.35);
    z-index: 2;
}
.bds-thumb-play svg { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); }

/* Active thumbnail */
.bds-thumb.is-active {
    opacity: 1;
    outline-color: var(--gallery-primary);
    transform: scale(1.06);
    z-index: 5;
}

/* Tray bottom spacer */
.bds-tray-spacer { height: 2rem; flex-shrink: 0; }

#bds-gallery-slider img {
    transition: transform 0.15s ease;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
}