/* ===== MENÚ PRINCIPAL (DESKTOP) ===== */
.nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
    align-items: center;
    height: 100%;
}

.nav-menu > li {
    position: relative;
    margin: 0;
}

/* ENLACES NIVEL 1 */
.nav-menu > li > a {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    color: #4a5568;
    font-weight: 500;
    font-size: 0.8925rem; /* 0.85rem × 1.05 */
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    line-height: 1.2;
    border: 1px solid transparent;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu > li > a:hover {
    background-color: #f0f2f5;
    color: var(--color-primario);
}

/* ===== FLECHA INDICADORA (NIVEL 1) ===== */
.dropdown > .dropdown-toggle::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    transition: opacity 0.2s ease;
    opacity: 0.7;
    vertical-align: middle;
}

.dropdown:hover > .dropdown-toggle::after {
    opacity: 1;
}

/* ===== DROPDOWNS (NIVEL 2) ===== */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 285px;
    background: white;
    box-shadow: 0 16px 40px rgba(15,23,42,0.14);
    border-radius: 0;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s;
    z-index: 1000;
    border: 1px solid transparent !important;
}

.dropdown:hover > .dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.dropdown-menu li {
    position: relative;
}

.dropdown-menu a {
    display: block;
    padding: 10px 20px;
    color: #4a5568;
    font-family: 'Open Sans', sans-serif;
    font-weight: 500;
    font-size: 0.9975rem; /* 0.95rem × 1.05 */
    line-height: 1.2;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: normal;
    word-wrap: break-word;
    border-left: 3px solid transparent;
}

.dropdown-menu a:hover {
    background: #f8fafc;
    color: var(--color-primario);
    border-left-color: var(--color-primario);
}

/* ===== MEGA MENÚ (PRODUCTOS) ===== */
.dropdown-menu.mega-menu {
    min-width: 740px;
    padding: 0;
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%);
    background: #f8fafc;
}

.mega-cols {
    display: flex;
    align-items: stretch;
    padding: 20px;
    gap: 36px;
}

.mega-col {
    flex: 1;
    min-width: 190px;
}

a.mega-col-title {
    display: block;
    font-weight: 600;
    font-size: 0.873rem; /* 0.759rem × 1.15 */
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    color: var(--color-primario);
    padding: 0 0 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid #eef1f4;
    border-left: none;
    text-decoration: none;
    background: none;
}

a.mega-col-title:hover {
    background: none;
    border-left: none;
    border-bottom-color: var(--color-primario);
}

.mega-col-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mega-col-links li a {
    display: block;
    padding: 6px 0 6px 10px;
    font-size: 0.9rem;
    color: #4a5568;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.mega-col-links li a:hover {
    color: var(--color-primario);
    background: none;
    border-left-color: var(--color-primario);
}

.mega-highlight {
    width: 180px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.mega-highlight::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--color-primario);
    opacity: 0.18;
}

.mega-highlight-titulo {
    color: white;
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.3;
    position: relative;
    z-index: 1;
}

.mega-highlight-texto {
    color: #94a3b8;
    font-size: 0.78rem;
    line-height: 1.45;
    margin: 0;
    position: relative;
    z-index: 1;
}

a.mega-highlight-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-primario);
    color: white;
    font-size: 0.74rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    padding: 7px 12px;
    border-radius: 20px;
    margin-top: 4px;
    position: relative;
    z-index: 1;
    transition: filter 0.15s ease;
}

.mega-highlight-link:hover {
    filter: brightness(1.1);
}

/* ===== SUBMENÚS (NIVEL 3) ===== */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu .dropdown-menu {
    top: 0;
    left: 100%;
    margin-left: 5px;
    transform: translateX(-5px);
}

.dropdown-submenu:hover > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* FLECHA PARA SUBMENÚS (NIVEL 2 CON HIJOS) */
.dropdown-submenu > a {
    position: relative;
    padding-right: 30px;
}

.dropdown-submenu > a::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-left-color: #a0aec0;
    transition: opacity 0.2s ease;
    opacity: 0.7;
}

.dropdown-submenu:hover > a::after {
    opacity: 1;
    border-left-color: var(--color-primario);
}

/* ===== DIVISOR ===== */
.dropdown-divider {
    height: 1px;
    background: #5a5a5a;
    margin: 4px 0;
}

/* ===== BOTÓN PORTAL CLIENTES ===== */
.acceso-clientes {
    margin-left: 10px;
}

.btn-acceso {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    color: var(--color-primario) !important;
    padding: 4px 10px !important;
    border-radius: 30px !important;
    font-weight: 700;
    font-size: 0.84rem; /* 0.8rem × 1.05 */
    transition: background 0.2s ease, color 0.2s ease;
    border: 1px solid  var(--color-primario) !important;
    white-space: nowrap;
    text-decoration: none;
}

.btn-acceso:hover {
    background: var(--color-primario) !important;
    color: white !important;
}

