
/* ==========================================
   Nested Mega Menu
   ========================================== */

/* Base styles */
header .menu-sub-item {
    position: relative;
    min-width: 0;
}

header .menu-sub-item-header {
    display: flex;
    align-items: center;
}

header .menu-sub-item-header > .dropdown-item {
    flex: 1;
    min-width: 0;
    width: auto;
    white-space: normal;
}

/* Submenu toggle */
header .menu-sub-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

header .menu-sub-toggle::after {
    content: "";
    display: block;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
}

header .menu-sub-children {
    display: none;
}

/* ==========================================
   Desktop: Full-width nested mega menu
   ========================================== */

@media (min-width: 992px) {

    /* Positioning */
    header .navbar {
        position: relative;
    }

    header .menu-sub-item {
        position: static;
    }

    /* Open nested menus on hover/focus */
    header .menu-sub-item.has-children:hover > .menu-sub-children,
    header .menu-sub-item.has-children:focus-within > .menu-sub-children,
    header .nav-item.active .menu-sub-item.has-children.is-open > .menu-sub-children {
        display: flex;
    }

    /* Full-width submenu */
    header .menu-sub-children {
        position: absolute;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 1050;

        align-items: center;
        justify-content: center;
        flex-wrap: wrap;

        padding: 15px 0;
        background: #F4F7FB;
        box-shadow: none;
    }

    /* First nested level: original dropdown padding */
    header .dropdown-menu > .menu-sub-item > .menu-sub-children {
        transform: translateY(20px);
    }

    header .dropdown-menu > .menu-sub-item > .menu-sub-children::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: -20px;
        height: 20px;
        background: transparent;
    }

    /* All deeper levels */
    header .menu-sub-children .menu-sub-children {
        transform: translateY(15px);
        background: #EAF0F8;
    }

    header .menu-sub-children .menu-sub-children::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: -15px;
        height: 15px;
        background: transparent;
    }

    /* Nested menu items */
    header .menu-sub-children .menu-sub-item {
        width: auto;
    }

    header .menu-sub-children .menu-sub-item-header {
        width: auto;
    }

    header .menu-sub-children .dropdown-item {
        width: auto;
        white-space: nowrap;
    }

    /* Desktop arrows */
    header .menu-sub-toggle::after {
        transform: rotate(45deg);
    }
}

/* ==========================================
   Mobile: Nested accordion
   ========================================== */

@media (max-width: 991.98px) {

    header .menu-sub-item {
        width: 100%;
    }

    header .menu-sub-item-header {
        width: 100%;
    }

    /* Toggle button */
    header .menu-sub-toggle {
        margin-left: auto;
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
        color: #fff;
    }

    /* Closed: right arrow */
    header .menu-sub-toggle::after {
        width: 9px;
        height: 9px;
        border-right: 3px solid currentColor;
        border-bottom: 3px solid currentColor;
        transform: rotate(-45deg);
    }

    /* Open: down arrow */
    header .menu-sub-toggle[aria-expanded="true"]::after {
        transform: rotate(45deg);
    }

    /* Expanded submenu */
    header .menu-sub-item.is-open > .menu-sub-children {
        display: block;
    }

    header .menu-sub-children {
        position: static;
        padding-left: 16px;
        box-shadow: none;
        background: transparent;
    }
}


/* Highlight ancestors of the active menu item */
header .menu-sub-item-header > .dropdown-item.active-parent {
    color: #23527c;
    font-weight: 700;
}

/* Highlight the active menu item */
header .menu-sub-item-header > .dropdown-item.active {
    font-weight: 700;
}
