/* === SUPER MENU === */
#supermenu {
    display: none;
    position: fixed;
    top: calc(var(--header-height, 120px));
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--header-height, 120px));
    background: var(--white);
    z-index: 1000;
    overflow-y: auto; scrollbar-width: none; /* Firefox */ -ms-overflow-style: none;  /* Internet Explorer 10+ */
    box-sizing: border-box;
    padding: 20px 50px;
}

/* Стили для каталога меню */
.catalog-menu {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    padding: 0;
    margin: 0;
}

/* Базовые настройки для всех меню */
.menu-level {
    position: relative; 
    list-style: none; 
    padding: 0; 
    margin: 0;
    box-sizing: border-box;
    overflow-y: auto; scrollbar-width: none; /* Firefox */ -ms-overflow-style: none;  /* Internet Explorer 10+ */
}

/* Десктопные стили для подуровней */
.menu-level:not(.menu-root) {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
}

.menu-level:not(.menu-root).menu-level--visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0s;
}

.menu-root {
    height: calc(100% - 40px);
    flex-shrink: 0; 
    background-color: var(--main-grey); 
    border-radius: 10px;
    padding: 20px 0 20px 20px;
}

/* Все пункты меню */
.menu-item {
    position: relative;
}
    
/* Ссылки в меню */
.menu-item a {
    display: block;
    padding: 8px 20px;
    font-size: 15px;
}

/* Особые стили для первого уровня */
.menu-root > .menu-item {
    background: url(../img/arrow-right-small.png) no-repeat calc(100% - 20px) 50%;
    background-size: auto 14px;
}

.menu-root > .menu-item > a {
    font-size: 18px;
    font-weight: 400;
    padding: 10px 0 10px 10px;
    background: none;
}

.menu-root > .menu-item.active  {
    border-radius: 10px 0 0 10px;
    background-color: #fff;
}

.menu-link--root {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    padding: 12px 72px 12px 20px;
    color: var(--main-black);
    width: 100%;
}

.menu-link__image {
    width: 30px;
    height: 38px;
    background: var(--main-grey);
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.menu-link__image img {
    width: 100%;
    height: 100%;
    display: block;
}

.menu-link__image--placeholder {
    border: 1px solid #e5e5e5;
}

.menu-link__text {
    display: block;
    line-height: 1.3;
    font-weight: 500;
}

/* Стрелки для подпунктов */
.menu-item .menu-item.has-children {
    background: url(../img/arrow-right-small.png) no-repeat calc(100% - 10px) 50%;
    background-size: auto 14px;
    border-radius: var(--main-radius);
}

/* Базовое позиционирование подменю */
.menu-item .menu-level {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    z-index: 100;
    border-right: 1px solid #eee;
    box-sizing: border-box;
    padding: 0 20px;
    height: auto;
}

/* Фиксированное позиционирование для десктопа */
.menu-root > .menu-item > .menu-level,
.menu-root > .menu-item > .menu-level .menu-level {
    position: fixed;
    top: 0;
    margin-top: 0;
    padding-top: 0;
    height: auto;
    border-right: 1px solid #D0D0D0;
    width: 290px;
    box-sizing: border-box;
}

/* Показ подменю при наведении (НЕ ТРОГАЕМ - ДЛЯ ДЕСКТОПА) */
.menu-item.has-children:hover > .menu-level,
.menu-item.has-children.active > .menu-level {
    display: block;
}

/* Активные состояния (НЕ ТРОГАЕМ - ДЛЯ ДЕСКТОПА) */
.menu-item .menu-item.active {
    background: url(../img/arrow-right-small.png) no-repeat calc(100% - 10px) 50%;
    background-size: auto 14px;
    background-color: var(--main-grey);
}

/* Z-index для десктопа (НЕ ТРОГАЕМ) */
.menu-root > .menu-item > .menu-level {z-index: 101;}
.menu-root > .menu-item > .menu-level > .menu-item > .menu-level {z-index: 102;}
.menu-root > .menu-item > .menu-level > .menu-item > .menu-level > .menu-item > .menu-level {z-index: 103;}

/* Контейнер заголовка */
#supermenu-active-title-container {
    position: absolute;
    z-index: 105;
    display: none;
    padding-bottom: 15px;
    box-sizing: border-box;
}
#supermenu-active-title-text {
    font-size: 40px; 
    font-weight: 700;
    color: var(--main-black);
    line-height: normal;
    margin: 28px 0 10px 40px;
    padding: 0;
}

