/* ============================================================
   SECCIÓN GALERÍA M50 ULTRA
   ============================================================ */

.m50-gallery {
    padding: 60px 0;
    background: #2a2d34;
}

/* Panel izquierdo: Imagen Grande */
.main-image {
    height: 75vh;
    background: #3c3f49;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 20px;
}

.main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Mantiene la proporción sin deformar */
    transition: opacity 0.4s ease-in-out;
}

/* Carrusel lateral de miniaturas */
.thumbs-carousel {
    display: grid;
    /* Forzamos 3 columnas exactas para que no salte al redimensionar */
    grid-template-columns: repeat(3, 1fr); 
    grid-auto-rows: 100px;
    gap: 12px;
    max-height: 75vh;
    overflow-y: auto;
    padding: 10px; /* Espacio para que el efecto scale no se corte */
    scrollbar-width: thin;
    scrollbar-color: #D32F2F #f0f0f0;
}

/* Estilo de la miniatura individual */
.thumb {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    background: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s ease, 
                border-color 0.3s ease;
    z-index: 1;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Recorta la miniatura para que todas sean iguales */
    display: block;
}

/* EFECTO HOVER: Sin mover a los vecinos */
.thumb:hover {
    transform: scale(1.05); /* Escala pequeña para no romper el grid */
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    z-index: 10; /* Se superpone a las demás */
    border-color: rgba(211, 47, 47, 0.5);
}

/* Estado Activo (Imagen seleccionada) */
.thumb.active {
    border-color: #D32F2F;
    box-shadow: 0 0 12px rgba(211, 47, 47, 0.3);
}

/* Estilo del Scrollbar (Chrome/Edge/Safari) */
.thumbs-carousel::-webkit-scrollbar {
    width: 6px;
}
.thumbs-carousel::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.thumbs-carousel::-webkit-scrollbar-thumb {
    background: #D32F2F;
    border-radius: 10px;
}

/* ============================================================
   RESPONSIVIDAD (CORREGIDA)
   ============================================================ */

/* Escritorio mediano / Tablets Horizontales */
@media (max-width: 1199px) {
    .thumbs-carousel {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 90px;
    }
}

/* Tablets Verticales */
@media (max-width: 991px) {
    .main-image {
        height: 50vh;
    }
    .thumbs-carousel {
        grid-template-columns: repeat(4, 1fr); /* Más espacio horizontal */
        max-height: 400px;
    }
}

/* Móviles */
@media (max-width: 576px) {
    .main-image {
        height: 40vh;
        padding: 10px;
    }
    .thumbs-carousel {
        grid-template-columns: repeat(3, 1fr); /* Volvemos a 3 para que no sean enanas */
        grid-auto-rows: 80px;
        gap: 8px;
    }
}