/* Variables globales */
:root {
    --color-primary: #035f68;
    --color-secondary: #54bbc9;
    --color-gray: #c6c6c6;
    --color-light-gray: #f5f5f5;
    --color-white: #ffffff;
    --color-black: #333333;
    --font-primary: 'Montserrat', sans-serif;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.1);
    --border-radius: 8px;
}

/* Reset y estilos base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    color: var(--color-black);
}

/* Navbar principal */
.navbar {
    background-color: var(--color-white);
    box-shadow: var(--shadow-sm);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    height: 70px;
}

.nav-container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0 2rem;
    display: flex;
    align-items: stretch;
    justify-content: space-between;
}

/* Logo */
.nav-logo {
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-logo a {
    display: flex;
    align-items: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
    line-height: 1;
}

.nav-logo a:hover {
    color: var(--color-secondary);
}

.nav-logo img {
    max-height: 54px;
    width: auto;
    display: block;
}

/* Menú principal */
.nav-menu {
    display: flex;
    list-style: none;
    align-items: stretch;
    gap: 0.5rem;
    height: 100%;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 1.2rem;
    height: 100%;
    color: var(--color-primary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.nav-link:hover {
    color: var(--color-secondary);
    background: rgba(84, 187, 201, 0.1);
}

/* Botón CTA especial */
.nav-link-cta {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    color: var(--color-white) !important;
    font-weight: 600;
    padding: 0.5rem 1.2rem;
    height: auto;
    align-self: center;
    font-size: 1rem;
    line-height: 1.4;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(3, 95, 104, 0.2);
    transition: all 0.3s ease;
    position: relative;
    box-sizing: border-box;
}

.nav-link-cta b {
    color: var(--color-white);
    font-weight: inherit;
}

.nav-link-cta:hover {
    color: var(--color-white) !important;
    background: var(--color-secondary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(84, 187, 201, 0.35);
}

/* Flecha del submenú */
.arrow {
    transition: transform 0.3s ease;
}

.has-submenu:hover .arrow {
    transform: rotate(180deg);
}

/* Submenús */
.submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--color-white);
    min-width: 280px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 0.5rem 0;
    padding-left: 0;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.has-submenu:hover > .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.submenu li {
    padding: 0;
    position: relative;
}

.submenu a {
    display: block;
    padding: 0.8rem 1.5rem;
    color: var(--color-black);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.submenu a:hover {
    background: var(--color-primary);
    color: var(--color-white);
    padding-left: 2rem;
}

/* Submenus de segundo nivel (anidados) */
.submenu .submenu {
    /* Posicionar a la derecha del menú padre */
    position: absolute;
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: 0.25rem;
    min-width: 280px;
    transform: translateX(-10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1100;
}

/* Mostrar submenú anidado al hacer hover sobre su padre (desktop) */
.submenu li.has-submenu:hover > .submenu,
.submenu li.has-submenu > a:hover + .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Mantener visible el submenú anidado mientras se hace hover sobre él */
.submenu .submenu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Ajustes para evitar solapamiento visual */
.submenu .submenu a {
    padding-left: 1rem;
}

.submenu li:first-child a:hover {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.submenu li:last-child a:hover {
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Botón hamburguesa */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.nav-toggle span {
    width: 100%;
    height: 3px;
    background: var(--color-primary);
    border-radius: 3px;
    transition: all 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Responsive - Tablet y móvil */
@media screen and (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-container {
        align-items: center;
    }

    .nav-logo {
        height: auto;
    }

    .nav-menu {
        position: fixed;
        left: -100%;
        top: 70px;
        flex-direction: column;
        align-items: stretch;
        height: auto;
        background: var(--color-white);
        width: 100%;
        text-align: center;
        transition: left 0.3s ease;
        box-shadow: var(--shadow-md);
        padding: 2rem 0;
        gap: 0;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-item {
        width: 100%;
        height: auto;
        flex-direction: column;
        align-items: stretch;
    }

    .nav-link {
        width: 100%;
        height: auto;
        padding: 1rem 2rem;
        justify-content: center;
        border-radius: 0;
        line-height: 1.4;
        white-space: nowrap;
    }

    .submenu {
        min-width: 0;
        width: 100%;
    }

    /* Submenús en móvil */
    .submenu {
        position: static;
        opacity: 0;
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
        transform: none;
        box-shadow: none;
        background: var(--color-light-gray);
        border-radius: 0;
        margin: 0;
        transition: all 0.3s ease;
    }

    /* Mostrar submenú (cualquier nivel) en móvil: usar alturas grandes y overflow visible
       para evitar que el contenido anidado quede recortado por un contenedor con overflow:hidden. */
    .has-submenu.active > .submenu {
        opacity: 1 !important;
        visibility: visible !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    .submenu a {
        color: var(--color-primary);
        padding: 1rem 2rem;
        padding-left: 3rem;
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .submenu a:hover {
        background: var(--color-secondary);
        color: var(--color-white);
        padding-left: 3.5rem;
    }
    
    /* Para submenus anidados, incrementar padding izquierdo */
    .submenu .submenu a {
        padding-left: 4rem;
    }
    
    .submenu .submenu a:hover {
        padding-left: 4.5rem;
    }

    .submenu li:first-child a:hover,
    .submenu li:last-child a:hover {
        border-radius: 0;
    }

    /* En móvil, hacer clic en el enlace del menú despliega el submenú */
    .has-submenu > .nav-link {
        pointer-events: all;
    }

    /* En móvil, los submenús anidados deben comportarse como bloques estáticos */
    .submenu .submenu {
        position: static;
        transform: none;
        left: auto;
        margin-left: 0;
        min-width: auto;
        box-shadow: none;
        background: var(--color-light-gray);
        opacity: 0;
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
    }

    /* Mostrar submenú anidado cuando el LI que lo contiene tiene .active en móvil */
    .has-submenu.active > .submenu li.has-submenu.active > .submenu {
        opacity: 1 !important;
        visibility: visible !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        display: block !important;
    }
}

/* Animaciones adicionales */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-menu.active .nav-item {
    animation: fadeInDown 0.3s ease forwards;
}

.nav-menu.active .nav-item:nth-child(1) { animation-delay: 0.1s; }
.nav-menu.active .nav-item:nth-child(2) { animation-delay: 0.15s; }
.nav-menu.active .nav-item:nth-child(3) { animation-delay: 0.2s; }
.nav-menu.active .nav-item:nth-child(4) { animation-delay: 0.25s; }
.nav-menu.active .nav-item:nth-child(5) { animation-delay: 0.3s; }
.nav-menu.active .nav-item:nth-child(6) { animation-delay: 0.35s; }

/* Footer link small helpers to match nav hover behavior */
.footer a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
.footer a:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}
