/* Simple Menu Styles - Nested Structure */

/* Main menu container */
.main-menu {
    display: flex;
    gap: 0;
    align-items: center;
    flex-wrap: wrap;
}

/* Menu separator - only visible on desktop */
.menu-separator {
    display: none;
    color: rgba(3, 47, 86, 1);
    padding: 0 10px;
    font-size: 16px;
    font-weight: 400;
}

/* Menu item */
.menu-item {
    position: relative;
    padding: 10px 10px;
    transition: background-color 0.3s ease;
}

.menu-item:hover {
    /*background-color: #f5f5f5;*/
}

/* Menu link */
.menu-link {
    color: rgba(3, 47, 86, 1);
    text-decoration: none;
    font-size: 16px;
    font-weight: 400;
    transition: color 0.3s ease;
    display: inline-block;
}

.menu-link:hover a {
    color: rgb(5, 38, 69);
}

/* Active state */
.menu-item.active > .menu-link {
    color: rgba(3, 47, 86, 1);
    font-weight: 700;
}

/* Has children indicator */
.menu-item.has-child > .menu-link::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 8px;
    margin-left: 8px;
    transition: transform 0.3s ease;
    vertical-align: middle;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg width="16" height="8" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.8198 0.167368C16.0601 0.390524 16.0601 0.752333 15.8198 0.97549L8.43514 7.83263C8.19482 8.05579 7.80518 8.05579 7.56486 7.83263L0.180242 0.97549C-0.0600815 0.752333 -0.0600815 0.390524 0.180242 0.167368C0.420565 -0.0557892 0.810204 -0.0557892 1.05053 0.167368L8 6.62045L14.9495 0.167368C15.1898 -0.0557892 15.5794 -0.0557892 15.8198 0.167368Z" fill="%23333333"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.menu-item.has-child.menu-open > .menu-link::after {
    transform: rotate(180deg);
}

.menu-item.menu-item-level-1 a{
    padding: 10px 10px;
    font-size: 16px;
    font-weight: 400;
    display: block;
}

.menu-item.menu-item-level-1.has-child.menu-open>a,
.menu-item.menu-item-level-1  a:hover{
    background: rgba(249, 247, 247, 1);
    border-radius: 18px;
    color: rgba(3, 47, 86, 1);
    font-weight: 700;
}

/* Submenu - nested inside menu-item */
.menu-item > .sub-menu {
    position: absolute;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    padding: 10px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
    display: none;
}


.menu-item > .sub-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    display: block;
    top: -11px;
}

/* Submenu items */
.sub-menu .menu-item {
    padding: 10px 20px;
    display: block;
    width: 100%;
    border-radius: 0;
}

.sub-menu .menu-item:hover {
    /*background-color: #f9f9f9;*/
}

.sub-menu .menu-link {
    font-size: 14px;
}


/* Desktop styles */
@media (min-width: 992px) {


    .main-menu {
        display: flex !important;
        position: relative;
    }

    /* Show menu separator on desktop */
    .menu-separator {
        display: block;
    }
    .sub-menu-level-1.active{
        border-left: none;

    }

    .sub-menu-level-2.active{
        border-left: none;
        left: 91%;
        box-shadow: none;
        border-radius: 0 44px 44px 0;

    }

    /* First level submenu positioning - opens below parent using fixed positioning */
    .main-menu > .menu-item > .sub-menu,
    .sub-menu-level-1 {
        position: fixed;
        top: auto;
        left: auto;
        display: block;
        padding: 10px 0;
        min-width: 220px;
        background: #fff;
    }

    /* Level 1 items - left column */
    .sub-menu-level-1 > .menu-item {
        position: relative;
        display: block;
        width: 100%;
        padding: 3px 20px;
        border-radius: 0;
        margin: 0;
    }

    /* Hover state for level 1 items */
    .sub-menu-level-1 > .menu-item:hover,
    .sub-menu-level-1 > .menu-item.menu-open {
        /*background-color: #f5f5f5;*/
    }

    /* Second level - positioned absolutely to the right of parent menu-item */
    .sub-menu-level-2 {
        position: absolute !important;
        top: 0;
        left: 100%;
        display: flex !important;
        flex-direction: column;
        min-width: 220px;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.2s ease, visibility 0.2s ease;
        background: #fff;
        padding: 10px 0;
        margin-left: 0;
        border-left: 1px solid #e0e0e0;
    }

    /* Show level 2 when it has active class */
    .sub-menu-level-2.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Items in level 2 submenu */
    .sub-menu-level-2 > .menu-item {
        display: block;
        padding: 5px 10px;
        border-radius: 0;
        margin: 0;
        width: 100%;
        position: static;
    }

    .sub-menu-level-2 > .menu-item:hover {
        /*background-color: #f9f9f9;*/
    }

    /* Arrow for level 1 items with children - points right */
    .sub-menu-level-1 > .menu-item.has-child > .menu-link::after {
        transform: rotate(-90deg);
    }

    /* When level 1 item is open, arrow points down */
    .sub-menu-level-1 > .menu-item.has-child.menu-open > .menu-link::after {
        transform: rotate(0deg);
    }

    /* Hide deeper levels on desktop */
    .sub-menu-level-3,
    .sub-menu-level-4,
    .sub-menu-level-5 {
        display: none;
    }
}

