/*
 * Mega menú del sitio (estilo siigo.com).
 * Alcance: solo el menú principal (header nav) de components/navegacion.blade.php.
 * Desktop >= 993px: panel ancho con columnas (Escritorio, En la nube, Soluciones) y dropdowns simples (Soporte, Contacto).
 * Móvil <= 992px (mismo corte que style-navegacion.css): el panel es una lista apilada dentro del menú colapsable.
 * Paleta Siigo: #009dff, #007ecc, #222b45, #37465a. NEW naranja del sitio: #ff6b00 (definido en navegacion.blade.php).
 */
header nav {
    --mm-ink: #222b45;
    --mm-text: #37465a;
    --mm-muted: #5f6c7b;
    --mm-blue: #009dff;
    --mm-blue-dark: #007ecc;
    --mm-name: #0b3c87;
    --mm-line: #e6edf3;
    --mm-soft: #f3f7f9;
}

/* ---------- Comunes (desktop y móvil) ---------- */
header nav ul li .mega-panel .mega-inner,
header nav ul li .mega-panel .mega-col {
    text-align: left;
}

header nav ul li .mega-panel .mega-heading {
    margin: 0 0 12px;
    padding: 0;
    color: var(--mm-ink);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.3;
}

header nav ul li .mega-panel a.mega-link {
    display: block;
    width: auto;
    margin: 0 -12px 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: transparent;
    color: var(--mm-name);
    text-align: left;
    text-decoration: none;
    transition: background-color .15s ease;
}

header nav ul li .mega-panel a.mega-link:hover,
header nav ul li .mega-panel a.mega-link:focus {
    background: var(--mm-soft);
    color: var(--mm-name);
    text-decoration: none;
}

header nav ul li .mega-panel a.mega-link span {
    margin: 0;
    float: none;
    cursor: pointer;
}

header nav ul li .mega-panel a.mega-link .mega-name {
    display: block;
    color: var(--mm-name);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    transition: color .15s ease;
}

header nav ul li .mega-panel a.mega-link:hover .mega-name,
header nav ul li .mega-panel a.mega-link:focus .mega-name {
    color: var(--mm-blue);
}

header nav ul li .mega-panel a.mega-link .mega-desc {
    display: block;
    margin-top: 3px;
    color: var(--mm-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.45;
}

/* Etiqueta NEW junto al nombre (mismo naranja del sitio, sin pulso dentro del panel) */
header nav ul li .mega-panel .mega-name .new-badge {
    margin-left: 6px;
    padding: 3px 6px;
    vertical-align: 2px;
    font-size: 9px;
    letter-spacing: .02em;
    animation: none;
    box-shadow: none;
}

/* Chevron (reemplaza el triángulo del menú anterior) */
header nav ul li.mega-item > a .caret {
    display: inline-block;
    position: relative;
    top: -2px;
    width: 7px;
    height: 7px;
    margin: 0 0 0 9px;
    border: 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    font-size: 0;
    line-height: 0;
    vertical-align: middle;
    opacity: .85;
    transform: rotate(45deg);
    transition: transform .2s ease, top .2s ease;
}

header nav ul li.mega-item > a .caret:before {
    content: none;
    display: none;
}

header nav ul li.mega-item.is-open > a .caret {
    top: 1px;
    transform: rotate(-135deg);
}

/* ---------- Desktop ---------- */
@media (min-width: 993px) {
    /* El panel ancho se posiciona contra el nav (ancho completo) */
    header nav:not(.affix) {
        position: relative;
    }

    header nav .col-md-8 {
        position: static;
    }

    header nav ul.derecha > li.mega-item.mega-wide {
        position: static;
    }

    header nav ul.derecha > li.mega-item.mega-simple {
        position: relative;
    }

    header nav ul li.mega-item > a {
        transition: color .15s ease, box-shadow .15s ease;
    }

    /* Item activo: azul + barra inferior */
    header nav ul li.mega-item:hover > a,
    header nav ul li.mega-item.is-open > a {
        color: var(--mm-blue);
        box-shadow: inset 0 -3px 0 var(--mm-blue);
    }

    header nav ul li.mega-item > .mega-panel {
        display: none;
        position: absolute;
        z-index: 1100;
        width: auto;
        margin: 0;
        padding: 0;
        background: #fff;
        overflow: visible;
    }

    header nav ul li.mega-item:hover > .mega-panel,
    header nav ul li.mega-item.is-open > .mega-panel {
        display: block;
        animation: mm-in .16s ease-out;
    }

    /* Puente invisible para no perder el hover entre el item y el panel */
    header nav ul li.mega-item > .mega-panel:before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: -18px;
        height: 18px;
    }

    /* Panel ancho */
    header nav ul li.mega-item.mega-wide > .mega-panel {
        left: 0;
        right: 0;
        top: 100%;
        border-top: 1px solid var(--mm-line);
        box-shadow: 0 30px 40px -20px rgba(34, 43, 69, .25);
    }

    header nav ul li.mega-wide .mega-inner {
        display: grid;
        /* Columnas de ancho fijo alineadas a la izquierda: todos los paneles arrancan en el mismo punto */
        grid-template-columns: repeat(var(--mm-cols, 5), minmax(0, 196px));
        justify-content: start;
        column-gap: 44px;
        row-gap: 24px;
        box-sizing: border-box;
        max-width: 1240px;
        margin: 0 auto;
        padding: 36px 48px 42px;
    }

    header nav ul li.mega-wide .mega-inner.mega-cols-1 { --mm-cols: 1; }
    header nav ul li.mega-wide .mega-inner.mega-cols-2 { --mm-cols: 2; }
    header nav ul li.mega-wide .mega-inner.mega-cols-3 { --mm-cols: 3; }
    header nav ul li.mega-wide .mega-inner.mega-cols-4 { --mm-cols: 4; }
    header nav ul li.mega-wide .mega-inner.mega-cols-5 { --mm-cols: 5; }
    header nav ul li.mega-wide .mega-inner.mega-cols-6 { --mm-cols: 6; }

    /* Dropdown simple (Soporte, Contacto) */
    header nav ul li.mega-item.mega-simple > .mega-panel {
        top: 100%;
        left: 0;
        width: 360px;
        max-width: 90vw;
        margin-top: 9px;
        padding: 10px;
        box-sizing: border-box;
        border: 1px solid var(--mm-line);
        border-radius: 0 0 16px 16px;
        box-shadow: 0 22px 40px -16px rgba(34, 43, 69, .25);
    }

    header nav ul li.mega-item.mega-simple.mega-align-right > .mega-panel {
        left: auto;
        right: 0;
    }

    header nav ul li.mega-simple .mega-inner {
        display: block;
        padding: 0;
    }

    header nav ul li.mega-simple .mega-panel a.mega-link {
        margin: 0;
        padding: 12px 14px;
    }
}

