/* ============================================
   GALERÍA CON CARRUSEL AUTOMÁTICO Y OVERLAY
   ============================================ */

/* Contenedor principal */
.galeria-container {
    padding: 25px;
    margin-top: 30px;
    margin-bottom: 30px;
}

.galeria-container h3 {
    color: #333;
    font-weight: 600;
    margin-bottom: 25px;
    text-align: center;
}

/* Carrusel automático */
.galeria-carrusel {
    position: relative;
    overflow: hidden;
    padding: 10px 0;
}

.galeria-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    gap: 15px;
    will-change: transform;
}

.galeria-slide {
    flex: 0 0 auto;
    width: 180px;
}

.galeria-miniatura {
    width: 180px;
    height: 120px;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
}

.galeria-miniatura:hover {
    transform: scale(1.08);
    z-index: 2;
}

/* Botones de navegación del carrusel */
.galeria-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.8;
}

.galeria-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.galeria-btn-prev {
    left: 15px;
}

.galeria-btn-next {
    right: 15px;
}

/* Botón de pausa/play */
.galeria-play-pause {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.galeria-play-pause:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Texto informativo */
.galeria-info {
    text-align: center;
    margin-top: 15px;
    color: #6c757d;
    font-size: 0.9rem;
}

/* ============================================
   OVERLAY PARA IMAGENES AMPLIADAS
   ============================================ */

.galeria-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.97);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}

.galeria-overlay.activo {
    display: flex;
    opacity: 1;
}

.overlay-contenido {
    max-width: 90%;
    max-height: 90%;
    position: relative;
    text-align: center;
    animation: fadeInScale 0.3s ease-out;
}

.overlay-imagen {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 10px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.7);
    display: block;
    margin: 0 auto;
}

.overlay-cerrar {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    background: none;
    border: none;
    transition: all 0.3s ease;
    z-index: 10000;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-cerrar:hover {
    transform: rotate(90deg);
    color: #ff6b6b;
}

.overlay-contador {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 1.2rem;
    background: rgba(0,0,0,0.7);
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 500;
}

/* Botones de navegación en overlay */
.overlay-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 10000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.overlay-nav:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.overlay-nav-prev {
    left: 30px;
}

.overlay-nav-next {
    right: 30px;
}

/* Estados del body */
body.overlay-abierto {
    overflow: hidden;
    padding-right: 15px; /* Compensar scrollbar */
}

/* Animaciones */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.galeria-slide {
    animation: slideIn 0.5s ease-out;
}

/* ============================================
   ESTILOS RESPONSIVE
   ============================================ */

@media (max-width: 992px) {
    .galeria-slide {
        width: 160px;
    }
    
    .galeria-miniatura {
        width: 160px;
        height: 110px;
    }
    
    .overlay-nav {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .overlay-nav-prev {
        left: 15px;
    }
    
    .overlay-nav-next {
        right: 15px;
    }
}

@media (max-width: 768px) {
    .galeria-container {
        padding: 20px 15px;
        margin-top: 20px;
    }
    
    .galeria-slide {
        width: 140px;
    }
    
    .galeria-miniatura {
        width: 140px;
        height: 95px;
    }
    
    .galeria-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .galeria-play-pause {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .overlay-contenido {
        max-width: 95%;
    }
    
    .overlay-cerrar {
        top: 10px;
        right: 10px;
        font-size: 2rem;
        width: 40px;
        height: 40px;
    }
    
    .overlay-contador {
        font-size: 1rem;
        padding: 6px 15px;
        bottom: 15px;
    }
    
    .overlay-nav {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

@media (max-width: 576px) {
    .galeria-slide {
        width: 120px;
    }
    
    .galeria-miniatura {
        width: 120px;
        height: 85px;
    }
    
    .galeria-track {
        gap: 10px;
    }
    
    .overlay-nav {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .overlay-nav-prev {
        left: 10px;
    }
    
    .overlay-nav-next {
        right: 10px;
    }
}

/* ============================================
   ESTADOS DE CARGA
   ============================================ */

.galeria-miniatura.cargando {
    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; }
}

.overlay-imagen.cargando {
    min-height: 300px;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 10px;
}

/* ============================================
   EFECTOS ESPECIALES
   ============================================ */

.galeria-miniatura::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px;
    background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.3) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.galeria-miniatura:hover::after {
    opacity: 1;
}

.overlay-imagen {
    transition: transform 0.3s ease;
}

.overlay-imagen.zoom {
    transform: scale(1.05);
}

/* ============================================
   COMPATIBILIDAD Y RESET
   ============================================ */

.galeria-container * {
    box-sizing: border-box;
}

.galeria-container img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* Asegurar que los botones sean accesibles */
.galeria-btn:focus,
.galeria-play-pause:focus,
.overlay-cerrar:focus,
.overlay-nav:focus {
    outline: 2px solid #4d90fe;
    outline-offset: 2px;
}

/* Mejorar contraste para accesibilidad */
.galeria-info {
    color: #5a6268;
}

.overlay-contador {
    background: rgba(0, 0, 0, 0.85);
}
