:root {
    /* COLORES CORPORATIVOS */
    --undesa-cyan: #29ABE2;
    --undesa-blue: #0071BC;
    
    /* NUEVA PALETA "VIVA" (En lugar de negros puros) */
    --undesa-dark-bg: #0f172a; /* Azul noche muy oscuro (Slate 900) */
    --undesa-panel: #1e293b;   /* Azul grisáceo para paneles */
    --text-grey: #cbd5e1;      /* Gris claro azulado para textos */
    
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

html, body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    /* EL CAMBIO CLAVE: Degradado sutil en vez de color sólido */
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    color: white;
    min-height: 100vh; /* Asegura que el degradado cubra todo */
}

/* HEADER: Sutil, para que destaque el logo */
header {
    background-color: rgba(15, 23, 42, 0.9) !important; /* Azul noche translúcido */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.logo-img {
    height: 50px; /* Ajusta según necesidad */
    width: auto;
}

/* =========================================
   SPINNER DE CARGA "UNDESA NEON"
   ========================================= */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* Ancho total del viewport */
    height: 100vh; /* Alto total del viewport */
    background-color: #000; /* Fondo negro sólido para cubrir todo */
    display: flex; /* FLEXBOX ES LA CLAVE PARA CENTRAR */
    justify-content: center; /* Centrado horizontal */
    align-items: center; /* Centrado vertical */
    flex-direction: column;
    z-index: 99999; /* Encima de todo */
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

/* Círculo Exterior (Azul Oscuro) */
.loader-ring {
    width: 80px;
    height: 80px;
    border: 4px solid transparent;
    border-top-color: var(--undesa-blue); /* Color Corporativo 1 */
    border-right-color: var(--undesa-blue);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
    position: relative;
}

/* Círculo Interior (Cyan Brillante) */
.loader-ring::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 4px solid transparent;
    border-top-color: var(--undesa-cyan); /* Color Corporativo 2 */
    border-left-color: var(--undesa-cyan);
    border-radius: 50%;
    animation: spin-reverse 1s linear infinite;
}

/* Texto de carga pulsante */
.loading-text {
    margin-top: 20px;
    color: white;
    font-family: var(--font-heading);
    letter-spacing: 3px;
    font-size: 0.9rem;
    animation: pulse 2s infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spin-reverse {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; text-shadow: 0 0 10px var(--undesa-cyan); }
    100% { opacity: 0.5; }
}

/* =========================================
   GALERÍA ACORDEÓN (MEJORADA)
   ========================================= */
main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.gallery-container {
    display: flex;
    width: 100%;
    height: 600px;
    max-width: 1400px;
    gap: 15px;
    padding: 0 20px;
}

.gallery-item {
    position: relative;
    flex: 1;
    border-radius: 15px;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    overflow: hidden;
    cursor: pointer;
    /* Filtro inicial: Blanco y negro + oscurecido para elegancia */
    filter: grayscale(100%) brightness(0.6);
    border: 1px solid #333;
}

/* --- ESTADO ACTIVO (HOVER) --- */
.gallery-item:hover {
    flex: 4; /* Expansión */
    filter: grayscale(0%) brightness(1); /* Color real */
    /* Borde brillante usando el Cyan de Undesa */
    border: 1px solid var(--undesa-cyan); 
    box-shadow: 0 0 25px rgba(41, 171, 226, 0.3); /* Resplandor sutil */
}

/* CONTENIDO INTERNO DE LA TARJETA */
.item-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    /* AQUÍ ESTÁ EL TRUCO: Degradado azulado en lugar de negro */
    /* Va de Azul Profundo casi opaco abajo -> a Transparente arriba */
    background: linear-gradient(to top, rgba(1, 23, 46, 0.95) 0%, rgba(1, 23, 46, 0.7) 50%, transparent 100%);
    padding: 40px 30px;
    color: white;
    transform: translateY(20px);
    transition: transform 0.4s ease;
    border-top: 1px solid rgba(41, 171, 226, 0.3); /* Línea sutil Cyan arriba del texto */
}

.gallery-item:hover .item-content {
    transform: translateY(0);
}