/* МОБИЛЬНЫЕ СТИЛИ */
@media (max-width: 800px) {
    /* Контейнер мобильного меню */
    #mobile-menu-container {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        background: var(--white);
        z-index: 9999;
        padding: 20px 0 20px 0;
        box-sizing: border-box;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }

    /* Шапка мобильного меню */
    .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        padding: 0 20px 20px 20px;
    }

    /* Кнопка закрытия */
    .mobile-close-button {
        margin-left: auto;
        padding: 10px 15px;
        background: var(--main-orange);
        font-weight: 700;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        cursor: pointer;
    }

    /* Кнопка назад */
    .mobile-back-button {
        padding: 10px 16px;
        background: var(--main-grey);
        border: none;
        border-radius: 10px;
        font-size: 16px;
        font-weight: 500;
        cursor: pointer;
        color: var(--main-black);
        flex-shrink: 0;
    }

    /* Заголовок уровня */
    .mobile-level-title {
        margin: 0 20px 20px 20px;
        font-size: 24px;
        font-weight: 700;
        color: var(--main-black);
        padding-bottom: 15px;
        border-bottom: 2px solid var(--main-grey);
    }

    .mobile-menu-search {
        position: relative;
        padding: 0 20px 16px 20px;
        box-sizing: border-box;
    }

    .mobile-menu-search .header__search {
        width: 100%;
        position: relative;
    }

    .mobile-menu-search .header__search-input {
        width: 100%;
    }

    /* Первый экран мобильного меню */
    .mobile-menu-body {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 0 20px 60px 20px;
    }

    .mobile-menu-profile {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        padding: 8px 0;
        color: var(--main-black);
        font-size: 18px;
        font-weight: 600;
        text-decoration: none;
    }

    .mobile-menu-profile img {
        width: 20px;
        height: 20px;
        display: block;
    }

    .mobile-menu-list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-menu-item {
        list-style: none;
    }

    .mobile-menu-item + .mobile-menu-item--divider,
    .mobile-menu-item--divider {
        border-top: 1px solid #ccc;
        padding-top: 16px;
        margin-top: 8px;
    }

    .mobile-menu-link {
        display: block;
        width: 100%;
        text-align: left;
        padding: 8px 16px;
        border-radius: 10px;
        color: var(--main-black);
        font-size: 18px;
        font-weight: 500;
        text-decoration: none;
        border: none;
        cursor: pointer;
        box-sizing: border-box;
    }

    .mobile-menu-link--catalog {
        position: relative;
        padding: 16px 16px;
        padding-right: 46px;
        font-family: Montserrat, sans-serif;
        background: var(--main-grey);
    }

    .mobile-menu-link--catalog::after {
        content: '';
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        width: 14px;
        height: 14px;
        background-image: url(../img/arrow-right-small.png);
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
    }

    .mobile-menu-link:active {
        transform: scale(0.99);
        transition: transform 0.1s ease;
    }

    .mobile-menu-contacts {
        background: #f8f8f8;
        border-radius: 12px;
        padding: 16px;
        box-sizing: border-box;
    }

    .mobile-menu-contacts__title {
        font-size: 16px;
        font-weight: 700;
        margin-bottom: 8px;
        color: var(--main-black);
    }

    .mobile-menu-contacts__body {
        font-size: 14px;
        line-height: 1.5;
        color: var(--main-black);
    }

    .mobile-menu-contacts__cta {
        margin-top: 12px;
        width: 100%;
        padding: 12px 16px;
        border: none;
        border-radius: 10px;
        background: var(--main-orange);
        color: #fff;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
    }

    /* Мобильный корневой уровень */
    .mobile-menu-root {
        padding: 0 20px;
        background: none;
        border-radius: 0;
        height: auto;
        list-style: none;
    }

    /* Мобильные пункты первого уровня - наследуют иконки */
    .mobile-menu-root .menu-item {
        margin-bottom: 2px;
        border-radius: 10px;
        background-color: var(--main-grey);
        list-style: none;
    }

    .mobile-menu-root .menu-item > a {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 12px;
        padding: 18px 60px 18px 16px;
        font-size: 18px;
        font-weight: 500;
        color: var(--main-black);
        text-decoration: none;
        border-radius: 10px;
    }

    /* Стрелки для корневых элементов с подменю */
    .mobile-menu-root .menu-item.has-children > a {
        padding-right: 50px;
        position: relative;
    }

    .mobile-menu-root .menu-item.has-children > a::after {
        content: '';
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        width: 14px;
        height: 14px;
        background-image: url(../img/arrow-right-small.png);
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        transition: opacity 0.2s ease;
    }

    /* Визуальная область для клика по стрелке */
    .mobile-menu-root .menu-item.has-children > a::before {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 60px;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 0 10px 10px 0;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .mobile-menu-root .menu-item.has-children > a:active::before {
        opacity: 1;
    }

    .mobile-submenu .menu-item.has-children > a {
        position: relative;
    }

    /* Аналогично для подуровней */
    .mobile-submenu .menu-item.has-children > a::before {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 50px;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 0 8px 8px 0;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .mobile-submenu .menu-item.has-children > a:active::before {
        opacity: 1;
    }

    .mobile-menu-root .menu-link__image {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    /* Мобильные подуровни */
    .mobile-submenu {
        padding: 0 20px;
        background: none;
        list-style: none;
    }

    .mobile-submenu .menu-item {
        margin-bottom: 2px;
        background: none;
        border-radius: 8px;
        list-style: none;
    }

    .mobile-submenu .menu-item > a {
        display: block;
        padding: 15px 20px;
        font-size: 16px;
        color: var(--main-black);
        text-decoration: none;
        background: #f8f8f8;
        border-radius: 8px;
    }

    .mobile-submenu .menu-item.has-children > a {
        background-image: url(../img/arrow-right-small.png);
        background-repeat: no-repeat;
        background-position: calc(100% - 15px) 50%;
        background-size: 12px auto;
        background-color: #f8f8f8;
        padding-right: 40px;
    }

    /* Активные состояния для мобильной версии */
    .mobile-menu-root .menu-item:active,
    .mobile-submenu .menu-item:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

@media (max-width: 800px) {
    html.mobile-menu-open,
    body.mobile-menu-open {
        overscroll-behavior-y: none;
    }
}
