/* VIM Product Gallery — replaces Woo Variation Gallery plugin */

/* ── Container ────────────────────────────────────────────── */
.vim-gallery {
    position: relative;
    width: 48%;
    float: left;
    margin-bottom: 1.5em;
    margin-right: 4%;
}

/* Astra / standard themes use .woocommerce-product-gallery at ~48% */
@media (max-width: 921px) {
    .vim-gallery {
        width: 100%;
        float: none;
        margin-right: 0;
    }
}

/* ── Main Slider ──────────────────────────────────────────── */
.vim-gallery-slider {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
}

.vim-gallery-slider__track {
    display: flex;
    transition: transform 0.35s ease;
    will-change: transform;
}

.vim-gallery-slide {
    flex: 0 0 100%;
    min-width: 100%;
    position: relative;
    cursor: zoom-in;
}

.vim-gallery-slide img {
    display: block;
    width: 100%;
    height: auto;
}

/* Navigation arrows */
.vim-gallery-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
    opacity: 0;
    padding: 0;
    font-size: 0;
    line-height: 1;
}

.vim-gallery-slider:hover .vim-gallery-arrow {
    opacity: 1;
}

.vim-gallery-arrow:hover {
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

.vim-gallery-arrow--prev { left: 10px; }
.vim-gallery-arrow--next { right: 10px; }

.vim-gallery-arrow svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #333;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Hide arrows when only 1 image */
.vim-gallery--single .vim-gallery-arrow { display: none; }

/* ── Thumbnail Strip ──────────────────────────────────────── */
.vim-gallery-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
}

.vim-gallery-thumb {
    flex: 0 0 auto;
    width: 80px;
    height: 80px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    opacity: 0.5;
    transition: opacity 0.2s, border-color 0.2s;
    background: #f8f8f8;
}

.vim-gallery-thumb:hover {
    opacity: 0.8;
}

.vim-gallery-thumb--active {
    opacity: 1;
    border-color: #333;
}

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

/* WooCommerce FlexSlider thumbnails — leave as default */

/* Hide thumbs when only 1 image */
.vim-gallery--single .vim-gallery-thumbs { display: none; }

/* ── Zoom ─────────────────────────────────────────────────── */
.vim-gallery-slide--zoomed {
    cursor: zoom-out;
    overflow: hidden;
}

.vim-gallery-slide--zoomed img {
    transform-origin: var(--zoom-x, 50%) var(--zoom-y, 50%);
    transform: scale(1.7);
    max-height: none;
    transition: none;
}

/* ── Lightbox ─────────────────────────────────────────────── */
.vim-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.vim-lightbox--open {
    opacity: 1;
    visibility: visible;
}

.vim-lightbox__close {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.vim-lightbox__close:hover {
    background: rgba(255,255,255,0.3);
}

.vim-lightbox__close svg {
    width: 20px;
    height: 20px;
    stroke: #fff;
    stroke-width: 2;
    fill: none;
}

.vim-lightbox__counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
}

.vim-lightbox__img-wrap {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vim-lightbox__img-wrap img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.vim-lightbox__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.vim-lightbox__arrow:hover {
    background: rgba(255,255,255,0.3);
}

.vim-lightbox__arrow--prev { left: 20px; }
.vim-lightbox__arrow--next { right: 20px; }

.vim-lightbox__arrow svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Magnifier icon on slider ────────────────────────────── */
.vim-gallery-zoom-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}

.vim-gallery-zoom-icon:hover {
    background: #fff;
}

.vim-gallery-zoom-icon svg {
    width: 16px;
    height: 16px;
    stroke: #333;
    stroke-width: 2;
    fill: none;
}

/* ── Loading state ───────────────────────────────────────── */
.vim-gallery-slide--loading {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vim-gallery-slide--loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #ddd;
    border-top-color: #333;
    border-radius: 50%;
    animation: vim-gallery-spin 0.8s linear infinite;
}

@keyframes vim-gallery-spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .vim-gallery-thumb {
        width: 60px;
        height: 60px;
    }
    .vim-gallery-arrow {
        width: 34px;
        height: 34px;
        opacity: 1;
    }
    .vim-gallery-slide img {
        max-height: none;
    }
}
