/* ═══════════════════════════════════════════════════════════════
 * Galería de producto — img principal + tira de thumbs
 * ═══════════════════════════════════════════════════════════════ */

/* Override del contenedor heredado de styles.css */
.ficha-card .image:has(.product-gallery) {
    height: auto;
    overflow: visible;
}

.product-gallery {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f5f5;
}

/* ── Imagen principal ──────────────────────────────────────────── */
.gallery-main {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f5f5f5;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0px 30px #e7e7e7;
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.2s ease;

}

.gallery-main img.is-loading {
    opacity: 0.4;
}

/* ── Tira de thumbs ───────────────────────────────────────────── */
.gallery-thumbs {
    position: relative;
    padding: 0 34px; /* espacio para las flechas */
}

.gallery-thumbs-swiper {
    overflow: hidden;
}

.gallery-thumbs-swiper .swiper-slide {
    width: 76px !important;
    height: 76px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.gallery-thumbs-swiper .swiper-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-thumbs-swiper .swiper-slide.is-active,
.gallery-thumbs-swiper .swiper-slide:hover {
    border-color: #b2b2b2;
}

/* ── Flechas de la tira ───────────────────────────────────────── */
.gallery-prev,
.gallery-next {
    position: absolute;
    top: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b2b2b2;
    cursor: pointer;
    z-index: 10;
}

.gallery-prev {
    left: 0;
}

.gallery-next {
    right: 0;
}

.gallery-prev::after,
.gallery-next::after {
    font-size: 14px !important;
}

/* Ocultar flechas si Swiper las deshabilita */
.gallery-prev.swiper-button-disabled,
.gallery-next.swiper-button-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* ── Hint de zoom en imagen principal ────────────────────────── */
.gallery-main {
    cursor: zoom-in;
    position: relative;
}

.gallery-main::after {
    content: '⤢';
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 18px;
    color: #fff;
    background: rgba(0,0,0,0.35);
    border-radius: 4px;
    padding: 2px 5px;
    line-height: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-main:hover::after {
    opacity: 1;
}

/* ── Modal lightbox ───────────────────────────────────────────── */
.gallery-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.88);
    align-items: center;
    justify-content: center;
}

.gallery-lightbox.is-open {
    display: flex;
}

/* Contenedor con tamaño fijo y overflow hidden para el modo full */
.gallery-lightbox-inner {
    position: relative;
    width: min(90vw, 1000px);
    height: min(85vh, 900px);
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Estado FIT: imagen adaptada al contenedor */
#lightbox-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}

/* Estado FULL: tamaño natural, posicionada absolutamente para poder dragear */
#lightbox-img.lb-zoomed {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    max-height: none;
    cursor: grab;
}

#lightbox-img.lb-dragging {
    cursor: grabbing;
}

.gallery-lightbox-close {
    position: fixed;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    z-index: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.gallery-lightbox-close:hover {
    opacity: 1;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .gallery-thumbs-swiper .swiper-slide {
        width: 60px !important;
        height: 60px;
    }
}
