/* Estilos para Galería PODS */
.galeria-pods-container {
    width: 100%;
    position: relative;
    isolation: isolate; /* crea un nuevo contexto de apilamiento */
}

/* Aislar estilos de botones dentro del contenedor para evitar overrides del tema */
.galeria-pods-container button {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    appearance: none !important;
    font: inherit;
    color: inherit;
    line-height: normal;
}

/* Forzar estilos de los controles de la galería */
.galeria-pods-container .slider-btn,
.galeria-pods-container .zoom-btn,
.galeria-pods-container .lightbox-nav,
.galeria-pods-container .lightbox-close {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #ddd !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    border-radius: 50% !important;
}

/* Ajustes particulares para lightbox buttons */
.galeria-pods-container .lightbox-nav,
.galeria-pods-container .lightbox-close {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

/* Asegurar que los íconos SVG no hereden rellenos del tema */
.galeria-pods-container .slider-btn svg,
.galeria-pods-container .zoom-btn svg {
    fill: none !important;
    stroke: currentColor !important;
}

.galeria-pods-container .lightbox-nav svg,
.galeria-pods-container .lightbox-close svg {
    fill: none !important;
    stroke: currentColor !important;
}

/* Layout de dos columnas */
.product-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 40px;
    align-items: start;
}

/* Galería de producto */
.product-gallery {
    display: block;
    position: sticky;
    top: 20px;
}

/* Contenedor de imagen principal */
.main-image-container {
    width: 100%;
    position: relative;
    margin-bottom: 15px;
}

.main-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* Ratio 1:1 moderno */
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
}

.main-image-wrapper img {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    opacity: 1;
}

@supports not (aspect-ratio: 1 / 1) {
    .main-image-wrapper {
        padding-bottom: 100%;
    }
    .main-image-wrapper img {
        position: absolute;
        top: 0;
        left: 0;
    }
}

.main-image-wrapper img.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.main-image-wrapper img.fade-in {
    animation: fadeInImage 0.4s ease forwards;
}

@keyframes fadeInImage {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.main-image-wrapper:hover img {
    transform: scale(1.05);
}

/* Botones de control deslizante */
.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.slider-btn:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.slider-btn.prev {
    left: 15px;
}

.slider-btn.next {
    right: 15px;
}

.slider-btn svg {
    color: #333;
}

/* Botón de zoom */
.zoom-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ddd;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.zoom-btn:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.zoom-btn svg {
    color: #333;
}

/* Contenedor de miniaturas */
.thumbnails-container {
    width: 100%;
}

.thumbnails-wrapper {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* Ratio 1:1 */
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.thumbnail:hover {
    border-color: #999;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.thumbnail.active {
    border-color: #4a90e2;
    box-shadow: 0 0 0 1px #4a90e2;
}

.thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Contenido del producto */
.product-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.lightbox.active {
    display: block;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.lightbox-content img {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Botón cerrar lightbox */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10001;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

.lightbox-close svg {
    color: #ffffff;
}

/* Caption del lightbox */
.lightbox-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 25px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    text-align: center;
}

.lightbox-caption h3 {
    font-size: 1.5rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Navegación del lightbox */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav.prev {
    left: 30px;
}

.lightbox-nav.next {
    right: 30px;
}

.lightbox-nav svg {
    color: #ffffff;
}

/* Barra de progreso del autoplay */
.lightbox-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.8);
    width: 0%;
    animation: none;
    z-index: 10002;
}

.lightbox-progress-bar.active {
    animation: progressBar var(--autoplay-duration, 5s) linear forwards;
}

@keyframes progressBar {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}



/* Tooltip de instrucciones */
.gallery-hint {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    animation: fadeInOut 4s ease-in-out forwards;
    z-index: 5;
}

@keyframes fadeInOut {
    0%, 10% { opacity: 0; }
    20%, 80% { opacity: 1; }
    90%, 100% { opacity: 0; }
}

/* Feedback de swipe */
.main-image-wrapper.swipe-left,
.main-image-wrapper.swipe-right {
    animation: swipeFeedback 0.3s ease;
}

@keyframes swipeFeedback {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.98); }
}

/* Tira de miniaturas en lightbox */
.lightbox-thumbnails-strip {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    height: 80px;
    background: rgba(0, 0, 0, 0.5);
    overflow-x: auto;
    display: flex;
    gap: 8px;
    padding: 8px;
    overflow-y: hidden;
    z-index: 10002;
}

.lightbox-thumbnails-strip::-webkit-scrollbar {
    height: 4px;
}

.lightbox-thumbnails-strip::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.lightbox-thumbnails-strip::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.lightbox-thumb {
    flex: 0 0 70px;
    width: 70px;
    height: 70px;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.3);
}

.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-thumb:hover {
    opacity: 1;
    border-color: rgba(255, 255, 255, 0.5);
}

.lightbox-thumb.active {
    border-color: #4a90e2;
    opacity: 1;
}

/* Lazy loading placeholder */
.lazy-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .product-layout {
        grid-template-columns: 350px 1fr;
        gap: 30px;
    }
}

@media (max-width: 900px) {
    .product-layout {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .product-gallery {
        position: static !important; /* desactiva sticky en móvil */
        top: auto !important;
        z-index: 0 !important;
        margin-bottom: 16px;
    }
}

@media (max-width: 767px) {
    .product-layout {
        gap: 20px;
    }
    
    /* asegurar que los controles no sobresalgan fuera del wrapper */
    .main-image-wrapper {
        overflow: hidden !important;
    }
    
    .slider-btn {
        width: 35px;
        height: 35px;
    }
    
    .slider-btn.prev {
        left: 10px;
    }
    
    .slider-btn.next {
        right: 10px;
    }
    
    .zoom-btn {
        width: 35px;
        height: 35px;
        top: 10px;
        right: 10px;
    }
    
    .thumbnails-wrapper {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    .lightbox-nav,
    .lightbox-close {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-nav.prev {
        left: 15px;
    }
    
    .lightbox-nav.next {
        right: 15px;
    }
    
    .lightbox-caption h3 {
        font-size: 1.2rem;
    }
    
    .lightbox-counter {
        font-size: 0.9rem;
        padding: 6px 15px;
    }
}

@media (max-width: 480px) {
    .thumbnails-wrapper {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .lightbox-content img {
        max-width: 95%;
        max-height: 75%;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.lightbox.active {
    animation: fadeIn 0.3s ease;
}
