/* =============================================================================
 * KS-Semilla Nutriente: NtMultiLevelMenu - nt-multi-level-menu.css
 * -----------------------------------------------------------------------------
 * Stylesheet for the Multi-Level Menu Nutrient.
 *
 * Method: Mobile-First
 * - Base styles create a vertical, accordion-style menu for mobile devices.
 * - A min-width media query at the bottom overrides these styles to create
 * a horizontal, hover-triggered dropdown menu for desktop.
 * ============================================================================= */

 /* --- 1. Mobile Styles (Default - Accordion Behavior) --- */

.nt-multi-level-menu {
    width: 100%;
}

.nt-main-menu__list--level-1 {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.nt-main-menu__item {
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* This new rule forces the link and the arrow onto the same line */
.nt-main-menu__item.has-children {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allows the submenu <ul> to wrap to the next line */
}

.nt-main-menu__link,
.nt-main-menu__submenu-toggle {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

.nt-main-menu__link {
    padding: 1.5rem 0 1.5rem 2rem;  
}

.nt-main-menu__item.has-children > .nt-main-menu__link {
    flex-grow: 1;
}

.nt-main-menu__link--toggle,
.nt-main-menu__link--link {
    color: #fff;
 }

.nt-main-menu__submenu-toggle {
    cursor: pointer;
    padding: 1.5rem 2rem;  
}

.is-toggle-only {
    cursor: pointer;
    justify-content: space-between;
    width: 100%; /* Make it take the full width */
    padding: 1.5rem 2.1rem 1.5rem 0;
}

/* Submenu Lists */
.nt-main-menu__item .nt-main-menu__list--level-2 {
    list-style: none;
    padding-left: 2rem;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    width: 100%; /* Ensure it takes full width inside the flex container */
}

/* New styles for Level 3 items, as per your design decision */
.nt-main-menu__list--level-2 .nt-main-menu__list--level-2 {
    padding-left: 0; /* Remove extra indentation */
    
    border-top: 1px solid rgba(255, 255, 255, 0.05); /* Top separator line */
}

/* Adjust padding for Level 3 links */
.nt-main-menu__list--level-2 .nt-main-menu__list--level-2 .nt-main-menu__link {
    padding-left: 3rem; /* Still provide some indentation for clarity */
}

.nt-main-menu__item.is-open > .nt-main-menu__list--level-2 {
    max-height: 1000px;
}


/* --- 2. Desktop Styles (min-width: 1024px - Dropdown Behavior) --- */

@media (min-width: 1024px) {

    .nt-main-menu__list--level-1 {
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
    }

    .nt-main-menu__item {
        border-bottom: none;
    }

    .nt-main-menu__item.has-children {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .nt-main-menu__link,
    .is-toggle-only {
        padding: 2rem 1.5rem;
        display: flex;
        align-items: center;
    }

    .nt-main-menu__link--toggle,
    .nt-main-menu__link--link {
        color: #0A7EF5;
     }

    .nt-main-menu__submenu-toggle {
        display: flex;
        align-items: center;
        padding: 0;
        margin-left: 0.7rem;
        margin-right: 2.1rem;
    }

    .nt-main-menu__item.has-children .ks-chevron-down {
        opacity: 0.7;
        font-size: 0.9em;
        transition: transform 0.2s ease;
    }
    
    .nt-main-menu__item:hover > .is-toggle-only .ks-chevron-down,
    .nt-main-menu__item:hover > .nt-main-menu__submenu-toggle .ks-chevron-down {
        transform: rotate(180deg);
    }
    
    .nt-main-menu__list--level-2 .nt-main-menu__item {
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .nt-main-menu__list--level-2 .nt-main-menu__item:last-child {
        border-bottom: none;
    }

    .nt-main-menu__item .nt-main-menu__list--level-2 {
        position: absolute;
        top: 100%;
        left: 0;
        background-color: #fff;
        border: 1px solid rgba(0, 0, 0, 0.1);
        padding-left: 0;
        min-width: 24rem;
        z-index: 1000;
        width: auto;
        visibility: hidden;
        opacity: 0;
        max-height: none;
        overflow: visible;
    }
    
    /*
     * New class for accessibility: forces a submenu to be visible
     * for keyboard navigation, overriding the default hidden state.
     */
    .nt-main-menu__list--level-2.is-a11y-open {
        visibility: visible;
        opacity: 1;
    }
    
    .nt-main-menu__item:hover > .nt-main-menu__list--level-2 {
        visibility: visible;
        opacity: 1;
    }

    /*
     * --------------------------------------------------------------
     * SUBMENU BEHAVIOR CONFIGURATION (LEVEL 3+)
     * --------------------------------------------------------------
     * Choose ONE of the two options below. Uncomment the block you
     * want to use and make sure the other is commented out.
     * --------------------------------------------------------------
     */

    /* --- OPTION A: Flyout Menu --- */
    /* This is the classic style. It may show a slight flicker when 
       moving the mouse between items if not handled carefully. */

    /*
    .nt-main-menu__list--level-2 .nt-main-menu__list--level-2 {
        padding-left: 0;
        background-color: #fff;
        border-top: none;
        top: 0;
        left: 100%;
    }
    */


    /* --- OPTION B: Vertical Dropdown Menu (Accordion Style) --- */
    /* This style is 100% robust and never fails. The submenu expands
       downward within the parent menu. This is the recommended option. */

    .nt-main-menu__list--level-2 > .nt-main-menu__item:hover > .nt-main-menu__list--level-2 {
        position: static;
        visibility: visible;
        opacity: 1;
        width: 100%;
        border: none;
        box-shadow: none;
        max-height: 1000px; 
        transition: max-height 0.3s ease-in-out;
        
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        background-color: rgba(0, 0, 0, 0.02);
    }

    .nt-main-menu__list--level-2 .nt-main-menu__list--level-2 {
         max-height: 0; 
         overflow: hidden;
         transition: max-height 0.3s ease-in-out;
         width: 100%;
    }
    
}