/* ===== САЙДБАР (только внешний вид) ===== */
/* ===== КОНТЕЙНЕР КАТАЛОГА ===== */
.catalog-page {
    padding: 30px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.catalog-container {
    position: relative;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    align-items: start;
    transition: grid-template-columns 0.35s ease, gap 0.35s ease;
}

.catalog-content {
    transition: padding-top 0.35s ease;
    min-width: 0;  
    padding-top: 39px;           /* предотвращает переполнение */
}

.sidebar {
    width: 280px;
    overflow: hidden;
    transition: width 0.35s ease;
}

/* ---------- Switcher ---------- */
.sidebar .switcher {
    margin: 0 0 18px;
}
.sidebar .switcher > span {
    position: relative;
    display: inline-block;
    width: 33px;
    height: 16px;
    border-radius: 8px;
    background: var(--main-color);          /* активное состояние */
    cursor: pointer;
    transition: background 0.2s;
}
.sidebar .switcher .circle {
    position: absolute;
    top: 50%;
    left: 100%;
    margin: -6px 0 0 -14px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: left 0.2s, margin 0.2s;
}
/* Неактивный (свёрнутый) переключатель */
.sidebar .switcher.collapsed > span {
    background: #dbe0e6;
}
.sidebar .switcher.collapsed .circle {
    left: 2px;
    margin-left: 0;
}

/* .sidebar.closed .side-menu {
    display: none;
} */
.sidebar.closed .catalog_opener .arrow::after {
    transform: rotate(180deg);
}

/* ---------- Catalog Opener ---------- */
.sidebar .catalog_opener {
    margin: 0 0 -1px;
    padding: 27px 19px 26px 25px;
    cursor: pointer;
    border-bottom: 1px solid #eff1f5;
    border-top: 1px solid #eff1f5;
    transition: background 0.2s;
}
.sidebar .catalog_opener:hover {
    background: #f8f9fb;
}
.sidebar .catalog_opener > span {
    display: block;
    position: relative;
    padding: 0 40px 0 26px;
    font-size: 0.8667em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #333;
}
/* Иконка перед текстом */
.sidebar .catalog_opener > span::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    margin-top: -6px;
    width: 11px;
    height: 11px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11'%3E%3Cpath d='M0 2h11v1H0zm0 3h11v1H0zm0 3h11v1H0z' fill='%23333'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}
/* Стрелка справа */
.sidebar .catalog_opener .arrow {
    position: absolute;
    right: 0;
    top: 50%;
    margin-top: -10px;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    transition: background-color 0.3s;
}
.sidebar .catalog_opener .arrow::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    margin: -3px 0 0 -4px;
    width: 8px;
    height: 5px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23333'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}
.sidebar .catalog_opener:hover .arrow {
    background-color: var(--primary-light);
}

/* ---------- Основное меню ---------- */
.sidebar .side-menu {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid #eff1f5;
    background: #fff;
}
.sidebar .side-menu li {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid #eff1f5;
}
.sidebar .side-menu > li:first-child {
    border-top: none;
}
.sidebar .side-menu li a {
    display: block;
    padding: 21px 23px;
    color: #333;
    text-decoration: none;
    position: relative;
    transition: background 0.2s, color 0.2s;
}
.sidebar .side-menu li a:hover {
    background: #f8f9fb;
    color: #333;
}
/* Активный пункт */
.sidebar .side-menu li.active > a {
    font-weight: 700;
    color: #333;
    background: #f8f9fb;
}

/* ---------- Пункты с детьми и стрелки ---------- */
.sidebar .side-menu li.child > a {
    padding-right: 54px;
}
.sidebar .side-menu li.child > a .arrow {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 51px;
    cursor: pointer;
}
/* Кружок под стрелкой */
.sidebar .side-menu li.child > a .arrow::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 19px;
    height: 19px;
    margin: -9.5px 0 0 -9.5px;   /* было -9px → теперь точно половина от 19px */
    border-radius: 3px;
    transition: background 0.2s;
}
/* Сама стрелка */
/* Сама стрелка (теперь идеально по центру кружка) */
.sidebar .side-menu li.child > a .arrow::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 19px;                /* как у кружка */
    height: 19px;
    margin: -9.5px 0 0 -9.5px;  /* центрируем */
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 3'%3E%3Cpath d='M0 0l2.5 3L5 0z' fill='%23666'/%3E%3C/svg%3E") no-repeat center;
    background-size: 5px 3px;   /* сохраняем исходный размер стрелки */
    transition: transform 0.2s;
}
.sidebar .side-menu li.child > a .arrow:hover::before {
    background: var(--primary-light);
}
.sidebar .side-menu li.child > a .arrow:hover::after {
    /* можно изменить цвет, но проще оставить */
}
/* Развёрнутая стрелка */
.sidebar .side-menu li.opened > a .arrow::after {
    transform: rotate(180deg);
}
.sidebar .side-menu li.opened > a .arrow::before {
    background: #f8f9fb; /* фон активного пункта уже светлый */
}

