/* ============================================================
   WC Product Gallery Widget — gallery.css
   Compatible con temas Storefront, Astra, OceanWP, Hello, etc.
   ============================================================ */

/* ── Variables internas ──────────────────────────────────── */
.wcgw-gallery {
    --wcgw-thumb-size:     72px;
    --wcgw-thumb-gap:      8px;
    --wcgw-gap:            16px;
    --wcgw-radius:         8px;
    --wcgw-radius-lg:      12px;
    --wcgw-border:         1px solid #e0e0e0;
    --wcgw-active-color:   #2271b1;
    --wcgw-trans:          0.22s ease;
    --wcgw-nav-bg:         rgba(255,255,255,0.88);
    --wcgw-dot-size:       7px;
}

/* ── Wrappers de layout ─────────────────────────────────── */
.wcgw-gallery {
    display: flex;
    gap: var(--wcgw-gap);
    position: relative;
    width: 100%;
}

/* Miniaturas a la izquierda (default) */
.wcgw-gallery--left  { flex-direction: row; }

/* Miniaturas a la derecha */
.wcgw-gallery--right { flex-direction: row-reverse; }

/* Miniaturas abajo */
.wcgw-gallery--bottom {
    flex-direction: column;
}

/* ── Imagen principal ───────────────────────────────────── */
.wcgw-main {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wcgw-main-image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
    overflow: hidden;
    border-radius: var(--wcgw-radius-lg);
    background: #f5f5f5;
    cursor: default;
}

/* Soporte para zoom: muestra crosshair y agranda la imagen */
.wcgw-zoom-enabled .wcgw-main-image-wrap {
    cursor: zoom-in;
}

.wcgw-zoom-enabled .wcgw-main-image-wrap:hover img.wcgw-main-image--active {
    transform: scale(1.06);
}

/* Imágenes dentro del wrap — todas apiladas */
.wcgw-main-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity var(--wcgw-trans),
                transform 0.35s ease;
    border-radius: inherit;
    will-change: opacity;
}

.wcgw-main-image--active {
    opacity: 1;
    position: relative; /* ocupa espacio en el flujo */
}

/* ── Badge de oferta ────────────────────────────────────── */
.wcgw-sale-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: #e2001a;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    pointer-events: none;
}

/* ── Botón de lightbox ──────────────────────────────────── */
.wcgw-lightbox-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--wcgw-nav-bg);
    border: 0.5px solid #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: background var(--wcgw-trans), color var(--wcgw-trans);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.wcgw-lightbox-btn:hover {
    background: #fff;
    color: #111;
}

/* ── Flechas de navegación ──────────────────────────────── */
.wcgw-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wcgw-nav-bg);
    border: 0.5px solid #ccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    opacity: 0;
    transition: opacity var(--wcgw-trans), background var(--wcgw-trans);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.wcgw-main-image-wrap:hover .wcgw-nav,
.wcgw-main-image-wrap:focus-within .wcgw-nav {
    opacity: 1;
}

.wcgw-nav--prev { left: 10px; }
.wcgw-nav--next { right: 10px; }

.wcgw-nav:hover {
    background: #fff;
    color: #000;
}

.wcgw-nav:focus-visible {
    outline: 2px solid var(--wcgw-active-color);
    outline-offset: 2px;
}

/* ── Dots de paginación ─────────────────────────────────── */
.wcgw-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 2px 0;
}

.wcgw-dot {
    width: var(--wcgw-dot-size);
    height: var(--wcgw-dot-size);
    border-radius: 50%;
    border: none;
    background: #ccc;
    cursor: pointer;
    padding: 0;
    transition: background var(--wcgw-trans), transform var(--wcgw-trans);
}

.wcgw-dot--active {
    background: var(--wcgw-active-color);
    transform: scale(1.4);
}

.wcgw-dot:focus-visible {
    outline: 2px solid var(--wcgw-active-color);
    outline-offset: 2px;
}

/* ── Tira de miniaturas ─────────────────────────────────── */
.wcgw-thumbs {
    display: flex;
    gap: var(--wcgw-thumb-gap);
    flex-shrink: 0;
}

/* Columna (lateral izq / der) */
.wcgw-gallery--left .wcgw-thumbs,
.wcgw-gallery--right .wcgw-thumbs {
    flex-direction: column;
    width: var(--wcgw-thumb-size);
    align-items: stretch;
    overflow-y: auto;
    max-height: 100%;
    /* Ocultar scrollbar pero permitir scroll */
    scrollbar-width: none;
}

.wcgw-gallery--left .wcgw-thumbs::-webkit-scrollbar,
.wcgw-gallery--right .wcgw-thumbs::-webkit-scrollbar {
    display: none;
}

/* Fila (abajo) */
.wcgw-gallery--bottom .wcgw-thumbs {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
}

.wcgw-gallery--bottom .wcgw-thumbs::-webkit-scrollbar {
    display: none;
}

/* Cada miniatura */
.wcgw-thumb {
    flex-shrink: 0;
    width: var(--wcgw-thumb-size);
    height: var(--wcgw-thumb-size);
    border-radius: var(--wcgw-radius);
    overflow: hidden;
    cursor: pointer;
    border: 1.5px solid #e0e0e0;
    background: #f5f5f5;
    opacity: 0.65;
    padding: 0;
    transition: border-color var(--wcgw-trans),
                opacity var(--wcgw-trans),
                transform var(--wcgw-trans);
}

.wcgw-thumb:hover {
    opacity: 0.9;
    border-color: #aaa;
    transform: translateY(-1px);
}

.wcgw-thumb--active {
    border-color: var(--wcgw-active-color);
    opacity: 1;
}

.wcgw-thumb:focus-visible {
    outline: 2px solid var(--wcgw-active-color);
    outline-offset: 2px;
}

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

/* ── Lightbox ───────────────────────────────────────────── */
.wcgw-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: wcgw-lb-in 0.2s ease;
}

.wcgw-lightbox[hidden] {
    display: none !important;
}

@keyframes wcgw-lb-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

.wcgw-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    transition: opacity 0.15s ease;
}

.wcgw-lightbox__close,
.wcgw-lightbox__prev,
.wcgw-lightbox__next {
    position: absolute;
    background: rgba(255,255,255,0.12);
    border: 0.5px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.wcgw-lightbox__close:hover,
.wcgw-lightbox__prev:hover,
.wcgw-lightbox__next:hover {
    background: rgba(255,255,255,0.25);
}

.wcgw-lightbox__close { top: 16px; right: 16px; width: 40px; height: 40px; }
.wcgw-lightbox__prev  { left: 16px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.wcgw-lightbox__next  { right: 16px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }

/* ── Placeholder del editor ─────────────────────────────── */
.wcgw-editor-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 200px;
    border: 2px dashed #ccc;
    border-radius: var(--wcgw-radius-lg);
    color: #888;
    background: #fafafa;
    padding: 24px;
    text-align: center;
}

.wcgw-editor-placeholder p {
    font-size: 15px;
    font-weight: 500;
    margin: 0;
}

.wcgw-editor-placeholder small {
    font-size: 13px;
    color: #aaa;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
    .wcgw-gallery--left,
    .wcgw-gallery--right {
        flex-direction: column !important;
    }

    .wcgw-gallery--left .wcgw-thumbs,
    .wcgw-gallery--right .wcgw-thumbs {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        max-height: none;
    }
}

/* ── Soporte @prefers-reduced-motion ────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .wcgw-main-image,
    .wcgw-thumb,
    .wcgw-nav,
    .wcgw-dot,
    .wcgw-lightbox {
        transition: none;
        animation: none;
    }
}
