/* ===========================================
   NAVBAR MAESTRO (FIX FINAL: DROPDOWN & ALINEACIÓN)
   =========================================== */
:root {
    --nav-purple: #2E1A5F;
    --nav-teal: #3BBCA8;
    --nav-height: 100px;
    --nav-height-mobile: 80px;
}

html {
    scroll-padding-top: var(--nav-height);
    font-family: 'Poppins', sans-serif;
}

/* ===========================================
   ESTILOS BASE (Móvil y General)
   =========================================== */
.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    background-color: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    height: var(--nav-height);
    z-index: 1000;
    display: flex; justify-content: center;
    transition: height 0.3s ease;
}

.nav-container {
    width: 100%; max-width: 100%;
    padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
    height: 100%;
}

/* --- LOGO --- */
.logo {
    display: flex; align-items: center; text-decoration: none; 
    margin: 0; flex-shrink: 0; z-index: 1003;
}
.logo img {
    height: 85px; width: auto; max-width: 200px;
    object-fit: contain; transition: 0.3s;
}
.logo:hover img { transform: scale(1.05); }

/* --- BURBUJA DE CONTACTO (SOLUCIÓN DEFORMIDAD) --- */
.nav-contact-bubble {
    position: relative; display: none; /* Se activa en Tablet/PC */
    align-items: center; margin-right: 30px;
    background: #f0fdfa; padding: 10px 22px;
    border-radius: 50px; border: 1px solid var(--nav-teal);
    transition: all 0.3s ease; flex-shrink: 0; cursor: pointer;
    min-width: max-content; /* Evita que se aplaste */
}
.nav-contact-bubble:hover {
    border-color: var(--nav-purple);
    box-shadow: 0 4px 12px rgba(46, 26, 95, 0.15);
}

.bubble-content { 
    display: flex; align-items: center; gap: 10px; 
    width: 100%; justify-content: center;
}

/* Icono Animado */
.pulse-icon {
    width: 38px; height: 38px;
    background: var(--nav-teal); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1rem; position: relative; z-index: 1; flex-shrink: 0;
    animation: pulse-wave 2s infinite ease-out;
}
.pulse-icon::after {
    content: ''; position: absolute; top: 0; left: 0;
    width: 100%; height: 100%; border-radius: 50%;
    background: var(--nav-teal); z-index: -1;
    animation: pulse-wave 2s infinite ease-out;
}
@keyframes pulse-wave {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 0.4; }
    100% { transform: scale(1); opacity: 0.8; }
}

.bubble-text { 
    display: flex; flex-direction: column; line-height: 1.1; 
    white-space: nowrap; /* Evita saltos de línea raros */
}
.bubble-label { font-size: 0.7rem; color: var(--nav-purple); font-weight: 700; text-transform: uppercase; }
.bubble-number { font-size: 1.6rem; color: var(--nav-purple); font-weight: 800; }

/* Dropdown de la burbuja */
.bubble-dropdown {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: white; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden; opacity: 0; visibility: hidden;
    transform: translateY(-10px); transition: all 0.3s ease; z-index: 100;
}
.nav-contact-bubble.active .bubble-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-option {
    display: flex; align-items: center; gap: 12px; padding: 12px 18px;
    text-decoration: none; font-weight: 600; font-size: 0.9rem;
    transition: all 0.2s ease; border-bottom: 1px solid #f0f0f0;
}
.call-option { color: var(--nav-purple); }
.whatsapp-option { color: #25D366; }

/* --- MENÚ PRINCIPAL --- */
.nav-menu {
    display: flex; list-style: none; margin: 0; padding: 0;
}
.nav-menu a {
    font-family: 'Poppins', sans-serif; text-decoration: none; color: #333;
    font-weight: 500; transition: 0.3s; display: flex; align-items: center;
}

/* --- BOTONES --- */
.nav-buttons {
    display: flex; gap: 10px; align-items: center; flex-shrink: 0;
}
.btn-nav-cotiza, .btn-nav-resultados {
    display: inline-block; padding: 10px 18px; border-radius: 8px;
    text-decoration: none; font-family: 'Poppins', sans-serif; font-weight: 700;
    font-size: 0.85rem; transition: all 0.3s ease; white-space: nowrap;
}
.btn-nav-cotiza { background: var(--nav-purple); color: white; border: 2px solid var(--nav-purple); }
.btn-nav-resultados { background: var(--nav-teal); color: white; border: 2px solid var(--nav-teal); }

/* Hamburguesa */
.hamburger {
    display: none; flex-direction: column; gap: 6px; 
    background: none; border: none; cursor: pointer; padding: 5px;
}
.hamburger span { width: 30px; height: 3px; background: var(--nav-purple); transition: 0.3s; border-radius: 2px; }


/* ===========================================
   MÓVIL (Menos de 992px)
   >>> AQUÍ ARREGLAMOS EL CENTRADO Y EL DROPDOWN <<<
   =========================================== */
@media (max-width: 991px) {
    .navbar { height: 80px; }
    .hamburger { display: flex; position: absolute; right: 20px; z-index: 1002; }
    
    .nav-container { padding: 0 15px; justify-content: space-between; }
    .logo { margin: 0 auto 0 10px; order: 0; } /* Logo a la izquierda */
    .logo img { height: 50px; }
    
    /* MENÚ DESLIZANTE */
    .nav-menu {
        position: fixed; top: 80px; right: -100%; width: 100%;
        height: calc(100vh - 80px); background: white;
        flex-direction: column; 
        /* CENTRADO TOTAL */
        align-items: center; 
        justify-content: flex-start;
        padding: 20px 0; overflow-y: auto; z-index: 1001;
        transition: right 0.4s ease;
    }
    .nav-menu.active { right: 0; box-shadow: -5px 0 20px rgba(0,0,0,0.1); }

    /* Items del menú centrados */
    .nav-menu > li { width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; }
    
    .nav-menu > li > a {
        padding: 15px 20px; width: 100%; border-bottom: 1px solid #f0f0f0;
        font-size: 1.1rem; justify-content: center; /* Centra el texto */
    }

    /* DROPDOWN MÓVIL (ACORDEÓN) */
    .nav-menu li.has-dropdown { display: flex; flex-direction: column; }
    
    .nav-menu li.has-dropdown > a::after {
        content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
        margin-left: 10px; font-size: 0.8rem; transition: 0.3s;
    }
    .nav-menu li.has-dropdown.open > a::after { transform: rotate(180deg); }

    /* El submenú */
    .dropdown-menu {
        display: none; /* Oculto por defecto */
        width: 100%; background: #f8f8f8; 
        padding: 0; list-style: none;
    }
    
    /* ¡ESTA ES LA CLAVE PARA QUE ABRA EN MÓVIL! */
    .nav-menu li.has-dropdown.open .dropdown-menu {
        display: block; /* Se muestra al tener la clase .open */
    }

    .dropdown-menu li a {
        padding: 12px 0; font-size: 0.95rem; color: #555;
        border-bottom: 1px solid #e5e5e5;
        justify-content: center; /* Centra los items del submenú */
    }

    /* Botones Móvil */
    .nav-buttons {
        position: fixed; bottom: 0; right: -100%; width: 100%;
        background: white; padding: 20px; flex-direction: column;
        transition: right 0.4s ease; z-index: 1002; box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
    }
    .nav-buttons.active { right: 0; }
    .btn-nav-cotiza, .btn-nav-resultados { width: 100%; text-align: center; }

    /* Animación X Hamburguesa */
    .hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(7px, 7px); }
    .hamburger.active span:nth-child(2) { opacity: 0; }
    .hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(7px, -7px); }
}