.btn-acceso svg {
    width: 16px;
    height: 16px;
}
/* ===== MENÚ HAMBURGUESA (MÓVIL) ===== */
@media (max-width: 768px) {

    /* CONTENEDOR PRINCIPAL - 70% ANCHO */
    .main-nav {
        position: fixed;
        top: 70px;
        left: -70%;  /* Coincide con el ancho */
        width: 70% !important;
        height: calc(100vh - 70px);
        background: white;
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        margin: 0;
        padding: 0;
    }
    
    .main-nav.active {
        left: 0 !important;
    }

    /* LISTA PRINCIPAL */
    .nav-menu {
        display: flex;
        flex-direction: column;
        padding: 0;
        margin: 0 3px;
        width: calc(100% - 6px);
        background: white;
        list-style: none;
    }

    /* ITEMS DE TODOS LOS NIVELES */
    .nav-menu li {
        width: 100%;
        margin: 0;
        padding: 0;
        list-style: none;
        border-bottom: 1px solid #f0f0f0;
    }

    .nav-menu li:last-child {
        border-bottom: none;
    }

    /* ===== NIVEL 1 ===== */
    .nav-menu > li > a {
        display: block;
        padding: 0.5rem 0.75rem !important;
        background: var(--color-primario) !important;
        color: white !important;
        border-radius: 6px;
        font-weight: 500;
        width: 100%;
        text-decoration: none;
        transition: filter 0.2s ease;
        font-size: 0.945rem; /* 0.9rem × 1.05 */
        line-height: 1.6;
        border: none;
        outline: none;
        box-shadow: none;
        margin: 0;
    }

    .nav-menu > li > a:hover {
        filter: brightness(1.1);
        background: var(--color-primario) !important;
        color: white !important;
    }

    /* ===== NIVEL 2 ===== */
    .dropdown-menu li > a {
        display: block;
        padding: 0.4rem 0.7rem !important;
        background: var(--color-primario) !important;
        filter: brightness(1.15);
        color: white !important;
        font-size: 0.945rem; /* 0.9rem × 1.05 */
        font-weight: 600;
        width: 100%;
        text-decoration: none;
        border: none;
        outline: none;
        border-radius: 6px;
    }

    .dropdown-menu li > a:hover {
        background: #e8e8e8 !important;
        color: #111 !important;
    }

    /* ===== NIVEL 3 ===== */
    .dropdown-submenu .dropdown-menu li > a {
        display: block;
        padding: 0.4rem 0.7rem !important;
        background: #f6f2f1 !important;
        color: var(--color-primario) !important;
        font-size: 0.945rem; /* 0.9rem × 1.05 */
        font-weight: 600;
        width: 100%;
        text-decoration: none;
        border: 1px solid var(--color-primario) !important;
        border-radius: 6px;
    }

    .dropdown-submenu .dropdown-menu li > a:hover {
        background: #e0e0e0 !important;
        color: #111 !important;
    }

    /* DROPDOWNS */
    .dropdown-menu,
    .dropdown-submenu .dropdown-menu {
        display: none;
        position: static;
        box-shadow: none;
        padding: 0;
        margin: 0;
        width: 100%;
        background: transparent;
    }

    .dropdown.active > .dropdown-menu,
    .dropdown-submenu.active > .dropdown-menu {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    /* MEGA MENÚ EN MÓVIL: se apila, con fondo propio para no verse plano/blanco.
       Anula el ancho fijo y el translateX de centrado de desktop (el transform
       no se desactiva solo con position:static, y sin esto el panel terminaba
       corrido cientos de px fuera de pantalla). */
    .mega-menu {
        min-width: 0 !important;
        width: 100%;
        left: auto !important;
        transform: none !important;
        background: #f8fafc !important;
        border-radius: 0;
        margin: 0.25rem 0 0.5rem;
    }
    .nav-menu li.mega-cols {
        flex-direction: column;
        padding: 0.75rem !important;
        border-bottom: none;
        gap: 0;
    }
    .mega-col {
        margin-bottom: 0.5rem;
    }
    .mega-col-title {
        color: var(--color-primario) !important;
        background: none !important;
        border-bottom: 1px solid #e2e8f0;
        padding: 0.4rem 0 6px !important;
        font-size: 1rem !important;
    }
    .mega-col-links li > a {
        color: #4a5568 !important;
        background: none !important;
        border: none !important;
        font-size: 1.012rem !important; /* 0.88rem × 1.15 */
        font-weight: 400 !important;
        padding: 0.35rem 0.5rem !important;
    }
    .mega-highlight {
        display: none;
    }

    /* OCULTAR FLECHAS */
    .dropdown-submenu > a::after,
    .dropdown-toggle::after {
        display: none !important;
    }

    /* BOTÓN PORTAL */
    .acceso-clientes {
        padding: 0.75rem;
        background: white;
        width: 100%;
        box-sizing: border-box;
    }

    .btn-acceso {
        display: block;
        width: 100%;
        text-align: center;
        padding: 0.75rem;
        background: var(--color-primario);
        color: white !important;
        border-radius: 25px;
        font-weight: 700;
        text-decoration: none;
        transition: filter 0.2s ease;
    }

    .btn-acceso:hover {
        filter: brightness(1.1);
        background: var(--color-primario);
        color: white !important;
    }
}