
:root {
    --header-menu-container-bg: #fff;
    --header-top-height: 2rem;
}

.header-top {
    --header-top-bg: var(--surface-1);
    --header-top-border: var(--border-light);
    width: 100%;
    z-index: 905;
    background-color: var(--header-top-bg);
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--header-top-border);
    position: relative;
}
.header-top > .container {
    display: flex;
    align-items: center;
    justify-content: end;
    height: var(--header-top-height);
    gap: 1rem;
}

@media (min-width: 991px) {
    .header-top {
        width: 100%;
        height: var(--header-top-height);
    }
}


.header-top__menu {
    --mega-menu-bg: var(--surface-1);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: nowrap;
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    background-color: var(--mega-menu-bg);
}

@media (max-width: 991px) {
    .header-top__menu {
        gap: 0;
        width: 100%;
        order: 2;
        padding: 0;
        overflow: visible;
        background: var(--mega-menu-bg);
        z-index: 1001;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
}


.header-top__right {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    flex-wrap: nowrap;
    list-style: none;
    padding: 0;
    margin: 0;
}

.header-top__item {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
}

.header-top__item.active {
    z-index: 10;
}

.header-top__button {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    background-color: transparent;
    color: var(--menu-item-color, inherit);
    font-size: 0.9rem;
    letter-spacing: 0.1px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-duration) var(--transition-timing);
    position: relative;
    white-space: nowrap;
    line-height: 1;
}

.header-top__button .avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    margin-right: 0.25rem;
}

.header-top__button a {
    color: var(--text-primary);
}

.header-top__button:hover {
    color: var(--menu-item-color-active);
}

.header-top__button:focus {
    outline: none;
}

.header-top__button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.header-top__item.active .header-top__button {
    color: var(--menu-item-color-active);
}

.header-top__label {
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.header-top__item .icon {
    color: var(--text-muted-700);
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    transition: color var(--transition-duration) var(--transition-timing);
}

.header-top__item .chevron {
    width: 1.1rem;
    height: 1.1rem;
    transition: transform 0.25s ease;
    border-radius: 50%;
}
.header-top__item.active .chevron {
    transform: rotate(180deg);
}
.header-top__item:hover .chevron {
    background-color: #f5f2ff;
}

.header-top__item.active .chevron {
    background-color: #f5f2ff;
}




/**/

/* HEADER MENU */

:root {
    --header-menu-container-bg: #fff;
    --header-menu-height: 3rem;
    --mega-menu-text-color: #333;
    --mega-menu-link-color: #666;
    --mega-menu-link-hover-color: #000;
    --mega-menu-title-color: #000;
    --mega-menu-divider-color: #f0f0f0;
    --mega-menu-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --transition-duration: 0.3s;
    --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
}

.header-nav {
    --header-nav-bg: var(--surface-1);
    --header-nav-border: var(--border-light);
    width: 100%;
    z-index: 905;
    background-color: var(--header-nav-bg);
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--header-nav-border);
    position: relative;
}
.header-nav > .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-menu-height);
    gap: 1rem;
}

@media (min-width: 991px) {
    .header-nav {
        width: 100%;
        height: var(--header-menu-height);
    }
}

/* HEADER MENU */

.header-nav__menu {
    --mega-menu-bg: var(--surface-1);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: nowrap;
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    background-color: var(--mega-menu-bg);
}

.header-nav__menu::-webkit-scrollbar {
    display: none;
}

.header-nav__menu-title {
    font-size: 0.85rem;
    padding: 0 1rem 0.5rem 1rem;
    color: var(--menu-title-color);
    letter-spacing: 1px;
}

.header-nav__item {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
}

.header-nav__item.active {
    z-index: 10;
}

/* ============================================ */
/* HEADER MENU HEADER (только на мобильном) */
/* ============================================ */

.header-nav__menu-header {
    display: none;
    width: 100%;
    list-style: none;
    padding: 1.5rem;
    margin: 0;
    border-bottom: 1px solid var(--mega-menu-divider-color);
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-nav__menu-header .header-nav__menu-title {
    padding: 0;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: 0;
}

.header-nav__menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: currentColor;
    flex-shrink: 0;
}

.header-nav__menu-close:hover {
    opacity: 0.7;
}

.header-nav__menu-close svg {
    width: 24px;
    height: 24px;
}

/* ============================================ */
/* HEADER MENU BUTTON */
/* ============================================ */

.header-nav__button {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    background-color: transparent;
    color: var(--menu-item-color, inherit);
    font-size: 0.9rem;
    letter-spacing: 0.1px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-duration) var(--transition-timing);
    position: relative;
    white-space: nowrap;
    line-height: 1;
}

.header-nav__button .avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    margin-right: 0.25rem;
}

.header-nav__button a {
    color: var(--text-primary);
}

.header-nav__button:hover {
    color: var(--menu-item-color-active);
}

.header-nav__button:focus {
    outline: none;
}

.header-nav__button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.header-nav__item.active .header-nav__button {
    color: var(--menu-item-color-active);
}

