/*
 * Galería de imágenes de la ficha del producto (Producto.php, js/galeria_producto.js), como PcComponentes:
 * escritorio: miniaturas en columna a la izquierda e imagen grande con flechas; móvil: se desliza con el dedo,
 * con puntos y contador. Al pulsar la imagen se abre el visor a pantalla completa (con zoom en escritorio).
 */
/* el visor se crea fuera de .gp (al final del body), por eso lleva sus propias variables */
.gp, .gp-visor {
    --gp-borde: #dee2e6;
    --gp-activo: #0077a8;
    --gp-fondo-visor: #ffffff;
    --gp-texto-visor: #212529;
}
.gp {
    display: flex;
    gap: 12px;
    width: 100%;
}
@media (prefers-color-scheme: dark) {
    .gp, .gp-visor {
        --gp-borde: #3a3f44;
        --gp-activo: #5cc3ee;
        --gp-fondo-visor: #16191c;
        --gp-texto-visor: #e9ecef;
    }
}
.gp-miniaturas {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 72px;
    max-height: 480px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.gp-mini {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    padding: 4px;
    border: 2px solid var(--gp-borde);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}
.gp-mini img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.gp-mini.gp-activa {
    border-color: var(--gp-activo);
}
.gp-escenario {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}
.gp-pista {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: 12px;
    background: #ffffff;
}
.gp-pista::-webkit-scrollbar {
    display: none;
}
.gp-foto {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    height: min(55vh, 480px);
    margin: 0;
    padding: 8px;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}
.gp-foto img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.gp-flecha {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: 1px solid var(--gp-borde);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #212529;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    z-index: 2;
}
.gp-flecha:disabled {
    opacity: 0;
    pointer-events: none;
}
.gp-anterior {
    left: 8px;
}
.gp-siguiente {
    right: 8px;
}
.gp-contador {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 2px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 13px;
    display: none;
}
.gp-puntos {
    display: none;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}
.gp-punto {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--gp-borde);
    cursor: pointer;
}
.gp-punto.gp-activa {
    background: var(--gp-activo);
}
/* una sola imagen: sin miniaturas ni flechas */
.gp-una .gp-miniaturas, .gp-una .gp-flecha, .gp-una .gp-puntos, .gp-una .gp-contador {
    display: none !important;
}
@media (max-width: 767px) {
    .gp-miniaturas, .gp-flecha {
        display: none;
    }
    .gp-contador {
        display: block;
    }
    .gp-puntos {
        display: flex;
    }
    .gp-foto {
        height: min(45vh, 380px);
    }
}

/* ===== Visor a pantalla completa ===== */
.gp-visor {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: none;
    flex-direction: column;
    background: var(--gp-fondo-visor);
    color: var(--gp-texto-visor);
}
.gp-visor.gp-abierto {
    display: flex;
}
html.gp-sin-scroll, html.gp-sin-scroll body {
    overflow: hidden;
}
.gp-visor-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 15px;
}
.gp-visor-cerrar {
    border: 0;
    background: none;
    color: inherit;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
}
.gp-visor-escenario {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}
.gp-visor .gp-pista {
    height: 100%;
    border-radius: 0;
    background: transparent;
}
.gp-visor .gp-foto {
    height: 100%;
    cursor: zoom-in;
    overflow: hidden;
}
.gp-visor .gp-foto img {
    transition: transform .2s;
}
.gp-visor .gp-foto.gp-zoom {
    cursor: zoom-out;
}
.gp-visor .gp-foto.gp-zoom img {
    transform: scale(2.2);
    transition: none;
}
.gp-visor .gp-miniaturas {
    flex-direction: row;
    justify-content: center;
    flex: 0 0 auto;
    max-height: none;
    padding: 10px 16px 16px;
    overflow-x: auto;
}
.gp-visor .gp-flecha {
    display: block;
}
.gp-visor .gp-flecha:disabled {
    display: block;
}
@media (max-width: 767px) {
    .gp-visor .gp-flecha {
        display: none;
    }
    .gp-visor .gp-miniaturas {
        display: flex;
    }
    .gp-visor .gp-mini {
        width: 56px;
        height: 56px;
    }
}
