/* ========================================= */
/* 1. VARIABLES Y RESET */
/* ========================================= */
:root {
    --color-primario: #1a3c8b;
    --color-secundario: #0d1b3e;
    --color-acento: #ffcc00;
    --color-texto: #333333;
    --color-fondo-claro: #f8f9fa;
    --color-error: #e74c3c;
    --color-exito: #2ecc71;
    --ancho-maximo: 1200px;
    --whatsapp-color: #25d366;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }
html { scroll-behavior: smooth; overflow-x: hidden; } /* FIX 1: overflow-x también en html */
body { 
    color: var(--color-texto); 
    line-height: 1.6; 
    background-color: var(--color-fondo-claro); 
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw; /* FIX 1: evita que cualquier hijo desborde el viewport */
}

/* ========================================= */
/* 2. LAYOUT Y UTILIDADES */
/* ========================================= */
.container { width: 90%; max-width: var(--ancho-maximo); margin: 0 auto; padding: 0 15px; }
.section { padding: 80px 0; }

.section-title {
    font-family: 'Montserrat', sans-serif; font-size: 2.5rem; font-weight: 700;
    color: var(--color-primario); text-align: center; margin-bottom: 20px; 
    position: relative; line-height: 1.2;
}
.section-title::after {
    content: ''; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
    width: 100px; height: 4px; background-color: var(--color-acento); border-radius: 2px;
}
.section-subtitle {
    text-align: center; color: #666; font-size: 1.1rem; margin-bottom: 50px;
    max-width: 800px; margin-left: auto; margin-right: auto; padding: 0 10px;
}

/* ========================================= */
/* 3. ANIMACIONES */
/* ========================================= */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.anim-element { opacity: 0; } 
.anim-element.visible { animation: fadeInUp 0.8s ease-out forwards; }

/* ========================================= */
/* 4. NAV & HEADER */
/* ========================================= */
nav {
    background-color: var(--color-primario);
    color: white;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0; /* FIX 2: explícito para todas las páginas */
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}
.nav-container { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; }
.logo { font-family: 'Montserrat', sans-serif; font-size: 1.8rem; font-weight: 700; color: white; text-decoration: none; z-index: 1001; position: relative; }
.logo span { color: var(--color-acento); }

/* ─── MENÚ DESKTOP ─── */
.nav-links { display: flex; list-style: none; }
.nav-links li { margin-left: 30px; }
.nav-links a {
    color: white; text-decoration: none; font-weight: 500; font-size: 1.05rem;
    position: relative; padding: 5px 0; transition: 0.3s;
}
.nav-links a:hover, .nav-links a.active { color: var(--color-acento); }

/* ─── BOTÓN HAMBURGUESA: oculto en desktop ─── */
.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    z-index: 1001;
    position: relative;
    padding: 5px;
    line-height: 1;
}

/* Header Index */
header#inicio {
    position: relative;
    height: 75vh;
    min-height: 480px;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding-top: 70px; /* Compensa el nav fijo en todos los navegadores */
}

.header-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0;
}
.header-bg img {
    width: 100%; height: 100%; object-fit: cover; filter: brightness(0.65);
}

.header-content {
    position: relative; z-index: 1; width: 100%; color: white;
    text-align: center; padding: 0 20px;
}
.header-content h1 {
    font-size: 3rem; font-weight: 700; text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 20px; line-height: 1.1;
}

.cta-button {
    background: var(--color-acento); color: var(--color-primario); padding: 15px 35px;
    font-size: 1.1rem; font-weight: 700; text-decoration: none; border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); transition: all 0.3s ease; display: inline-block;
}
.cta-button:hover { transform: translateY(-3px) scale(1.05); background: #ffdb4d; }
.cta-button.secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
}
.cta-button.secondary:hover {
    background: white;
    color: var(--color-primario);
}

/* Headers Subpáginas */
.page-header {
    background: linear-gradient(rgba(26,60,139,0.9), rgba(26,60,139,0.95)), url('https://images.unsplash.com/photo-1554224155-6726b3ff858f?ixlib=rb-4.0.3');
    background-size: cover; background-position: center; color: white; text-align: center;
    padding: 140px 0 80px;
}
.page-header h1 { font-size: 2.8rem; margin-bottom: 15px; line-height: 1.2; }
.page-subtitle { font-size: 1.1rem; opacity: 0.9; padding: 0 10px; }