/* Íconos: Usamos el degradado del logo en el texto/icono (Efecto avanzado) */
.item-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    
    /* DEFINICIÓN DEL DEGRADADO */
    background: -webkit-linear-gradient(45deg, var(--undesa-blue), var(--undesa-cyan));
    
    /* REGLAS PARA RECORTAR EL FONDO A LA FORMA DEL TEXTO */
    -webkit-background-clip: text; /* Para Chrome, Safari, Edge (Antiguo) */
    background-clip: text;         /* <--- ESTA ES LA LÍNEA QUE FALTABA (Estándar) */
    
    /* HACE EL TEXTO TRANSPARENTE PARA QUE SE VEA EL FONDO */
    -webkit-text-fill-color: transparent;
    color: transparent; /* Fallback estándar */
}

.item-title {
    font-family: var(--font-heading);
    font-weight: 800; /* Más grueso para parecerse al logo */
    font-size: 1.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

/* BARRA DECORATIVA BAJO EL TÍTULO */
.item-title::after {
    content: '';
    display: block;
    width: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--undesa-cyan), var(--undesa-blue));
    margin-top: 10px;
    transition: width 0.5s ease;
}

.gallery-item:hover .item-title::after {
    width: 60px; /* Se dibuja la línea al hacer hover */
}

.item-description {
    max-height: 0;
    opacity: 0;
    color: #ddd;
    margin-top: 0;
    font-size: 1.1rem;
    line-height: 1.5;
    transition: all 0.5s ease 0.1s;
}

.gallery-item:hover .item-description {
    max-height: 200px;
    opacity: 1;
    margin-top: 15px;
}

/* BOTÓN DE ACCIÓN */
.btn-action {
    background-color: transparent;
    border: 2px solid var(--undesa-cyan);
    color: white;
    font-weight: bold;
    margin-top: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease 0.2s;
}

.btn-action:hover {
    background-color: var(--undesa-cyan);
    color: white;
    box-shadow: 0 0 15px var(--undesa-cyan);
}

.gallery-item:hover .btn-action {
    opacity: 1;
    transform: translateY(0);
}

/* FOOTER */
footer {
    flex-shrink: 0;
    background-color: #0b1120 !important; /* Casi negro, pero con tono azul */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 20px 0;
    font-size: 0.9rem;
    color: var(--text-grey);
}

/* =========================================
   ENLACES DEL FOOTER (Corrección de color)
   ========================================= */
.footer-link {
    /* Estado Normal: Gris claro azulado (legible sobre fondo oscuro) */
    color: var(--text-grey) !important; 
    transition: all 0.3s ease;
    opacity: 0.8; /* Un poco de transparencia para que no compita con el copyright */
}

/* Estado Hover (Al pasar el mouse) */
.footer-link:hover {
    /* Se ilumina con el Cyan corporativo */
    color: var(--undesa-cyan) !important;
    opacity: 1;
    text-decoration: underline !important; /* Subrayado sutil para indicar clic */
}

/* =========================================
   RESPONSIVE DESIGN (Móviles y Tablets)
   ========================================= */
@media (max-width: 991px) {
    
    /* 1. CAMBIO DE ESTRUCTURA: De filas a columnas */
    .gallery-container {
        flex-direction: column; /* Apilar uno sobre otro */
        height: 85vh; /* Usar el 85% de la altura de la pantalla del móvil */
        max-height: none; /* Quitar límites fijos */
        padding: 0 15px; /* Menos padding lateral */
    }

    /* 2. AJUSTE DE LAS CARTAS */
    .gallery-item {
        width: 100%; /* Ancho completo */
        flex: 1; /* Altura equitativa inicial */
        min-height: 80px; /* Asegura que siempre se vea un pedazo de la carta */
    }

    /* En móvil, al tocar (active/hover), la carta crece verticalmente */
    .gallery-item:hover, 
    .gallery-item:active,
    .gallery-item:focus {
        flex: 4; /* Crece 4 veces más alto que las otras */
    }

    /* 3. AJUSTES DE TEXTO PARA PANTALLAS PEQUEÑAS */
    .item-title {
        font-size: 1.4rem; /* Título un poco más pequeño */
    }
    
    .item-icon {
        font-size: 2rem;
    }

    .item-description {
        font-size: 0.95rem; /* Texto más legible en móvil */
    }
    
    /* Ajuste del contenido interno para que no se salga */
    .gallery-item:hover .item-description {
        max-height: 120px; /* Limitar altura de texto en móvil */
        overflow-y: auto; /* Permitir scroll si el texto es muy largo */
    }

    /* Ocultar el eslogan del header en móviles muy pequeños para ahorrar espacio */
    header .border-start {
        display: none !important;
    }
}

/* =========================================
   RESPONSIVE DESIGN (MÓVIL / TABLET VERTICAL)
   ========================================= */
