/**
 * CTS2026 Theme — assets/css/product-lightbox.css
 * Lightbox de galería del producto individual.
 *
 * Isolation notes (Elementor-safe):
 *  - Todos los selectores usan el prefijo #cts-lightbox o .cts-lightbox__
 *  - z-index 1000100: por encima del search-modal (999999) y los popups de Elementor (~9999)
 *  - body.single-product scope para evitar filtraciones en páginas del editor
 *  - cursor: zoom-in SOLO en .cts-product-gallery__main (ya es exclusivo de esta plantilla)
 *  - No se usa .elementor, .e-, ni ninguna clase del namespace de Elementor
 */

/* ============================================================
   OVERLAY PRINCIPAL
   ============================================================ */
#cts-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000100;
    background: rgba(10, 12, 18, 0.92);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;

    /* Estado inicial: oculto sin afectar el layout */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.7s ease-out, visibility 0.7s ease-out;
}

#cts-lightbox.cts-lightbox--open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ============================================================
   FIGURA / IMAGEN CENTRAL
   ============================================================ */
.cts-lightbox__fig {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.88);
    transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: 90vw;
    max-height: 90vh;
}

#cts-lightbox.cts-lightbox--open .cts-lightbox__fig {
    transform: scale(1);
}

.cts-lightbox__img {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
    /* Evita que la imagen herede estilos globales de WooCommerce */
    padding: 0 !important;
    background: transparent !important;
}

/* ============================================================
   BOTÓN CERRAR (×)
   ============================================================ */
.cts-lightbox__close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    /* Reset de posibles estilos de botón del tema */
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
    padding: 0;
    text-transform: none;
    letter-spacing: normal;
}

.cts-lightbox__close:hover,
.cts-lightbox__close:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    transform: scale(1.08);
    outline: none;
}

/* ============================================================
   BOTONES PREV / NEXT
   ============================================================ */
.cts-lightbox__btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    /* Reset */
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
    padding: 0;
    text-transform: none;
    letter-spacing: normal;
}

.cts-lightbox__btn:hover,
.cts-lightbox__btn:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    outline: none;
}

.cts-lightbox__btn:active {
    transform: translateY(-50%) scale(0.92);
}

.cts-lightbox__prev {
    left: 1rem;
}

.cts-lightbox__next {
    right: 1rem;
}

/* Ocultar prev/next si solo hay una imagen (JS añade cts-lightbox--single) */
#cts-lightbox.cts-lightbox--single .cts-lightbox__btn {
    display: none;
}

/* ============================================================
   CONTADOR (ej: 2 / 4)
   ============================================================ */
.cts-lightbox__counter {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8125rem;
    font-family: inherit;
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
}

#cts-lightbox.cts-lightbox--single .cts-lightbox__counter {
    display: none;
}

/* ============================================================
   INDICADOR ZOOM en la imagen principal del producto
   (solo en páginas de producto, no en el editor de Elementor)
   ============================================================ */
body.single-product:not(.elementor-editor-active) .cts-product-gallery__main {
    cursor: zoom-in;
    position: relative; /* ya existe, pero lo aseguramos */
}

/* Icono de zoom sobre la esquina superior derecha */
body.single-product:not(.elementor-editor-active) .cts-product-gallery__main::after {
    content: '';
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    background-color: rgba(255, 255, 255, 0.75);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3Cline x1='11' y1='8' x2='11' y2='14'/%3E%3Cline x1='8' y1='11' x2='14' y2='11'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3Cline x1='11' y1='8' x2='11' y2='14'/%3E%3Cline x1='8' y1='11' x2='14' y2='11'/%3E%3C/svg%3E");
    mask-repeat: no-repeat;
    -webkit-mask-repeat: no-repeat;
    mask-size: contain;
    -webkit-mask-size: contain;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

body.single-product:not(.elementor-editor-active) .cts-product-gallery__main:hover::after {
    opacity: 1;
}

/* ============================================================
   PREVENIR SCROLL DEL BODY cuando el lightbox está abierto
   ============================================================ */
body.cts-lightbox-active {
    overflow: hidden;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    .cts-lightbox__prev { left: 0.5rem; }
    .cts-lightbox__next { right: 0.5rem; }
    .cts-lightbox__close { top: 0.5rem; right: 0.5rem; }
    .cts-lightbox__btn  { width: 40px; height: 40px; }
    .cts-lightbox__close { width: 40px; height: 40px; }
}
