/* css/sidebar.css */

.sidebar {
    width: 220px;
    flex-shrink: 0;
}

.sidebar__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

.sidebar__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar__link {
    font-size: 14.5px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    transition: color 0.2s ease;
    cursor: pointer;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
}

.sidebar__link:hover {
    color: var(--text-primary);
}

.sidebar__link.is-active {
    color: #1A1917;
    font-weight: 700;
}

/* Стрелочка с плавной анимацией вращения */
.sidebar__arrow {
    font-size: 12px;
    color: #B0AAA0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
    margin-left: 6px;
}

/* Когда аккордеон открыт — стрелка плавно переворачивается */
.sidebar__item.is-open .sidebar__arrow {
    transform: rotate(180deg);
    color: #D4AF37;
}

/* ==========================================================================
   ДЕЛИКАТНЫЙ АККОРДЕОН ПОДАТЕГОРИЙ (СКРЫТ ПО УМОЛЧАНИЮ)
   ========================================================================== */
.sidebar__sub-wrapper {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
}

/* Раскрытое состояние */
.sidebar__item.is-open .sidebar__sub-wrapper {
    max-height: 350px; /* Достаточно для любого количества подкатегорий */
    opacity: 1;
}

.sidebar__sub-list {
    list-style: none;
    padding-left: 12px;
    margin: 4px 0 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-left: 1.5px solid rgba(212, 175, 55, 0.35); /* Золотая линия иерархии */
}

.sidebar__sub-link {
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.2s;
    display: block;
    padding: 2px 0;
}

.sidebar__sub-link:hover,
.sidebar__sub-link.is-active {
    color: #1A1917;
    font-weight: 600;
}

.sidebar__sub-link--all {
    color: #9C824A;
    font-weight: 500;
}

/* На десктопе мобильная шторка скрыта */
.bottom-sheet { display: none; }

/* ==========================================================================
   МОБИЛЬНЫЙ АДАПТИВ (ГОРИЗОНТАЛЬНЫЙ СКРОЛЛ + ШТОРКА)
   ========================================================================== */
@media (max-width: 992px) {
    .sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-bottom: 16px;
        /* Обязательно прячем всё, что пытается вылезти за пределы сайдбара */
        overflow: hidden;
    }

    .sidebar__title,
    .sidebar__sub-wrapper {
        display: none !important;
    }

    .sidebar__nav-container {
        display: flex;
        width: calc(100% + 40px); /* Компенсируем боковые отступы */
        margin-left: -20px;       /* Сдвигаем влево к краю экрана */
        margin-right: -20px;
        padding: 4px 20px 12px 20px; /* Внутренние поля для красивой докрутки */

        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;

        scrollbar-width: none;
    }
    .sidebar__nav-container::-webkit-scrollbar {
        display: none;
    }

    .sidebar__list {
        display: inline-flex; /* Используем inline-flex вместо width: max-content */
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        width: auto;
    }

    .sidebar__item {
        flex-shrink: 0; /* Не даем кнопкам сплющиваться */
    }

    .sidebar__link {
        font-size: 13px;
        font-weight: 500;
        padding: 8px 16px;
        background: #FFFFFF;
        border: 1px solid rgba(35, 33, 30, 0.08);
        border-radius: var(--border-radius-pill);
        color: var(--text-secondary);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
        gap: 6px;
        white-space: nowrap;
    }

    .sidebar__link.is-active {
        background: #1C1B18;
        color: #F5E0A3;
        border-color: rgba(212, 175, 55, 0.5);
    }
}

    /* Мобильная шторка (Bottom Sheet) */
    .bottom-sheet {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 2000;
        pointer-events: none;
        visibility: hidden;
        transition: visibility 0.3s ease;
    }
    .bottom-sheet.is-open {
        pointer-events: auto;
        visibility: visible;
    }
    .bottom-sheet__overlay {
        position: absolute;
        inset: 0;
        background: rgba(18, 17, 15, 0.6);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        opacity: 0;
        transition: opacity 0.35s ease;
    }
    .bottom-sheet.is-open .bottom-sheet__overlay {
        opacity: 1;
    }
    .bottom-sheet__panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 82vh;
        background: #FFFFFF;
        border-radius: 28px 28px 0 0;
        padding: 12px 20px 34px;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        z-index: 100000;
    }
    .bottom-sheet.is-open .bottom-sheet__panel {
        transform: translateY(0);
    }
    .bottom-sheet__handle {
        width: 40px;
        height: 4px;
        background: #D8D4CC;
        border-radius: 2px;
        margin: 0 auto 16px;
    }
    .bottom-sheet__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
        padding-bottom: 14px;
        border-bottom: 1px solid rgba(35, 33, 30, 0.06);
    }
    .bottom-sheet__title {
        font-family: var(--font-heading);
        font-size: 20px;
        color: #1A1917;
    }
    .bottom-sheet__close {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--bg-surface);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        cursor: pointer;
    }
    .bottom-sheet__body {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .bottom-sheet__item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        border-radius: 14px;
        background: #FAF8F5;
        font-size: 15px;
        font-weight: 500;
        color: #1A1917;
    }
    .bottom-sheet__item:hover {
        background: #1C1B18;
        color: #F5E0A3;
    }
    .bottom-sheet__item-arrow {
        color: #B8B3A8;
    }
}