@keyframes mm-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Móvil / tablet (cajón a ancho completo) ---------- */
/*
 * Estas reglas pisan las de style-navegacion.css (ancho 50/60/80%, top: 10%,
 * font-size: .8em y padding: 25px de los breakpoints de 1100px). El cajón
 * queda a 100% bajo la barra del logo, con Inicio visible y tipografía legible.
 */
@media (max-width: 992px) {
    html.is-menu-open,
    body.is-menu-open {
        overflow: hidden;
        overscroll-behavior: none;
    }

    body.is-menu-open {
        position: fixed;
        width: 100%;
        left: 0;
        right: 0;
    }

    .menu_bar {
        z-index: 100060;
    }

    /* Hamburguesa → X en acento azul, sin el glifo icomoon */
    .menu_bar .icon-menu {
        position: absolute;
        top: 0;
        right: 4px;
        bottom: 0;
        z-index: 100070;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        width: 48px;
        height: auto;
        margin: 0;
        padding: 0;
        float: none;
        overflow: visible;
        color: var(--mm-blue, #009dff);
        font-size: 0 !important;
        line-height: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .menu_bar .icon-menu:before,
    .menu_bar .icon-menu:after {
        content: "" !important;
        font-family: inherit !important;
        position: absolute;
        left: 12px;
        width: 22px;
        height: 2px;
        border: 0;
        border-radius: 2px;
        background: var(--mm-blue, #009dff);
        speak: none;
        transition: transform .2s ease, top .2s ease, box-shadow .2s ease, opacity .2s ease;
    }

    .menu_bar .icon-menu:before {
        top: 50%;
        margin-top: -7px;
        box-shadow: 0 6px 0 var(--mm-blue, #009dff);
    }

    .menu_bar .icon-menu:after {
        top: 50%;
        margin-top: 5px;
    }

    body.is-menu-open .menu_bar .icon-menu:before,
    .menu_bar .icon-menu.is-open:before {
        margin-top: -1px;
        box-shadow: none;
        transform: rotate(45deg);
    }

    body.is-menu-open .menu_bar .icon-menu:after,
    .menu_bar .icon-menu.is-open:after {
        margin-top: -1px;
        transform: rotate(-45deg);
    }

    /* Cajón blanco a todo el ancho, debajo de la barra del logo.
       !important para ganar a style-navegacion.css y a los top/width inline de affix. */
    header nav#barra,
    header nav#barra.affix {
        position: fixed !important;
        top: var(--mm-bar-h, 72px) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-height: none;
        margin: 0 !important;
        padding: 0;
        background: #fff;
        border-bottom: 0;
        box-shadow: none;
        z-index: 100050;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        transform: translateX(-100%);
        visibility: hidden;
        pointer-events: none;
        transition: transform .28s ease, visibility 0s linear .28s;
    }

    body.is-menu-open header nav#barra,
    body.is-menu-open header nav#barra.affix {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        transition: transform .28s ease, visibility 0s linear 0s;
    }

    /* Anula el grid de Bootstrap y el padding de 5em que dejaba el CSS de escritorio */
    header nav .container,
    header nav .container-fluid {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    header nav .row {
        margin: 0;
    }

    header nav .col-md-4,
    header nav .col-md-8,
    header nav [class*="col-"] {
        width: 100%;
        float: none;
        padding: 0;
        text-align: left !important;
    }

    header nav .logo {
        display: none;
    }

    header nav ul.derecha {
        float: none;
        width: 100%;
        margin: 0;
        padding: 4px 0 32px;
        text-align: left;
    }

    header nav ul.derecha > li {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
        float: none;
        text-align: left;
        border-bottom: 1px solid var(--mm-line, #e6edf3);
    }

    /* Ítems de primer nivel (incluido Inicio y Calendario): 16px / 600 / #222b45 */
    header nav ul.derecha > li > a,
    header nav ul.derecha > li.mega-item > a,
    header nav ul.derecha > li.mega-item > a.menu-item-with-badge {
        display: flex;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
        margin: 0;
        padding: 14px 20px;
        color: var(--mm-ink, #222b45);
        font-size: 16px;
        font-weight: 600;
        line-height: 1.3;
        text-align: left;
        text-decoration: none;
        box-shadow: none;
    }

    header nav ul.derecha > li > a:hover,
    header nav ul.derecha > li > a:focus,
    header nav ul.derecha > li.mega-item > a:hover,
    header nav ul.derecha > li.mega-item > a:focus,
    header nav ul.derecha > li.mega-item.is-open > a {
        color: var(--mm-blue, #009dff);
        background: transparent;
        text-decoration: none;
        box-shadow: none;
    }

    /* Oculta el icono de casa que desplazaba o recortaba la etiqueta Inicio */
    header nav ul.derecha > li > a .icon-house {
        display: none;
    }

    /* NEW junto a la etiqueta, más chico, ya no en esquina absoluta */
    header nav ul li.mega-item > a .new-badge-corner {
        position: static;
        top: auto;
        right: auto;
        display: inline-block;
        flex: 0 0 auto;
        margin: 0 0 0 8px;
        padding: 2px 6px;
        border-radius: 6px;
        font-size: 8px;
        font-weight: 700;
        line-height: 1.2;
        letter-spacing: .02em;
        animation: none;
        box-shadow: none;
        vertical-align: middle;
    }

    header nav ul li.mega-item > a .caret {
        position: relative;
        top: -1px;
        float: none;
        flex: 0 0 auto;
        width: 8px;
        height: 8px;
        margin: 0 0 0 auto;
        opacity: .7;
    }

    header nav ul li.mega-item.is-open > a .caret {
        top: 2px;
        margin-left: auto;
    }

    /* El panel lo muestra/oculta navegacion.js con slideToggle (display inline) */
    header nav ul li.mega-item > .mega-panel {
        display: none;
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        width: 100%;
        margin: 0;
        padding: 0 0 10px;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
        animation: none;
        transform: none;
    }

    header nav ul li .mega-panel .mega-inner {
        display: block;
        max-width: none;
        margin: 0;
        padding: 0 12px 4px 12px;
    }

    header nav ul li .mega-panel .mega-heading {
        margin: 10px 0 2px 20px;
        padding: 0;
        color: #8190a1;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
    }

    header nav ul li .mega-panel a.mega-link {
        margin: 0;
        padding: 8px 20px 8px 20px;
        border-radius: 0;
        background: transparent;
    }

    header nav ul li .mega-panel a.mega-link .mega-name {
        font-size: 15px;
        font-weight: 600;
    }

    /* En el menú móvil solo se muestran las listas, sin descripciones */
    header nav ul li .mega-panel a.mega-link .mega-desc {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    header nav ul li.mega-item:hover > .mega-panel,
    header nav ul li.mega-item.is-open > .mega-panel {
        animation: none;
    }
    header nav ul li.mega-item > a .caret {
        transition: none;
    }
    .menu_bar .icon-menu:before,
    .menu_bar .icon-menu:after,
    header nav#barra,
    header nav#barra.affix,
    body.is-menu-open header nav#barra,
    body.is-menu-open header nav#barra.affix {
        transition: none;
    }
}
