/* ================================
   GALERÍA TIPO SLIDER - ESTILO GRALUSA
   ================================ */

/* Sección principal */
.gallery {
    padding: 100px 0;
    background-color: #f8f9fa;
}

.gallery .section-title {
    margin-bottom: 40px;
    text-align: center;
}

/* Contenedor principal de la galería */
.gallery-main-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* ================================
   IMAGEN PRINCIPAL
   ================================ */

.gallery-main-viewer {
    position: relative;
    width: 100%;
    background: #000;
}

.gallery-main-image {
    position: relative;
    width: 100%;
    height: 600px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s ease;
}

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

.gallery-main-image:hover .gallery-nav-btn {
    opacity: 1;
}

.gallery-prev {
    left: 20px;
}

.gallery-next {
    right: 20px;
}

.gallery-nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

/* Botón fullscreen */
.gallery-fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    z-index: 10;
    opacity: 0;
}

.gallery-main-image:hover .gallery-fullscreen-btn {
    opacity: 1;
}

.gallery-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Título de la imagen */
.gallery-image-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 40px 30px 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-main-image:hover .gallery-image-title {
    transform: translateY(0);
}

.gallery-image-title h4 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

/* ================================
   THUMBNAILS
   ================================ */

.gallery-thumbnails-container {
    position: relative;
    background: white;
    padding: 20px 0;
    border-top: 1px solid #eee;
}

.gallery-thumbnails {
    display: flex;
    gap: 10px;
    padding: 0 60px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.gallery-thumbnails::-webkit-scrollbar {
    display: none;
}

.gallery-thumbnail {
    flex: 0 0 auto;
    width: 120px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
}

.gallery-thumbnail:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.gallery-thumbnail.active {
    border-color: #e0c88c;
    box-shadow: 0 0 0 1px #e0c88c;
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-thumbnail:hover img {
    transform: scale(1.05);
}

/* Navegación de thumbnails */
.thumbnail-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(224, 200, 140, 0.9);
    border: none;
    color: #3a3a3a;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    z-index: 5;
}

.thumbnail-nav-left {
    left: 10px;
}

.thumbnail-nav-right {
    right: 10px;
}

.thumbnail-nav:hover {
    background: #e0c88c;
    transform: translateY(-50%) scale(1.1);
}

.thumbnail-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(-50%);
}

/* ================================
   MODAL FULLSCREEN
   ================================ */

.gallery-fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.gallery-fullscreen-modal.active {
    display: flex;
}

.fullscreen-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.fullscreen-content {
    position: relative;
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 10;
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fullscreen-image-container {
    position: relative;
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.fullscreen-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.fullscreen-prev {
    left: 30px;
}

.fullscreen-next {
    right: 30px;
}

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

.fullscreen-info {
    margin-top: 20px;
    text-align: center;
    color: white;
}

.fullscreen-info h3 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.fullscreen-counter {
    font-size: 1.1rem;
    opacity: 0.8;
}

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

.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    background: #f8f9fa;
    border-radius: 12px;
    flex-direction: column;
    gap: 20px;
}

.gallery-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #e0c88c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.gallery-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 12px;
    flex-direction: column;
    gap: 20px;
    text-align: center;
    padding: 40px;
}

.gallery-error .error-icon {
    font-size: 3rem;
    color: #e17055;
}

.gallery-error h3 {
    color: #333;
    margin: 0;
}

.gallery-error p {
    color: #666;
    margin: 0;
}

.retry-btn {
    background: #e0c88c;
    color: #3a3a3a;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #d4bc80;
    transform: translateY(-2px);
}

/* ================================
   ANIMACIONES
   ================================ */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* Tablets */
