/**
 * Product Preview WooCarrousel - Estilos principales
 * Optimizado para rendimiento y compatibilidad
 */

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */

.ppw-gallery-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ppw-gallery-container *,
.ppw-gallery-container *::before,
.ppw-gallery-container *::after {
    box-sizing: border-box;
}

/* Sticky */
.ppw-gallery-container.ppw-sticky {
    position: sticky;
    top: var(--ppw-sticky-offset, 20px);
    z-index: 10;
}

/* ============================================
   IMAGEN PRINCIPAL
   ============================================ */

.ppw-main-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
}

.ppw-main-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
    object-fit: contain;
}

.ppw-main-image:hover img {
    transform: scale(1.02);
}

/* Ícono de zoom */
.ppw-zoom-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ppw-zoom-icon svg {
    width: 20px;
    height: 20px;
    color: #333;
}

.ppw-main-image:hover .ppw-zoom-icon {
    opacity: 1;
    transform: scale(1.1);
}

/* ============================================
   MINIATURAS
   ============================================ */

.ppw-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.ppw-thumbnail-item {
    width: 80px;
    height: 80px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    background: #f5f5f5;
    transition: transform 0.2s ease;
}

.ppw-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease, border-color 0.3s ease;
    opacity: 0.7;
}

.ppw-thumbnail-item:hover img,
.ppw-thumbnail-item.active img {
    opacity: 1;
}

.ppw-thumbnail-item:hover {
    transform: translateY(-2px);
}

.ppw-thumbnail-item.active {
    transform: none;
}

/* ============================================
   POSICIONES DE MINIATURAS
   ============================================ */

/* Abajo (default) */
.ppw-position-bottom {
    display: flex;
    flex-direction: column;
}

.ppw-position-bottom .ppw-thumbnails {
    margin-top: 15px;
    margin-bottom: 0;
}

/* Arriba */
.ppw-position-top {
    display: flex;
    flex-direction: column;
}

.ppw-position-top .ppw-thumbnails {
    order: -1;
    margin-top: 0;
    margin-bottom: 15px;
}

/* Izquierda */
.ppw-position-left {
    display: flex;
    flex-direction: row;
}

.ppw-position-left .ppw-main-image {
    flex: 1;
    order: 1;
}

.ppw-position-left .ppw-thumbnails {
    flex-direction: column;
    width: auto;
    margin-top: 0;
    margin-right: 15px;
    order: 0;
}

.ppw-position-left .ppw-thumbnail-item {
    width: 70px;
    height: 70px;
}

/* Derecha */
.ppw-position-right {
    display: flex;
    flex-direction: row;
}

.ppw-position-right .ppw-main-image {
    flex: 1;
}

.ppw-position-right .ppw-thumbnails {
    flex-direction: column;
    width: auto;
    margin-top: 0;
    margin-left: 15px;
}

.ppw-position-right .ppw-thumbnail-item {
    width: 70px;
    height: 70px;
}

/* ============================================
   ESTILOS DE GALERÍA
   ============================================ */

/* Estilo 1: Clásico */
.ppw-style-style-1 .ppw-main-image {
    border-radius: 4px;
}

.ppw-style-style-1 .ppw-thumbnail-item {
    border-radius: 4px;
}

/* Estilo 2: Moderno Grid */
.ppw-style-style-2 .ppw-main-image {
    border-radius: 12px;
}

.ppw-style-style-2 .ppw-thumbnail-item {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ppw-style-style-2 .ppw-thumbnail-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.ppw-style-style-2 .ppw-thumbnail-item.active {
    box-shadow: 0 0 0 2px #007bff;
}

/* ============================================
   LIGHTBOX
   ============================================ */

.ppw-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--ppw-lightbox-bg, rgba(0, 0, 0, 0.95));
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ppw-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.ppw-lightbox-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 90vw;
    max-height: 75vh;
    padding: 20px;
}

.ppw-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ppw-lightbox.active .ppw-lightbox-image {
    opacity: 1;
    transform: scale(1);
}

