/* Estilos base: variables, encabezado y menú (todas las páginas) */

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #10b981;
    --accent-color: #38bdf8;
    --light-color: #f8fafc;
    --dark-color: #1e293b;
    --header-height: 80px;
    --header-height-mobile: 70px;
    --transition-speed: 0.3s;
    --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --gradient-blue: linear-gradient(135deg, #2563eb, #38bdf8);
    --gray-color: #94a3b8;
    --dropdown-hover-bg: #e0f2fe;
    --dropdown-hover-bg-strong: #bae6fd;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--dark-color);
    line-height: 1.6;
    background-color: #fff;
    padding-top: var(--header-height);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--secondary-color);
}

/* HEADER ULTRA OPTIMIZADO */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0);
    box-shadow: none;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    transition: all var(--transition-speed);
    contain: layout style;
    will-change: transform, background-color, box-shadow;
}

.header.scrolled {
    height: 65px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    height: 100%;
    contain: layout;
}

.logo img {
    height: 60px;
    max-width: 220px;
    width: auto;
    transition: height var(--transition-speed);
    object-fit: contain;
    contain: layout;
}

.header.scrolled .logo img {
    height: 52px;
}

.nav-menu {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 100%;
    margin-left: 3rem;
    contain: layout;
}

.nav-menu ul {
    display: flex;
    flex-direction: row;
    align-items: center;
    list-style: none;
    height: 100%;
    margin: 0;
    padding: 0;
    gap: 0.75rem;
}

.nav-item {
    height: 100%;
    display: flex;
    align-items: center;
    contain: layout;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0 1.2rem;
    height: 45px;
    font-size: 1.02rem;
    color: #003b73;
    font-weight: 600;
    border-radius: 8px;
    transition: all var(--transition-speed);
    position: relative;
    contain: layout style;
    will-change: color, transform;
}

.header.scrolled .nav-link {
    color: var(--dark-color);
    font-weight: 500;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width var(--transition-speed);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 60%;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

/* Dropdown Optimizado */
.dropdown {
    position: relative;
    contain: layout;
}

.dropdown-toggle {
    padding-right: 22px;
    position: relative;
}

.dropdown-toggle::before {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: currentColor transparent transparent transparent;
    transition: transform var(--transition-speed);
}

.dropdown:hover .dropdown-toggle::before,
.dropdown.active .dropdown-toggle::before {
    transform: translateY(-50%) rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 280px;
    background: #fff;
    box-shadow: var(--box-shadow);
    border-radius: 10px;
    padding: 1rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-speed);
    z-index: 100;
    contain: layout style;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 0.8rem 1.5rem;
    color: var(--dark-color);
    transition: all 0.2s;
    font-size: 0.98rem;
    font-weight: 400;
    contain: layout style;
}

.dropdown-item:hover {
    background: var(--dropdown-hover-bg-strong);
    color: var(--primary-color);
    padding-left: 1.8rem;
}

.header-cta {
    margin-left: auto;
    contain: layout;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-blue);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 0.75rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
    text-transform: none;
    letter-spacing: 0.3px;
    contain: layout style;
    will-change: transform, box-shadow;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
    color: #fff;
}

.hamburger {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--light-color);
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition-speed);
    contain: layout;
}

.hamburger:hover {
    background: rgba(37, 99, 235, 0.1);
}

.hamburger span {
    display: block;
    width: 24px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 3px;
    transition: all 0.3s;
}

/* Elementos móviles ocultos por defecto */
.mobile-menu-header,
.mobile-menu-contact,
.mobile-cta-wrapper,
.menu-overlay {
    display: none;
}