@media (max-width: 768px) {
    .gallery {
        padding: 80px 0;
    }
    
    .gallery-main-image {
        height: 400px;
    }
    
    .gallery-nav-btn,
    .gallery-fullscreen-btn {
        opacity: 1;
    }
    
    .gallery-nav-btn {
        width: 40px;
        height: 40px;
    }
    
    .gallery-prev {
        left: 10px;
    }
    
    .gallery-next {
        right: 10px;
    }
    
    .gallery-fullscreen-btn {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
    }
    
    .gallery-image-title {
        padding: 30px 20px 15px;
        transform: translateY(0);
        background: rgba(0, 0, 0, 0.7);
    }
    
    .gallery-image-title h4 {
        font-size: 1.1rem;
    }
    
    .gallery-thumbnails {
        padding: 0 50px;
    }
    
    .gallery-thumbnail {
        width: 100px;
        height: 70px;
    }
    
    .thumbnail-nav {
        width: 35px;
        height: 35px;
    }
    
    .fullscreen-nav {
        width: 50px;
        height: 50px;
    }
    
    .fullscreen-prev {
        left: 15px;
    }
    
    .fullscreen-next {
        right: 15px;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .gallery-main-image {
        height: 300px;
    }
    
    .gallery-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .gallery-thumbnails {
        padding: 0 40px;
    }
    
    .gallery-thumbnail {
        width: 80px;
        height: 60px;
    }
    
    .gallery-image-title h4 {
        font-size: 1rem;
    }
    
    .fullscreen-content {
        width: 95%;
        height: 95%;
    }
    
    .fullscreen-nav {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .fullscreen-info h3 {
        font-size: 1.2rem;
    }
    
    .fullscreen-counter {
        font-size: 1rem;
    }
}

/* ================================
   UTILIDADES
   ================================ */

/* Prevenir scroll del body cuando modal está abierto */
body.fullscreen-open {
    overflow: hidden;
}

/* Mejoras de accesibilidad */
.gallery-nav-btn:focus,
.gallery-fullscreen-btn:focus,
.thumbnail-nav:focus,
.fullscreen-close:focus,
.fullscreen-nav:focus {
    outline: 2px solid #e0c88c;
    outline-offset: 2px;
}

/* Optimización para dispositivos táctiles */
@media (hover: none) {
    .gallery-nav-btn,
    .gallery-fullscreen-btn {
        opacity: 1;
    }
    
    .gallery-image-title {
        transform: translateY(0);
        background: rgba(0, 0, 0, 0.6);
    }
    
    .gallery-thumbnail:hover {
        transform: none;
    }
    
    .gallery-thumbnail:hover img {
        transform: none;
    }
}

/* ================================
   PLACEHOLDERS Y LOADING STATES
   ================================ */

   .thumbnail-placeholder {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.main-image-placeholder {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.thumbnail-number {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #666;
}

.loading-indicator span {
    font-size: 1.1rem;
    font-weight: 500;
}

/* ================================
   SHIMMER LOADING ANIMATION
   ================================ */

.loading-shimmer {
    position: relative;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    width: 100%;
    height: 100%;
}

.loading-shimmer.large {
    width: 300px;
    height: 200px;
    border-radius: 12px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ================================
   ANIMACIONES MEJORADAS
   ================================ */

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

.gallery-thumbnail {
    transition: all 0.3s ease, transform 0.2s ease;
}

.gallery-thumbnail:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.main-gallery-img {
    transition: opacity 0.3s ease-in-out;
}

/* ================================
   ESTADOS DE ERROR MEJORADOS
   ================================ */

.image-error-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #fff3cd;
    border: 2px dashed #ffeaa7;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    color: #856404;
}

.image-error-placeholder .error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.7;
}

.image-error-placeholder p {
    margin: 10px 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.retry-btn.small {
    padding: 8px 16px;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* ================================
   OPTIMIZACIONES DE RENDIMIENTO
   ================================ */

.gallery-thumbnail,
.gallery-main-image img {
    will-change: transform;
}

.gallery-thumbnails {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Optimizar reflows durante scroll */
.gallery-thumbnail img {
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* ================================
   MEJORAS RESPONSIVE
   ================================ */

@media (max-width: 768px) {
    .loading-shimmer.large {
        width: 250px;
        height: 150px;
    }
    
    .thumbnail-number {
        font-size: 0.6rem;
        padding: 1px 4px;
    }
    
    .main-image-placeholder {
        padding: 20px;
    }
    
    .loading-indicator span {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .loading-shimmer.large {
        width: 200px;
        height: 120px;
    }
    
    .image-error-placeholder {
        padding: 20px;
    }
    
    .image-error-placeholder .error-icon {
        font-size: 2rem;
    }
    
    .image-error-placeholder p {
        font-size: 1rem;
    }
}

/* ================================
   ESTADOS ESPECÍFICOS
   ================================ */

.gallery-thumbnail.loading .thumbnail-placeholder {
    background: #e9ecef;
}

.gallery-thumbnail.error {
    opacity: 0.6;
    filter: grayscale(50%);
}

.gallery-thumbnail.loaded {
    animation: thumbnailLoaded 0.5s ease-out;
}

@keyframes thumbnailLoaded {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ================================
   OPTIMIZACIONES ADICIONALES
   ================================ */

/* Preload hint para mejor rendimiento */
.gallery-main-image img[loading="lazy"] {
    loading: eager;
}

/* Mejoras para conexiones lentas */
@media (prefers-reduced-motion: reduce) {
    .loading-shimmer {
        animation: none;
        background: #f0f0f0;
    }
    
    .fade-in,
    .thumbnailLoaded {
        animation: none;
    }
    
    .gallery-thumbnail:hover {
        transform: none;
    }
}

/* Soporte para dark mode */
@media (prefers-color-scheme: dark) {
    .thumbnail-placeholder {
        background: #2a2a2a;
    }
    
    .main-image-placeholder {
        background: #1a1a1a;
        color: #e0e0e0;
    }
    
    .loading-shimmer {
        background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    }
    
    .image-error-placeholder {
        background: #3a2a1a;
        border-color: #5a4a2a;
        color: #e0d0a0;
    }
}