@media (max-width: 991px) {
    
    /* 1. CORRECCIÓN DE ALINEACIÓN GENERAL */
    /* Quitamos el centrado vertical para que el título suba */
    main {
        align-items: flex-start !important; /* Alinea todo al techo */
        padding-top: 40px; /* Espacio para que no choque con el header */
        flex-direction: column;
        height: auto; /* Permite scroll infinito si es necesario */
    }

    /* 2. TÍTULO "PORTAL DE SOLUCIONES" */
    .title-section {
        font-size: 1.5rem; /* Ajuste de tamaño */
        margin-top: 10px;
    }
    
    /* Aseguramos que el contenedor del texto ocupe el ancho y no se comprima */
    main > section.text-center {
        width: 100%; 
        padding: 0 15px;
        margin-bottom: 20px !important;
    }

    /* 3. CONTENEDOR DE CARTAS */
    .gallery-container {
        flex-direction: column; /* Apilar verticalmente */
        height: auto !important; /* Altura libre, que crezca lo que necesite */
        width: 100%; /* Ocupar todo el ancho */
        max-width: 100%;
        padding: 0 15px 40px 15px; /* Padding inferior extra para el scroll */
        gap: 20px; /* Separación clara entre cartas */
    }

    /* 4. TARJETAS (Ancho completo) */
    .gallery-item {
        width: 100%; /* OBLIGATORIO: Ancho total */
        flex: none; /* Desactivar flex automático */
        height: 100px; /* Altura "cerrada" inicial */
        min-height: auto;
        border-radius: 12px; /* Un poco menos redondeado en móvil aprovecha mejor espacio */
    }

    /* ESTADO ACTIVO (AL TOCAR) */
    .gallery-item:hover,
    .gallery-item:active, 
    .gallery-item:focus {
        width: 100%; /* Mantiene ancho total */
        flex: none;
        height: auto; 
        min-height: 380px; /* Altura generosa para ver foto + texto + botón */
    }

    /* 5. CONTENIDO INTERNO */
/* DENTRO DEL @MEDIA MÓVIL */
    .item-content {
        transform: translateY(0); 
        padding: 20px;
        /* Mismo degradado azul vivo para móvil */
        background: linear-gradient(to top, rgba(1, 23, 46, 1) 30%, rgba(1, 23, 46, 0.7) 100%);
        width: 100%;
        position: absolute;
        bottom: 0;
    }
    
    /* TEXTOS Y BOTONES */
    .item-title {
        font-size: 1.4rem;
    }
    
    .item-description {
        font-size: 1rem;
        margin-top: 0;
        max-height: 0;
        overflow: hidden;
    }

    /* Al abrir */
    .gallery-item:hover .item-description {
        margin-top: 15px;
        max-height: 800px; /* Espacio de sobra */
    }

    .btn-action {
        width: 100%;
        display: block;
        margin-top: 20px;
        padding: 12px;
        background-color: rgba(41, 171, 226, 0.15); /* Fondo Cyan muy suave */
        border-color: var(--undesa-cyan);
    }
    
    /* Ajustes menores de header */
    .logo-img { height: 50px; }
    header .border-start, header .lead { display: none !important; }
}

/* =========================================
   IMÁGENES DE FONDO (Placeholders)
   ========================================= */

/* 1. Construcción Industrial */
.bg-construccion {
    /* Foto de estructuras metálicas */
    background-image: url('../img/construccion1.webp');
}

/* 2. Alquiler de Bodegas */
.bg-bodegas {
    /* Foto de pasillo logístico */
    background-image: url('../img/hero_portada_bodegas.jpg');
}

/* 3. Inmobiliaria */
.bg-inmobiliaria {
    /* Foto de edificio residencial moderno */
    background-image: url('https://images.unsplash.com/photo-1545324418-cc1a3fa10c00?auto=format&fit=crop&w=1000&q=80');
}

/* Estilos para la sección de Proyectos */
.project-card {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-card img {
    transition: transform 0.5s ease;
    width: 100%;
    height: 300px; /* Altura fija para uniformidad */
    object-fit: cover;
}

.project-card:hover img {
    transform: scale(1.1);
}

.project-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.9), transparent);
    padding: 2rem 1.5rem 1rem;
    transform: translateY(10px);
    opacity: 0.9;
    transition: all 0.3s ease;
}

.project-card:hover .project-overlay {
    transform: translateY(0);
    opacity: 1;
}