/* RESPONSIVE OPTIMIZADO */
@media (max-width: 991px) {
    body {
        padding-top: var(--header-height-mobile);
    }

    .header {
        height: var(--header-height-mobile);
        padding: 0 1.5rem;
    }

    .header.scrolled {
        height: 60px;
    }

    .logo img {
        height: 42px;
        max-width: 160px;
    }

    .header.scrolled .logo img {
        height: 42px;
    }

    .hamburger {
        display: flex;
        width: 45px;
        height: 45px;
        border-radius: 10px;
        padding: 12px;
        z-index: 1002;
    }

    .hamburger.active span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
        background: var(--primary-color);
    }

    .hamburger.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(-20px);
    }

    .hamburger.active span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
        background: var(--primary-color);
    }

    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        margin-bottom: 1rem;
    }

    .mobile-logo img {
        height: 32px;
    }

    .close-menu {
        font-size: 1.5rem;
        color: var(--gray-color);
        cursor: pointer;
        display: none;
    }

    .nav-menu {
        display: block;
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 380px;
        height: 100vh;
        margin: 0;
        background: #fff;
        transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
        z-index: 1001;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
        padding-top: var(--header-height-mobile);
        overflow-y: auto;
    }

    .nav-menu.active {
        right: 0;
    }

    .menu-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        z-index: 1000;
        transition: all 0.3s ease;
    }

    .menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .nav-menu ul {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        padding: 1rem 1.5rem;
        gap: 0.5rem;
        margin-bottom: 1rem;
        height: auto;
    }

    .nav-item {
        height: auto;
        margin-bottom: 0;
        width: 100%;
    }

    .nav-link {
        height: auto;
        width: 100%;
        padding: 0.8rem 1rem;
        justify-content: flex-start;
        font-weight: 500;
        border-radius: 10px;
        font-size: 1.1rem;
        color: var(--dark-color);
        background: transparent;
        border-left: 3px solid transparent;
    }

    .nav-link.active {
        background: rgba(37, 99, 235, 0.08);
        border-left: 3px solid var(--primary-color);
        color: var(--primary-color);
        font-weight: 600;
    }

    .nav-link:hover {
        background: rgba(37, 99, 235, 0.05);
    }

    .nav-link::after {
        display: none;
    }

    .dropdown {
        width: 100%;
    }

    .dropdown-toggle {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-right: 1rem;
    }

    .dropdown-toggle::before {
        display: none;
    }

    .dropdown-toggle::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.8rem;
        color: var(--gray-color);
        transition: all var(--transition-speed);
    }

    .dropdown.active .dropdown-toggle::after {
        transform: rotate(180deg);
        color: var(--primary-color);
    }

    .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: max-height 0.3s ease-in-out;
        margin-top: 0.3rem;
        margin-bottom: 0.5rem;
        background: transparent;
    }

    .dropdown.active .dropdown-menu {
        max-height: 600px;
    }

    .dropdown-item {
        padding: 0.7rem 1rem 0.7rem 2rem;
        margin: 0.2rem 0;
        border-radius: 8px;
        font-size: 1rem;
        color: var(--dark-color);
        transition: all 0.2s;
        display: flex;
        align-items: center;
    }

    .dropdown-item:before {
        content: '\f054';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 0.7rem;
        margin-right: 0.8rem;
        color: var(--primary-color);
        opacity: 0.7;
    }

    .dropdown-item:hover {
        background: rgba(37, 99, 235, 0.08);
        padding-left: 2.3rem;
        color: var(--primary-color);
    }

    .mobile-menu-contact {
        display: block;
        padding: 1.5rem;
        background: var(--light-color);
        border-radius: 12px;
        margin: 1rem 1.5rem;
    }

    .mobile-menu-contact h4 {
        font-size: 1rem;
        margin-bottom: 1rem;
        color: var(--dark-color);
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .mobile-menu-contact h4 i {
        color: var(--primary-color);
    }

    .contact-item {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        margin-bottom: 0.8rem;
        font-size: 0.9rem;
    }

    .contact-item i {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(37, 99, 235, 0.1);
        border-radius: 50%;
        color: var(--primary-color);
    }

    .contact-item a {
        color: var(--dark-color);
    }

    .mobile-social {
        display: flex;
        gap: 1rem;
        margin-top: 1.5rem;
        justify-content: center;
    }

    .social-icon {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(37, 99, 235, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--primary-color);
        font-size: 1rem;
        transition: all var(--transition-speed);
    }

    .social-icon:hover {
        background: var(--primary-color);
        color: white;
        transform: translateY(-3px);
    }

    .mobile-cta-wrapper {
        display: block;
        padding: 1rem 1.5rem 2rem;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        margin-top: 1rem;
        text-align: center;
    }

    .header-cta {
        display: none;
    }

    .mobile-cta-wrapper .header-cta {
        display: block;
        margin: 0;
        width: 100%;
    }

    .mobile-cta-wrapper .btn {
        width: 100%;
        padding: 1rem 1.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        background: linear-gradient(135deg, #10b981, #059669);
        box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
    }

    .mobile-cta-wrapper .btn:hover {
        box-shadow: 0 6px 20px rgba(16, 185, 129, 0.25);
    }

    .mobile-cta-wrapper .btn i {
        margin-right: 8px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0 1rem;
    }

    .logo img {
        height: 38px;
    }

    .hamburger {
        width: 42px;
        height: 42px;
        padding: 10px;
    }

    .nav-menu {
        width: 100%;
        max-width: none;
    }

    .nav-link {
        font-size: 1rem;
        padding: 0.8rem 0.8rem;
    }

    .dropdown-item {
        font-size: 0.95rem;
    }

    .mobile-cta-wrapper .btn {
        font-size: 0.95rem;
    }
}

/* Campo trampa antispam de los formularios: invisible para las personas */
.hp-field {
    position: absolute !important;
    left: -10000px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
