/* =============================================
   Codlion Product Gallery — Slider, Arrows, Dots,
   Thumbnails, Lightbox
   ============================================= */

.cl-product-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

/*
 * Slider container uses padding-top trick for aspect ratio.
 * Zero CLS: space is reserved on first paint, before images load.
 * Ratio controlled via customizer: .cl-ratio-1-1, .cl-ratio-4-5, etc.
 */
.cl-gallery-slider {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: var(--cl-surface-muted, #fafafa);
    border: 1px solid var(--cl-border-light, #f0f0f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    touch-action: pan-y;
}

.cl-gallery-slider.cl-ratio-1-1  { padding-top: 100%; }
.cl-gallery-slider.cl-ratio-4-5  { padding-top: 125%; }
.cl-gallery-slider.cl-ratio-3-4  { padding-top: 133.33%; }
.cl-gallery-slider.cl-ratio-16-9 { padding-top: 56.25%; }

.cl-gallery-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    height: 100%;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.cl-gallery-slide {
    position: relative;
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
}

.cl-gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    user-select: none;
}

/* Arrows */
.cl-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--cl-arrow-color, #374151);
    cursor: pointer;
    z-index: 3;
    opacity: 1;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.cl-gallery-arrow:hover {
    background: var(--cl-arrow-bg, rgba(255, 255, 255, 0.9));
    color: var(--cl-arrow-color, #111827);
}

.cl-gallery-prev {
    left: 12px;
}

.cl-gallery-next {
    right: 12px;
}

/* Dots (shown when thumbnails are hidden) */
.cl-gallery-dots {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
    padding: 0;
}

.cl-gallery-dot {
    width: 8px;
    height: 8px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
}

.cl-gallery-dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

.cl-gallery-dot.active {
    width: 24px;
    border-radius: 4px;
    background: #fff;
}

/* Mobile: smaller dots */
@media (max-width: 991px) {
    .cl-gallery-dots {
        bottom: 8px;
        gap: 6px;
    }

    .cl-gallery-dot {
        width: 7px;
        height: 7px;
    }

    .cl-gallery-dot.active {
        width: 20px;
    }
}

/* Sale badge */
.cl-gallery-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    background: #D72E2E;
    color: var(--cl-btn-text, #fff);
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    line-height: 1;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* No image placeholder */
.cl-gallery-slider .cl-card-no-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cl-text-muted, #9ca3af);
    font-size: 14px;
}

/* Thumbnails — horizontal scroll strip with arrow navigation */
.cl-thumbs-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    justify-content: center;
    position: relative;
}

.cl-thumbs-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--cl-arrow-color, #374151);
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.cl-thumbs-prev {
    left: 0;
}

.cl-thumbs-next {
    right: 0;
}

.cl-thumbs-arrow.cl-thumbs-hidden {
    display: none;
}

.cl-thumbs-arrow:hover {
    background: var(--cl-arrow-bg, rgba(255, 255, 255, 0.9));
    color: var(--text-color, #111827);
}

.cl-gallery-thumbs {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    padding: 0 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.cl-gallery-thumbs::-webkit-scrollbar {
    display: none;
}

.cl-thumb {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    background: var(--cl-surface, #fff);
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.cl-thumb:hover {
    border-color: var(--cl-border, #e5e7eb);
}

.cl-thumb.active {
    border-color: var(--primary-color, #a67c52);
}

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

/* Lightbox (enabled via customizer) */
.cl-gallery-slider.cl-lightbox-enabled {
    cursor: zoom-in;
}

/* Drag cursor when in dots mode (no thumbnails, no lightbox) */
.cl-gallery-slider:not(.cl-lightbox-enabled) {
    cursor: grab;
}

.cl-gallery-slider:not(.cl-lightbox-enabled):active {
    cursor: grabbing;
}

.cl-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: zoom-out;
    padding: 24px;
}

.cl-lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
}

.cl-lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    color: var(--cl-btn-text, #fff);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    z-index: 10000;
}

/* RTL gallery */
.rtl-mode .cl-gallery-badge {
    left: auto;
    right: 12px;
}

.rtl-mode .cl-gallery-prev {
    left: auto;
    right: 12px;
}

.rtl-mode .cl-gallery-next {
    right: auto;
    left: 12px;
}

/* RTL: thumbnail arrows swap automatically via flex-direction reversal */
html[dir="rtl"] .cl-thumbs-wrapper {
    flex-direction: row-reverse;
}

/* Mobile responsive */
@media screen and (max-width: 991px) {
    .cl-gallery-slider {
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }
}

