/* ============================================================
   Aquarius Product Gallery — Frontend Styles
   ============================================================ */

/* Base Layout */
.aq-gallery {
    display: flex;
    flex-direction: row;
    gap: 12px;
    align-items: flex-start;
    width: 100%;
}

/* RTL — three selectors for Bricks Builder compatibility */
.aq-gallery.is-rtl,
.aq-gallery[dir="rtl"],
[dir="rtl"] .aq-gallery {
    flex-direction: row-reverse;
}

/* ---- Thumbnail Column ---- */
.aq-gallery__thumbs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding-right: 3px;
    /* max-height is NOT set here — set dynamically by JS */
}

.aq-gallery__thumbs::-webkit-scrollbar {
    width: 4px;
}
.aq-gallery__thumbs::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 2px;
}
.aq-gallery__thumbs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}
.aq-gallery__thumbs::-webkit-scrollbar-thumb:hover {
    background: #0E5BAD;
}

/* ---- Thumbnail Items ---- */
.aq-gallery__thumb-item {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s ease !important;
    transform: none !important;
}

.aq-gallery__thumb-item:hover {
    border-color: rgba(14, 91, 173, 0.6);
    transform: none !important;
}

.aq-gallery__thumb-item:hover img {
    transform: none !important;
}

.aq-gallery__thumb-item.is-active {
    border-color: #0E5BAD;
}

.aq-gallery__thumb-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: none !important;
    transition: border-color 0.2s ease !important;
}

/* ---- Main Column ---- */
.aq-gallery__main {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.aq-gallery__main-image {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.25s ease;
}

/* ---- RTL: Thumbnails on the RIGHT ---- */
/* In RTL mode, the thumbnail column should appear AFTER the main image in DOM order,
   so flex-direction: row-reverse puts thumbs on the right. */
.aq-gallery.is-rtl .aq-gallery__thumbs,
.aq-gallery[dir="rtl"] .aq-gallery__thumbs,
[dir="rtl"] .aq-gallery .aq-gallery__thumbs {
    order: 2;
}

.aq-gallery.is-rtl .aq-gallery__main,
.aq-gallery[dir="rtl"] .aq-gallery__main,
[dir="rtl"] .aq-gallery .aq-gallery__main {
    order: 1;
}

/* ---- Video Thumbnail ---- */
.aq-gallery__video-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
}

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

.aq-gallery__video-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.aq-gallery__video-overlay .play-icon {
    color: #fff;
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
}

.aq-gallery__video-overlay .watch-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: 8px;
    text-align: center;
    line-height: 1.2;
    padding: 0 4px;
    pointer-events: none;
}

/* ---- Video Player ---- */
.aq-gallery__video-player {
    display: none;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.aq-gallery__video-player.is-active {
    display: block;
}

.aq-gallery__video-player iframe,
.aq-gallery__video-player video {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .aq-gallery {
        flex-direction: column !important;
        width: 100%;
    }

    .aq-gallery__main {
        width: 100% !important;
        order: 1;
    }

    .aq-gallery__thumbs {
        width: 100% !important;
        order: 2;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        max-height: none !important;
        padding-bottom: 6px;
        gap: 8px;
    }

    .aq-gallery__thumbs::-webkit-scrollbar {
        height: 4px;
    }

    .aq-gallery__thumb-item,
    .aq-gallery__video-thumb {
        width: 70px !important;
        height: 70px !important;
        flex-shrink: 0;
    }
}