/* ========================================= */
/* 5. GRID SYSTEM Y TARJETAS */
/* ========================================= */
.servicios-grid, .testimonios-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 30px; margin-top: 40px; 
}
.servicio-card {
    background: white; border-radius: 12px; padding: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); transition: 0.4s ease;
    border-top: 5px solid var(--color-primario); display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.servicio-card:hover { transform: translateY(-10px); box-shadow: 0 20px 40px rgba(0,0,0,0.15); border-color: var(--color-acento); }
.servicio-icon { 
    font-size: 2.5rem; color: var(--color-primario); margin-bottom: 20px; transition: transform 0.4s ease, color 0.3s ease; display: inline-block;
}
.servicio-card:hover .servicio-icon { transform: translateX(-10px) scale(1.1); color: var(--color-acento); }
.servicio-card h3 { font-size: 1.4rem; color: var(--color-primario); margin-bottom: 15px; }
.servicio-card p { color: #555; flex-grow: 1; margin-bottom: 25px; }

/* ========================================= */
/* 6. FORMULARIOS */
/* ========================================= */
.formulario-inicio { background-color: #f0f4ff; }
.form-container-inicio {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 30px;
    background: white; border-radius: 15px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
#formulario-inicio { padding: 40px; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 0.95rem; color: #444; }
input, select, textarea {
    width: 100%; padding: 12px 15px; border: 1px solid #ddd; border-radius: 8px; font-size: 16px; background: #fff; transition: border 0.3s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primario); box-shadow: 0 0 0 3px rgba(26, 60, 139, 0.1); }
.submit-btn {
    background: var(--color-primario); color: white; border: none; padding: 15px;
    font-size: 1.1rem; font-weight: 600; border-radius: 8px; cursor: pointer;
    transition: 0.3s; width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.submit-btn:hover { background: var(--color-secundario); }
.checkbox-group { display: flex; align-items: flex-start; margin-top: 15px; gap: 12px; flex-wrap: wrap; }
.checkbox-group input { width: 20px !important; height: 20px !important; margin-top: 4px; flex-shrink: 0; cursor: pointer; }
.checkbox-group label { display: block; width: auto; flex: 1; margin-bottom: 0; line-height: 1.5; font-weight: 400; color: #555; cursor: pointer; }
.error-message { color: var(--color-error); font-size: 0.85rem; margin-top: 5px; display: block; width: 100%; flex-basis: 100%; }

.form-info-inicio { padding: 40px; background: var(--color-primario); color: white; display: flex; flex-direction: column; justify-content: center; }
.form-info-title { font-family: 'Montserrat', sans-serif; font-size: 1.6rem; margin-bottom: 25px; color: var(--color-acento); }
.beneficios-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
.beneficio-item { display: flex; align-items: flex-start; gap: 15px; padding: 15px 18px; background: #ffffff; border-radius: 10px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); transition: all .3s ease; }
.beneficio-item:hover { transform: translateY(-4px); box-shadow: 0 10px 25px rgba(0,0,0,0.08); }
.beneficio-item i { font-size: 20px; color: var(--color-acento); min-width: 25px; margin-top: 4px; }
.beneficio-item strong { display: block; font-size: 0.95rem; margin-bottom: 3px; color: var(--color-primario); }
.beneficio-item p { font-size: 0.9rem; color: #6b7280; line-height: 1.4; margin: 0; }

/* ============================= */
/* BANNER CRÉDITOS */
/* ============================= */
.banner-creditos {
    background-image: url("img/imagenbaner.webp"); background-size: cover; background-position: center; position: relative; height: 380px; display: flex; align-items: center; justify-content: center;
}
.banner-overlay {
    background: linear-gradient(rgba(10,25,60,0.75), rgba(10,25,60,0.85)); width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
}
.banner-content { text-align: center; color: white; max-width: 700px; }
.banner-content h2 { font-family: 'Montserrat', sans-serif; font-size: 2.2rem; margin-bottom: 15px; }
.banner-content p { font-size: 1rem; color: #d0d7e2; margin-bottom: 25px; line-height: 1.6; }

/* ========================================= */
/* 7. FOOTER */
/* ========================================= */
footer { background-color: var(--color-secundario); color: white; padding: 70px 0 20px; }
.footer-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 40px; margin-bottom: 40px; align-items: flex-start; }
.footer-contact h3, .footer-regulacion h3 { font-family: 'Montserrat', sans-serif; font-size: 1.3rem; margin-bottom: 20px; color: white; font-weight: 600; }
.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li { display: flex; align-items: flex-start; margin-bottom: 18px; color: #b0b7c3; font-size: 0.95rem; }
.contact-list i { color: var(--color-acento); margin-right: 15px; margin-top: 5px; }
.footer-regulacion p { margin-bottom: 20px; font-size: 0.95rem; color: #b0b7c3; line-height: 1.6; }
.reguladores { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
.reguladores img { height: 38px; width: auto; max-width: 160px; opacity: 0.85; filter: grayscale(100%); transition: all .3s ease; }
.reguladores img:hover { opacity: 1; filter: grayscale(0); transform: scale(1.05); }
.footer-bottom { text-align: center; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 30px; color: #888; font-size: 0.9rem; }
.legal-links a { color: #888; text-decoration: none; margin: 0 10px; transition: 0.3s; }
.legal-links a:hover { color: var(--color-acento); }

/* ========================================= */
/* 8. WHATSAPP FLOTANTE */
/* ========================================= */
.whatsapp-float {
    position: fixed; width: 60px; height: 60px; bottom: 30px; right: 30px;
    background-color: var(--whatsapp-color); color: #FFF; border-radius: 50px;
    text-align: center; font-size: 35px; box-shadow: 2px 2px 3px #999; z-index: 10000;
    display: flex; align-items: center; justify-content: center; text-decoration: none; transition: all 0.3s ease;
    animation: pulse-green 2s infinite;
}
.whatsapp-float:hover { background-color: #128C7E; transform: scale(1.1); color: white; }
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* ========================================= */
/* 9. RESPONSIVE */
/* ========================================= */

/* FIX 3: El breakpoint del menú hamburguesa sube a 992px
   para cubrir tablets y resoluciones "engañosas" de Android */
@media (max-width: 992px) {
    .section-title { font-size: 2.2rem; }
    .header-content h1 { font-size: 3rem; }
    .form-container-inicio { grid-template-columns: 1fr; }
    .form-info-inicio { order: -1; padding: 30px; }

    /* Mostrar botón hamburguesa */
    .menu-toggle { display: flex; align-items: center; justify-content: center; }

    /* FIX 4: position:absolute (no fixed) para que el menú no cause
       un segundo "bloque" que empuje el contenido y genere doble columna */
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;      /* ← CLAVE: absolute, no fixed */
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--color-primario);
        padding: 20px 0;
        box-shadow: 0 10px 10px rgba(0,0,0,0.15);
        z-index: 999;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }
    .nav-links.active { display: flex; }
    .nav-links li { margin: 0; width: 100%; text-align: center; }
    .nav-links a { display: block; padding: 15px; border-bottom: 1px solid rgba(255,255,255,0.1); }
    .nav-links a:hover, .nav-links a.active {
        background-color: rgba(255,204,0,0.12);
        color: var(--color-acento);
    }
}

@media (max-width: 768px) {
    .container { width: 92%; padding: 0 10px; }
    .section { padding: 50px 0; }
    .section-title { font-size: 1.8rem; }
    .header-content h1 { font-size: 2.2rem; }
    
    header#inicio { height: auto; min-height: 100vh; padding-top: 70px; padding-bottom: 50px; }
    .header-buttons { display: flex; flex-direction: column; align-items: center; gap: 15px; }
    .header-buttons .cta-button { width: 90%; max-width: 320px; text-align: center; }
    
    #formulario-inicio { padding: 25px 20px; }
    
    .footer-content { grid-template-columns: 1fr; gap: 30px; text-align: center; }
    .contact-list li, .reguladores { align-items: center; justify-content: center; }
    .whatsapp-float { width: 50px; height: 50px; font-size: 28px; bottom: 20px; right: 20px; }
    
    .banner-creditos { height: auto; min-height: 300px; padding: 60px 0; }
    .banner-overlay { padding: 60px 20px; }
    .banner-content h2 { font-size: 1.7rem; line-height: 1.2; }
    .banner-content p { font-size: 0.95rem; }
}