.header-nav__label {
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.header-nav__item .icon {
    color: var(--text-muted-700);
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    transition: color var(--transition-duration) var(--transition-timing);
}

.header-nav__item .chevron {
    width: 1.1rem;
    height: 1.1rem;
    transition: transform 0.25s ease;
    border-radius: 50%;
}
.header-nav__item.active .chevron {
    transform: rotate(180deg);
}
.header-nav__item:hover .chevron {
    background-color: #f5f2ff;
}

.header-nav__item.active .chevron {
    background-color: #f5f2ff;
}

/* ============================================ */
/* MENU TOGGLE BUTTON (только на мобильном) */
/* ============================================ */

.app-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 0.4rem;
    width: 2rem;
    height: 2rem;
    padding: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.app-menu-toggle span {
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: all var(--transition-duration) var(--transition-timing);
}

/* ============================================ */
/* MEGA MENU DROPDOWN STYLES */
/* ============================================ */

.mega-menu-dropdown {
    --menu-dropdown-bg: var(--surface-1);
    position: absolute;
    top: var(--header-menu-height);
    left: 0;
    right: 0;
    background: var(--menu-dropdown-bg);
    border-top: 1px solid var(--mega-menu-divider-color);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    transition: all var(--transition-duration) var(--transition-timing);
    pointer-events: none;
}

.mega-menu-dropdown.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;

    max-height: 100svh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ============================================ */
/* MEGA MENU HEADER (только на мобильном) */
/* ============================================ */

.mega-menu-header {
    display: none;
    padding: 1.5rem;
    border-bottom: 1px solid var(--mega-menu-divider-color);
}

.mega-menu-back {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: currentColor;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    transition: opacity var(--transition-duration) var(--transition-timing);
}

.mega-menu-back:hover {
    opacity: 0.7;
}

.mega-menu-back svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.mega-menu-back span {
    flex: 1;
    text-align: left;
}

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: 2.25rem;
    padding: 3rem 0;
}

.mega-menu-column {
    /*padding: 0 1rem;*/
}

.mega-menu-column-title {
    font-size: 0.85rem;
    font-weight: 400;
    color: #999;
    padding-bottom: 0.75rem;
}

/**/

.mega-menu-main-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mega-menu-main-item {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.mega-menu-main-item a {
    display: block;
    color: #000;
    text-decoration: none;
    transition: color var(--transition-duration) var(--transition-timing);
    position: relative;
}
.mega-menu-main-item a:hover {
    color: #222;
    text-decoration: underline;
}

/**/

.mega-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mega-menu-item {
    margin: 0;
}

.mega-menu-item a {
    display: block;
    font-size: 0.875rem;
    color: var(--mega-menu-link-color);
    text-decoration: none;
    transition: color var(--transition-duration) var(--transition-timing);
    position: relative;
}

.mega-menu-item a:hover {
    color: var(--mega-menu-link-hover-color);
}

.mega-menu-banner {
    /*  grid-column: 1 / -1;*/
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
    padding: 2rem;
    border-radius: 0.5rem;
    text-align: center;
}

.mega-menu-banner-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.mega-menu-banner-text {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 1rem;
}

.mega-menu-banner-link {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #000;
    color: #fff;
    text-decoration: none;
    border-radius: 0.3rem;
    transition: background var(--transition-duration) var(--transition-timing);
}

.mega-menu-banner-link:hover {
    background: #333;
}

/* ============================================ */
/* MOBILE STYLES */
/* ============================================ */

@media (max-width: 991px) {
    .header-nav {
        display: none;
        position: fixed;
        top: var(--header-height);;
        left: 0;
        right: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        max-height: 100vh;

        flex-direction: column;
    }
    .header-nav.active {
        display: flex;
    }

    .header-nav > .container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: auto;
        flex-shrink: 0;
    }

    /* Показать кнопку меню */
    .app-menu-toggle {
        display: flex;
    }

    /* Показать заголовок меню */
    .header-nav__menu-header {
        display: flex;
    }

    /* Скрыть меню по умолчанию */
    .header-nav__menu {
        display: none;
        flex-direction: column;
        gap: 0;
        width: 100%;
        order: 2;
        padding: 0;
        overflow: visible;
        background: var(--mega-menu-bg);
        z-index: 1001;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Показать меню когда активно */
    .header-nav__menu[data-menu-visible="true"] {
        display: flex;
        top: var(--header-menu-height);
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        max-height: calc(100vh - var(--header-menu-height));
    }

    .mega-menu-dropdown {
        position: fixed;
        top: var(--header-menu-height);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        margin-left: 0;
        border-top: none;
        box-shadow: none;
        transform: none;
        z-index: 1002;
        overflow-y: auto;
    }

    /* Показать заголовок мега-меню */
    .mega-menu-header {
        display: block;
        position: sticky;
        top: 0;
    }

    .mega-menu-dropdown.is-visible {
        opacity: 1;
        visibility: visible;
        transform: none;
        display: block;
    }

    .mega-menu-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem 0;
    }

    .mega-menu-column {
        padding: 0 1rem;
    }

    .mega-menu-banner {
        grid-column: 1;
    }

    .header-nav__item {
        width: 100%;
        padding: 0;
        flex-shrink: 1;
    }

    .header-nav__button {
        width: 100%;
        justify-content: flex-start;
        padding: 1rem;
        margin: 0;
        border-radius: 0;
    }

}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .mega-menu-dropdown,
    .header-nav__button,
    .mega-menu-item a,
    .mega-menu-item a::before,
    .mega-menu-banner-link,
    .app-menu-toggle span,
    .header-nav__menu-close,
    .mega-menu-back {
        transition: none;
    }
}