/* Botón cerrar */
.ppw-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.ppw-lightbox-close svg {
    color: var(--ppw-lightbox-close-color, #fff);
    width: 28px;
    height: 28px;
}

.ppw-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Navegación */
.ppw-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease, transform 0.3s ease;
    z-index: 10;
}

.ppw-lightbox-nav svg {
    color: var(--ppw-lightbox-nav-color, #fff);
    width: 32px;
    height: 32px;
}

.ppw-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ppw-lightbox-prev {
    left: 20px;
}

.ppw-lightbox-prev:hover {
    transform: translateY(-50%) translateX(-3px);
}

.ppw-lightbox-next {
    right: 20px;
}

.ppw-lightbox-next:hover {
    transform: translateY(-50%) translateX(3px);
}

/* Contador */
.ppw-lightbox-counter {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 20px;
}

/* Miniaturas del lightbox */
.ppw-lightbox-thumbnails {
    display: flex;
    gap: 10px;
    padding: 20px;
    max-width: 90vw;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.ppw-lightbox-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.ppw-lightbox-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.ppw-lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.ppw-lightbox-thumb {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.5;
    border: 2px solid transparent;
    transition: opacity 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

.ppw-lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ppw-lightbox-thumb:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.ppw-lightbox-thumb.active {
    opacity: 1;
    border-color: #fff;
}

/* ============================================
   MENSAJES
   ============================================ */

.ppw-no-product,
.ppw-no-images {
    padding: 40px;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    color: #6c757d;
    font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    /* En móviles, posición lateral se convierte en vertical */
    .ppw-position-left,
    .ppw-position-right {
        flex-direction: column;
    }

    .ppw-position-left .ppw-thumbnails,
    .ppw-position-right .ppw-thumbnails {
        flex-direction: row;
        width: 100%;
        margin: 15px 0 0 0;
    }

    .ppw-position-left .ppw-main-image,
    .ppw-position-right .ppw-main-image {
        order: 0;
    }

    .ppw-position-left .ppw-thumbnail-item,
    .ppw-position-right .ppw-thumbnail-item {
        width: 60px;
        height: 60px;
    }

    /* Lightbox responsive */
    .ppw-lightbox-nav {
        width: 45px;
        height: 45px;
    }

    .ppw-lightbox-nav svg {
        width: 24px;
        height: 24px;
    }

    .ppw-lightbox-prev {
        left: 10px;
    }

    .ppw-lightbox-next {
        right: 10px;
    }

    .ppw-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .ppw-lightbox-close svg {
        width: 22px;
        height: 22px;
    }

    .ppw-lightbox-counter {
        top: 15px;
        font-size: 14px;
        padding: 6px 15px;
    }

    .ppw-lightbox-thumbnails {
        padding: 15px;
        gap: 8px;
    }

    .ppw-lightbox-thumb {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .ppw-thumbnail-item {
        width: 50px !important;
        height: 50px !important;
    }

    .ppw-thumbnails {
        gap: 6px;
    }

    .ppw-lightbox-content {
        padding: 10px;
    }
}

/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes ppw-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes ppw-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ppw-gallery-container {
    animation: ppw-fade-in 0.4s ease;
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

.ppw-thumbnail-item:focus,
.ppw-lightbox-close:focus,
.ppw-lightbox-nav:focus,
.ppw-lightbox-thumb:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Modo de alto contraste */
@media (prefers-contrast: high) {
    .ppw-thumbnail-item {
        border: 2px solid #000;
    }

    .ppw-thumbnail-item.active {
        border-color: #007bff;
    }

    .ppw-lightbox-close,
    .ppw-lightbox-nav {
        border: 2px solid #fff;
    }
}

/* Reducir movimiento */
@media (prefers-reduced-motion: reduce) {
    .ppw-main-image img,
    .ppw-thumbnail-item,
    .ppw-lightbox,
    .ppw-lightbox-image,
    .ppw-lightbox-close,
    .ppw-lightbox-nav,
    .ppw-lightbox-thumb,
    .ppw-zoom-icon {
        transition: none;
    }

    .ppw-gallery-container {
        animation: none;
    }

    .ppw-main-image:hover img {
        transform: none;
    }
}