/* Mobile styles */
@media (max-width: 991px) {

    .mobile-menu-open nav.navbar{
        border-bottom: 1px solid rgba(217, 182, 115, 0.3);
    }
    .mobile-menu-open .mobile-contacts{
        border-top: 1px solid rgba(217, 182, 115, 0.3);
    }
    #primary-menu {
        width: 100%;
    }

    .wrap-navbar:before {
        left: calc(var(--w-minus) + 7px);
        box-shadow: 20px -15px 0 white;
        transform: rotate(10deg);
    }
    .wrap-navbar:after {
        right: calc(var(--w-minus) + 7px);
        box-shadow: -20px -15px 0 white;
        transform: rotate(-10deg);
    }

    /* Expand wrap-navbar to 100% when menu is open */
    body.mobile-menu-open .wrap-navbar {
        width: 100% !important;
        max-width: 100% !important;
    }

    .menu-item-level-0.has-child .menu-item-header{
        margin-left: 0;

    }
    .menu-item-level-1.has-child .menu-item-header{
        padding: 0;
    }

    .menu-item-level-0.has-child>a,
    .menu-item-level-1>a,
    .menu-item-header
    {

        padding: 15px 10px;
        background: rgba(249, 247, 247, 1);
        border-radius: 30px;

    }

    .menu-item.menu-item-level-1 a{
        padding: 15px;
        display: inline-block;
        min-width: 50%;
    }
    .navbar-nav{
        .menu-item{
            a{
                font-size: 18px;
                font-weight: 400;
            }
        }

        .menu-open>.menu-item-header>a{
            font-weight: 700;
        }

    }



    .main-menu {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .menu-item {
        width: 100%;
        padding: 12px 20px;
        /*background: #f9f7f7;*/
        border-radius: 8px;
        margin: 0px 0;
        display: block;
    }

    /* Wrapper for link and arrow in one row */
    .menu-item-header {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .menu-item-header > .menu-link {
        /*flex: 1;*/
        display: block;
    }

    /* Hide the ::after arrow on mobile, we use real element instead */
    .menu-item.has-child > .menu-link::after,
    .menu-item-header > .menu-link::after {
        display: none !important;
    }

    /* Real arrow element for mobile */
    .submenu-arrow-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        cursor: pointer;
        flex-shrink: 0;
        background-image: url('data:image/svg+xml;charset=UTF-8,<svg width="16" height="8" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M15.8198 0.167368C16.0601 0.390524 16.0601 0.752333 15.8198 0.97549L8.43514 7.83263C8.19482 8.05579 7.80518 8.05579 7.56486 7.83263L0.180242 0.97549C-0.0600815 0.752333 -0.0600815 0.390524 0.180242 0.167368C0.420565 -0.0557892 0.810204 -0.0557892 1.05053 0.167368L8 6.62045L14.9495 0.167368C15.1898 -0.0557892 15.5794 -0.0557892 15.8198 0.167368Z" fill="%23333333"/></svg>');
        background-repeat: no-repeat;
        background-position: center;
        background-size: 16px 8px;
        transition: transform 0.3s ease;
    }

    /* Rotate arrow when menu is open - for all levels */
    .menu-item.menu-open>.menu-item-header  .submenu-arrow-toggle {
        transform: rotate(180deg) !important;
    }

    /* Specifically for nested menu items */
    .sub-menu .menu-item.menu-open .submenu-arrow-toggle {
        /*transform: rotate(180deg) !important;*/
    }


    /* For deeply nested levels */
    .sub-menu .sub-menu .menu-item.menu-open .menu-item-header > .submenu-arrow-toggle {
        /*transform: rotate(180deg) !important;*/
    }

    /* Submenu inside menu-item on mobile */
    .menu-item > .sub-menu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin-top: 10px !important;
        margin-left: 0px !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease;
        display: block !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        min-width: auto !important;
        min-height: auto !important;
    }

    .menu-item > .sub-menu.active {
        max-height: 2000px;
    }
    .sub-menu-level-1.sub-menu  .menu-item{
        padding-left: 0;
    }
    .sub-menu-level-1.sub-menu .menu-item-header{
        padding-left: 0;

    }

    .sub-menu .menu-item {
        /*background: #f0f0f0;*/
        margin: 0;
        padding: 10px 0;
    }

    .sub-menu.sub-menu-level-2 .menu-item{
        padding: 5px 0;
    }
    .sub-menu.sub-menu-level-2 .menu-item a{
        padding: 3px 5px;
    }

    .sub-menu:not(.active) {
        display: none!important;
    }

    /* Nested levels */
    .sub-menu .sub-menu .menu-item {
        /*background: #e8e8e8;*/
    }

    .sub-menu .sub-menu .sub-menu .menu-item {
        /*background: #e0e0e0;*/
    }

    /* Additional indent for nested submenus */
    .sub-menu .menu-item > .sub-menu {
        /*margin-left: 15px !important;*/
    }

    .navbar-collapse .navbar-nav {
        max-height: 90vh;
        overflow-y: auto;
        z-index: 9999;
        display: block;
    }
    .menu-item.has-child{
        padding-bottom: 0;
    }
}
