/**
 * Solicitar Cotización Mercadito — Visor de imágenes (v7.3.0)
 *
 * Se carga SOLO en la ficha de producto y solo con el visor activo.
 *
 * Los z-index arrancan en 999990: por encima de los encabezados fijos de
 * los temas (Blocksy ronda 100-1000) pero por debajo de la barra de
 * administración de WordPress (99999 en móvil), para no tapársela al
 * admin mientras edita.
 */

/* ========================================
   PISTA SOBRE LA GALERÍA
======================================== */

.scm-lb-zoomable img {
    cursor: zoom-in;
}

/* ========================================
   CONTENEDOR
======================================== */

.scm-lb[hidden] {
    display: none;
}

.scm-lb {
    position: fixed;
    inset: 0;
    z-index: 999990;
    display: flex;
}

.scm-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.96);
}

.scm-lb-panel {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    /* Respeta el notch y la barra inferior de los móviles */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

/* El scroll de la página se congela mientras el visor está abierto: si
   no, al deslizar sobre la imagen se movía la ficha por detrás. */
body.scm-lb-open {
    overflow: hidden;
}

/* ========================================
   BARRA SUPERIOR
======================================== */

.scm-lb-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
}

.scm-lb-counter {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.scm-lb-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scm-lb-btn {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.scm-lb-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.scm-lb-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.scm-lb-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* El botón de salir se distingue del resto: es el que la gente busca
   primero y, en la referencia, es el único en color. */
.scm-lb-close {
    background: #ef4444;
}

.scm-lb-close:hover:not(:disabled) {
    background: #dc2626;
}

/* El ícono nunca intercepta el clic (misma lección que la X del modal
   en v7.1.1: el clic aterrizaba en el <svg> y el botón no respondía). */
.scm-lb-btn svg,
.scm-lb-btn svg * {
    pointer-events: none;
}

.scm-lb-btn:focus-visible,
.scm-lb-nav:focus-visible,
.scm-lb-thumb:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ========================================
   ESCENARIO
======================================== */

.scm-lb-stage {
    flex: 1 1 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0; /* deja que la imagen se encoja dentro del flex */
    padding: 0 8px;
}

.scm-lb-figure {
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: pan-y;
}

.scm-lb-figure.is-zoomed {
    cursor: grab;
    touch-action: none;
}

.scm-lb-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.2s ease;
    transform-origin: center center;
}

/* Flechas */
.scm-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

.scm-lb-nav[hidden] {
    display: none;
}

.scm-lb-nav:hover {
    background: rgba(255, 255, 255, 0.28);
}

.scm-lb-nav svg {
    width: 24px;
    height: 24px;
    display: block;
    pointer-events: none;
}

.scm-lb-prev { left: 10px; }
.scm-lb-next { right: 10px; }

/* ========================================
   MINIATURAS AGRUPADAS
======================================== */

.scm-lb-thumbs {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 12px 14px 14px;
    overflow-x: auto;
    overflow-y: hidden;
    /* "safe" evita que, al desbordar, el centrado recorte el primer
       grupo dejándolo inalcanzable con el scroll. */
    justify-content: center;
    justify-content: safe center;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.scm-lb-thumbs::-webkit-scrollbar {
    height: 6px;
}

.scm-lb-thumbs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* Un grupo = título arriba + su fila de miniaturas abajo */
.scm-lb-tgroup {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Separador entre grupos: la línea nace del segundo en adelante */
.scm-lb-tgroup + .scm-lb-tgroup {
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.scm-lb-group {
    color: rgba(255, 255, 255, 0.72);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.scm-lb-trow {
    display: flex;
    gap: 10px;
}

.scm-lb-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    overflow: hidden;
    opacity: 0.62;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.scm-lb-thumb:hover {
    opacity: 1;
}

.scm-lb-thumb.is-active {
    opacity: 1;
    border-color: #fff;
}

.scm-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* ========================================
   MÓVIL
======================================== */

@media (max-width: 768px) {
    .scm-lb-bar {
        padding: 10px 12px;
    }

    /* Las flechas estorban en pantallas angostas y el gesto natural es
       deslizar; se mantienen las miniaturas y el contador para orientarse. */
    .scm-lb-nav {
        display: none;
    }

    .scm-lb-stage {
        padding: 0;
    }

    .scm-lb-thumb {
        width: 54px;
        height: 54px;
    }

    .scm-lb-thumbs {
        gap: 12px;
        padding: 8px 12px 10px;
        justify-content: flex-start;
    }

    .scm-lb-trow {
        gap: 8px;
    }

    .scm-lb-tgroup + .scm-lb-tgroup {
        padding-left: 12px;
    }

    .scm-lb-group {
        font-size: 10px;
        letter-spacing: 0.06em;
    }
}

/* Pantallas muy bajas en horizontal: la tira se come la imagen */
@media (max-height: 460px) {
    .scm-lb-thumbs {
        display: none;
    }
}

/* ========================================
   PREFERENCIA DE MOVIMIENTO REDUCIDO
======================================== */

@media (prefers-reduced-motion: reduce) {
    .scm-lb-img,
    .scm-lb-btn,
    .scm-lb-nav,
    .scm-lb-thumb {
        transition: none;
    }
}

/* ========================================
   FLECHAS DE LA GALERÍA DEL TEMA (v7.3.1)

   Se ocultan con la clase de estado .scm-hide-gallery-arrows en <body>,
   no tocando el DOM del slider: Blocksy re-renderiza el flexy en varios
   momentos (cambio de imagen, resize, init diferido) y un elemento
   recreado nacería sin la clase directa, con la flecha reapareciendo
   (misma lección que las miniaturas duplicadas de la v6.12.2).

   Las reglas están acotadas a los contenedores de galería del producto:
   un carrusel de productos relacionados o de una página aparte conserva
   sus flechas.
======================================== */

body.scm-hide-gallery-arrows .woocommerce-product-gallery .flex-direction-nav,
body.scm-hide-gallery-arrows .woocommerce-product-gallery .flexy-arrow-prev,
body.scm-hide-gallery-arrows .woocommerce-product-gallery .flexy-arrow-next,
body.scm-hide-gallery-arrows .ct-product-gallery-container .flexy-arrow-prev,
body.scm-hide-gallery-arrows .ct-product-gallery-container .flexy-arrow-next,
body.scm-hide-gallery-arrows .ct-media-container .flexy-arrow-prev,
body.scm-hide-gallery-arrows .ct-media-container .flexy-arrow-next,
body.scm-hide-gallery-arrows .product-gallery .flex-direction-nav,
body.scm-hide-gallery-arrows .product-images .flex-direction-nav,
body.scm-hide-gallery-arrows .single-product div.images .flex-direction-nav,
/* Sliders genéricos que algunos temas usan para la galería */
body.scm-hide-gallery-arrows .woocommerce-product-gallery .swiper-button-prev,
body.scm-hide-gallery-arrows .woocommerce-product-gallery .swiper-button-next,
body.scm-hide-gallery-arrows .ct-product-gallery-container .swiper-button-prev,
body.scm-hide-gallery-arrows .ct-product-gallery-container .swiper-button-next,
body.scm-hide-gallery-arrows .woocommerce-product-gallery .slick-prev,
body.scm-hide-gallery-arrows .woocommerce-product-gallery .slick-next,
body.scm-hide-gallery-arrows .woocommerce-product-gallery .owl-nav {
    display: none !important;
}
