/* ==========================================================================
   Atlas Product Gallery v1.0  ·  Blue #2563eb theme
   Mobile-first, touch-swipe, variation image swap, full Elementor controls.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
.apg-gallery {
    --apg-accent:       #2563eb;
    --apg-accent-mid:   #1d4ed8;
    --apg-accent-pale:  #eff6ff;
    --apg-border:       #e2e8f0;
    --apg-bg:           #f8fafc;
    --apg-white:        #ffffff;
    --apg-arrow-bg:     #ffffff;
    --apg-arrow-clr:    #374151;
    --apg-arrow-hover-bg:  #2563eb;
    --apg-arrow-hover-clr: #ffffff;
    --apg-radius:       14px;
    --apg-t-radius:     8px;
    --apg-thumb-size:   74px;
    --apg-gap:          8px;
    --apg-badge-bg:     #2563eb;
    --apg-badge-color:  #ffffff;

    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    user-select: none;
}

/* ── Main image area ────────────────────────────────────────────────────── */
.apg-main-wrap {
    position: relative;
    width: 100%;
    height: 480px;
    background: var(--apg-bg);
    border: 1.5px solid var(--apg-border);
    border-radius: var(--apg-radius);
    overflow: hidden;
    outline: none;
}

.apg-slides {
    position: relative;
    width: 100%;
    height: 100%;
}

.apg-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}

.apg-slide.is-active {
    opacity: 1;
    pointer-events: auto;
}

.apg-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: var(--apg-radius);
}

/* ── Zoom button ────────────────────────────────────────────────────────── */
.apg-zoom-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,.88);
    border-radius: 50%;
    color: #374151;
    text-decoration: none;
    backdrop-filter: blur(4px);
    transition: background .15s, color .15s;
    box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

.apg-zoom-btn:hover {
    background: var(--apg-accent);
    color: #fff;
}

/* ── Badge (e.g. "New", "Sale") ──────────────────────────────────────────── */
.apg-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--apg-badge-color);
    background: var(--apg-badge-bg);
    border-radius: 20px;
    pointer-events: none;
}

/* ── Arrows ─────────────────────────────────────────────────────────────── */
.apg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--apg-arrow-bg);
    color: var(--apg-arrow-clr);
    border: 1.5px solid var(--apg-border);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.apg-prev { left: 12px; }
.apg-next { right: 12px; }

.apg-arrow:hover {
    background: var(--apg-arrow-hover-bg);
    color: var(--apg-arrow-hover-clr);
    border-color: var(--apg-arrow-hover-bg);
    box-shadow: 0 4px 14px rgba(37,99,235,.25);
}

.apg-arrow:focus-visible {
    outline: 2px solid var(--apg-accent);
    outline-offset: 2px;
}

/* ── Dots (mobile indicator) ─────────────────────────────────────────────── */
.apg-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    gap: 6px;
    z-index: 10;
}

.apg-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(37,99,235,.25);
    transition: background .2s, transform .2s;
    cursor: pointer;
}

.apg-dot.is-active {
    background: var(--apg-accent);
    transform: scale(1.35);
}

/* ── Slide counter pill ─────────────────────────────────────────────────── */
.apg-counter {
    position: absolute;
    bottom: 12px;
    right: 14px;
    z-index: 10;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(15,23,42,.45);
    padding: 3px 9px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    pointer-events: none;
    line-height: 1.6;
}

/* ── Thumbnails ─────────────────────────────────────────────────────────── */
.apg-thumbs {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--apg-gap);
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--apg-accent) transparent;
}

.apg-thumbs::-webkit-scrollbar { height: 4px; }
.apg-thumbs::-webkit-scrollbar-thumb { background: var(--apg-accent); border-radius: 4px; }

.apg-thumb {
    flex-shrink: 0;
    width: var(--apg-thumb-size);
    height: var(--apg-thumb-size);
    padding: 0;
    background: var(--apg-bg);
    border: 2px solid var(--apg-border);
    border-radius: var(--apg-t-radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

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

.apg-thumb:hover {
    border-color: var(--apg-accent);
}

.apg-thumb.is-active {
    border-color: var(--apg-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.18);
}

.apg-thumb:focus-visible {
    outline: 2px solid var(--apg-accent);
    outline-offset: 2px;
}

/* ── Editor placeholder ─────────────────────────────────────────────────── */
.apg-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 280px;
    border: 2px dashed #bfdbfe;
    border-radius: 14px;
    padding: 32px;
    color: #93c5fd;
    background: #eff6ff;
    font-size: .875rem;
    text-align: center;
}

.apg-placeholder p { margin: 0; color: #1e40af; font-weight: 500; }

/* ── Vertical thumbnail layout ──────────────────────────────────────────── */
.apg-gallery.apg-layout-vertical {
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
}

.apg-gallery.apg-layout-vertical .apg-main-wrap {
    flex: 1;
    min-width: 0;
}

.apg-gallery.apg-layout-vertical .apg-thumbs {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 480px;
    padding-bottom: 0;
    padding-right: 4px;
    order: -1;
    scrollbar-width: thin;
    scrollbar-color: var(--apg-accent) transparent;
}

/* ── Responsive — Tablet ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .apg-gallery.apg-layout-vertical {
        flex-direction: column;
    }

    .apg-gallery.apg-layout-vertical .apg-thumbs {
        flex-direction: row;
        max-height: none;
        overflow-y: hidden;
        overflow-x: auto;
        order: 0;
    }
}

/* ── Responsive — Mobile ────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .apg-main-wrap {
        height: 320px;
    }

    .apg-dots {
        display: flex;
    }

    .apg-counter {
        display: none;
    }

    .apg-prev { left: 8px; }
    .apg-next { right: 8px; }

    .apg-arrow {
        width: 32px;
        height: 32px;
    }

    .apg-thumbs {
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apg-slide,
    .apg-arrow,
    .apg-thumb,
    .apg-zoom-btn { transition: none; }
}