/* ---------- Подменю ---------- */
/* Скрытое подменю */
.sidebar .side-menu .submenu-wrapper.hidden-block {
    height: 0;
    overflow: hidden;
    transition: height 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.sidebar .side-menu li.opened > .submenu-wrapper.hidden-block {
    height: auto;
    overflow: visible;
}
.sidebar .side-menu > li > .submenu-wrapper > ul {
    margin: -4px 0 0;
    padding: 4px 0 26px;
    list-style: none;
}
.sidebar .side-menu > li > .submenu-wrapper > ul > li {
    margin-bottom: 10px;
    padding: 0 0 0 23px;
}
/* Вложенные подменю (3-й уровень) */
.sidebar .side-menu li ul li .submenu-wrapper > ul {
    margin: 10px 0 0 10px;
    padding-bottom: 8px;
    list-style: none;
}
.sidebar .side-menu li ul li .submenu-wrapper > ul li {
    margin-bottom: 6px;
    font-size: 1em;
    line-height: 1;
}

.sidebar .side-menu li ul li a:hover {
    color: var(--main-color);
}
.sidebar .side-menu li ul li.active > a {
    color: #333;
    font-weight: 700;
}
/* Отступ для элемента без детей, чтобы скомпенсировать margin */
.sidebar .side-menu li.no_child:last-of-type {
    margin-bottom: -8px;
}

/* Класс .font_xs для уменьшенного шрифта (в подменю) */
.sidebar .font_xs {
    font-size: 0.8667em;
    line-height: 1.3846em;
}

.sidebar .main-sidebar-font {
    font-size: 14px;
    line-height: 1.3846em;
}

/* ---------- Состояние "свёрнутого" сайдбара (при необходимости) ---------- */
.sidebar .side-menu {
    overflow: hidden;
    transition: height 0.35s cubic-bezier(0.4, 0.0, 0.2, 1),
                opacity 0.35s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* По умолчанию (сайдбар открыт) стрелка смотрит вверх */
.sidebar .catalog_opener .arrow::after {
    transform: rotate(180deg);
}

/* Когда сайдбар закрыт – стрелка возвращается вниз */
.sidebar.closed .catalog_opener .arrow::after {
    transform: rotate(0deg);
}

/* ===== Единый фон для раскрытой/активной ветки ===== */
.side-menu li.opened,
.side-menu li.opened li,
.side-menu li.opened > a,
.side-menu li.opened .submenu-wrapper {
    background-color: #f8f9fb;
}

/* Убираем разделительные линии внутри открытого подменю */
.side-menu li.opened > .submenu-wrapper li {
    border-top: none;
}

/* Активный (конечный) пункт тоже заливаем */
.side-menu li.active > a {
    background-color: #f8f9fb;
}

/* Чтобы не было белой полосы между ссылкой и подменю */
.side-menu li.opened > .submenu-wrapper {
    margin-top: 0;
}

/* Выделение всех предков активного пункта */
.side-menu li.has-active > a {
    font-weight: 700;
    color: #333;
    background-color: #f8f9fb;
}

/* Отключаем hover-эффект у выделенных предков */
.side-menu li.has-active > a:hover {
    color: #333 !important;            /* сохраняем чёрный цвет */
}

/* ===== ОТСТУПЫ ДЛЯ ВЛОЖЕННЫХ ССЫЛОК ===== */
.sidebar .side-menu .submenu li a {
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 0;          /* левый отступ уже есть у родительского li */
}

/* Для вложенных пунктов с детьми — увеличенный правый отступ под стрелку */
.sidebar .side-menu .submenu li.child > a {
    padding-right: 54px;
}

.page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

.news-container {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    margin: 0 auto;
}

/* Основной контент занимает всё доступное пространство */
.news-article {
    flex: 1;
    min-width: 0;
}

/* ===== КОНТЕЙНЕР ДЛЯ АБСОЛЮТНОГО ПОЗИЦИОНИРОВАНИЯ ===== */
/* .catalog-container {
    position: relative;
    transition: gap 0.35s ease;
} */

/* ===== САЙДБАР В СКРЫТОМ СОСТОЯНИИ ===== */
.sidebar.sidebar-hidden {
    width: 0 !important;
    overflow: visible;    /* ОБЯЗАТЕЛЬНО: чтобы абсолютный свитчер не обрезался */
}

/* Прячем всё, кроме свитчера */
.sidebar.sidebar-hidden .catalog_opener,
.sidebar.sidebar-hidden .side-menu,
.sidebar.sidebar-hidden .sidebar-certificates {
    display: none;
}

/* ===== СВИТЧЕР ПРИ СКРЫТОМ САЙДБАРЕ – НА ТОМ ЖЕ МЕСТЕ ===== */
.sidebar.sidebar-hidden .switcher {
    position: absolute;
    left: 0;             /* левый край совпадает с левым краем catalog-container */
    top: 0;              /* верхний край совпадает с верхом catalog-container */
    z-index: 100;
    margin: 0;           /* убираем нижний отступ, который был в обычном состоянии */
    /* Свитчер остаётся той же ширины и внешнего вида, что и раньше */
}

/* Контент занимает всё пространство */
.sidebar.sidebar-hidden ~ .catalog-content {
    flex: 1 1 100%;
}

/* Когда сайдбар скрыт – убираем зазор между колонками */
.catalog-container:has(.sidebar-hidden) {
    gap: 0;
    grid-template-columns: 0px 1fr;
}

/* Убираем границы при скрытом сайдбаре, чтобы они не мелькали */
.sidebar.sidebar-hidden .side-menu,
.sidebar.sidebar-hidden .catalog_opener {
    border: 0 !important;
}


/* Адаптив */
@media (max-width: 768px) {
    .page-wrapper {
        padding: 20px 15px;
    }
    .news-row {
        flex-direction: column;
        gap: 20px;
    }
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ: скрываем все варианты сайдбаров ===== */
@media (max-width: 767px),
       (max-height: 500px) and (orientation: landscape) {
    .sidebar.section-sidebar {
        display: none !important;
    }
    .catalog-container .sidebar {
        display: none !important;
    }
    .catalog-container {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .news-container {
        gap: 0;
    }
}