/* ===========================================
   TABLET (992px - 1199px)
   =========================================== */
@media (min-width: 992px) {
    /* Recuperamos estilos de escritorio */
    .nav-contact-bubble { display: flex; } /* Aparece la burbuja */
    
    .nav-menu { flex: 1; justify-content: center; gap: 15px; }
    .nav-menu a { font-size: 0.9rem; padding: 5px 0; position: relative; }
    
    /* Subrayado Hover */
    .nav-menu a::before {
        content: ''; position: absolute; left: 0; bottom: 0;
        width: 0; height: 3px; border-radius: 2px;
        background-color: var(--nav-teal); transition: width 0.3s ease;
    }
    .nav-menu a:hover { color: var(--nav-teal); }
    .nav-menu a:hover::before { width: 100%; }

    /* Dropdown Desktop (Hover) */
    .dropdown-menu {
        position: absolute; top: 100%; left: 50%; transform: translateX(-50%) translateY(10px);
        width: 220px; background: white; box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        border-radius: 8px; border-top: 4px solid var(--nav-purple);
        padding: 10px 0; list-style: none; opacity: 0; visibility: hidden; transition: 0.3s;
    }
    .nav-menu li.has-dropdown { position: relative; height: 100%; }
    .nav-menu li.has-dropdown:hover .dropdown-menu { 
        opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); 
    }
    
    .dropdown-menu li a { 
        display: block; padding: 10px 20px; color: #555; border-bottom: 1px solid #f0f0f0;
        justify-content: flex-start; /* Izquierda en submenú PC */
    }
    .dropdown-menu li a:hover { background: #f9f9f9; color: var(--nav-purple); padding-left: 25px; }
    
    /* Flechita PC */
    .nav-menu li.has-dropdown > a::after {
        content: ''; display: inline-block; width: 8px; height: 8px;
        border-right: 2px solid #555; border-bottom: 2px solid #555;
        transform: rotate(45deg); margin-left: 8px; margin-bottom: 3px; transition: 0.3s;
    }
    .nav-menu li.has-dropdown:hover > a::after { transform: rotate(-135deg); border-color: var(--nav-teal); }

    /* Burbuja y Botones */
    .nav-contact-bubble { margin-right: 15px; padding: 6px 12px; }
    .nav-buttons { margin-left: auto; padding-left: 0; }
}


/* ===========================================
   LAPTOP FIX (1200px - 1450px)
   >>> AQUÍ ARREGLAMOS EL ESPACIO PARA QUE QUEPA TODO <<<
   =========================================== */
@media (min-width: 1200px) {
    .nav-container {
        /* Padding elástico */
        padding: 0 clamp(20px, 3vw, 50px);
    }

    /* Logo elástico */
    .logo {
        margin-left: clamp(0px, 2vw, 40px); /* Sin margen fijo */
        margin-right: clamp(20px, 3vw, 40px);
    }
    .logo img { height: clamp(65px, 5vw, 85px); }

    /* Menú elástico */
    .nav-menu { gap: clamp(15px, 2vw, 40px); }
    .nav-menu a { font-size: clamp(0.95rem, 0.9rem + 0.2vw, 1.1rem); }
    
    /* Burbuja completa */
    .nav-contact-bubble {
        margin-right: clamp(15px, 2vw, 30px);
        padding: 10px clamp(15px, 1.5vw, 22px);
    }
    .bubble-number { font-size: clamp(1.3rem, 1.1rem + 0.4vw, 1.6rem); }

    /* Botones */
    .nav-buttons { padding-left: clamp(10px, 2vw, 40px); gap: 15px; }
    .btn-nav-cotiza, .btn-nav-resultados { padding: 10px clamp(15px, 1.5vw, 25px); font-size: 0.95rem; }
}