/* Страница «Reduceri»: фильтр по разделам и подразделам (24.09.2026) */
.rd {
    --rd-brand: #b74923;
    --rd-brand-dark: #9a3c1c;
    --rd-brand-soft: #fbefe9;
    --rd-text: #26221f;
    --rd-muted: #6b625c;
    --rd-line: #ececec;
    --rd-surface: #ffffff;
    --rd-sub-bg: #f6f2ef;
    --rd-radius: 5px;
    --rd-ease: cubic-bezier(.2, .7, .3, 1);
    margin-top: 20px;
}

.rd-filter {
    background: var(--rd-surface);
    border: 1px solid #f2f2f2;
    border-radius: 5px;
    padding: 18px 20px 20px;
}

.rd-filter__title {
    margin: 0 0 14px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--rd-text);
}

.rd-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Чипс раздела */
.rd-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    max-width: 100%;
    padding: 0 8px 0 12px;
    border: 1px solid var(--rd-line);
    border-radius: var(--rd-radius);
    background: var(--rd-surface);
    color: var(--rd-text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color .15s var(--rd-ease), background-color .15s var(--rd-ease), color .15s var(--rd-ease), box-shadow .15s var(--rd-ease);
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .rd-chip:hover {
        border-color: var(--rd-brand);
        color: var(--rd-brand);
    }
}

.rd-chip:focus-visible,
.rd-toggle:focus-visible,
.rd-more__btn:focus-visible {
    outline: 2px solid var(--rd-brand);
    outline-offset: 2px;
}

.rd-chip__icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.rd-chip__icon--svg {
    color: var(--rd-brand);
}

.rd-chip__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rd-chip__qty {
    flex: 0 0 auto;
    min-width: 24px;
    padding: 3px 7px;
    border-radius: 3px;
    background: var(--rd-brand-soft);
    color: var(--rd-brand);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.rd-chip.is-active {
    border-color: var(--rd-brand);
    background: var(--rd-brand);
    color: #fff;
}

.rd-chip.is-active .rd-chip__qty {
    background: rgba(255, 255, 255, .22);
    color: #fff;
}

.rd-chip.is-active .rd-chip__icon {
    filter: brightness(0) invert(1);
}

.rd-chip.is-active .rd-chip__icon--svg {
    filter: none;
    color: #fff;
}

/* Свёрнутый список разделов: на ПК первые 12, на телефоне первые 6 (выбранный раздел виден всегда) */
.rd-chips--roots.is-collapsed .rd-chip--extra-d:not(.is-active) {
    display: none;
}

.rd-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px dashed var(--rd-brand);
    border-radius: var(--rd-radius);
    background: transparent;
    color: var(--rd-brand);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s var(--rd-ease);
}

.rd-toggle:hover {
    background: var(--rd-brand-soft);
}

.rd-toggle--mobile-only,
.rd-toggle__n--m,
.rd-toggle__less {
    display: none;
}

.rd-toggle__chevron {
    transition: transform .2s var(--rd-ease);
}

.rd-toggle[aria-expanded="true"] .rd-toggle__more {
    display: none;
}

.rd-toggle[aria-expanded="true"] .rd-toggle__less {
    display: inline;
}

.rd-toggle[aria-expanded="true"] .rd-toggle__chevron {
    transform: rotate(180deg);
}

/* Подразделы выбранного раздела */
.rd-subs {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--rd-line);
    animation: rd-fade .2s var(--rd-ease);
}

.rd-subs[hidden] {
    display: none;
}

.rd-subs__title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--rd-muted);
}

.rd-chip--sub {
    min-height: 36px;
    padding: 0 6px 0 12px;
    border-color: transparent;
    background: var(--rd-sub-bg);
    font-size: 13px;
}

.rd-chip--sub .rd-chip__qty {
    background: #fff;
}

.rd-chip--sub.is-active {
    border-color: var(--rd-brand);
    background: var(--rd-brand-soft);
    color: var(--rd-brand);
    box-shadow: none;
}

.rd-chip--sub.is-active .rd-chip__qty {
    background: var(--rd-brand);
    color: #fff;
}

/* Число найденных товаров */
.rd-status {
    margin: 20px 0 0;
    font-size: 15px;
    line-height: 1.4;
    color: var(--rd-muted);
}

.rd-status__count {
    color: var(--rd-text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.rd-status__cat {
    color: var(--rd-text);
}

/* Результаты: пока идёт загрузка — приглушены */
.rd-results {
    transition: opacity .2s var(--rd-ease);
}

.rd-results[aria-busy="true"] .rd-products {
    opacity: .45;
    pointer-events: none;
}

.sort .wrapper .rd-products {
    margin-top: 16px;
}

/* «Показать ещё» */
.rd-more {
    display: flex;
    justify-content: center;
    margin: 28px 0 8px;
}

.rd-more[hidden] {
    display: none;
}

.rd-more__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 260px;
    min-height: 48px;
    padding: 0 24px;
    border: 1px solid var(--rd-brand);
    border-radius: var(--rd-radius);
    background: #fff;
    color: var(--rd-brand);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s var(--rd-ease), color .15s var(--rd-ease);
}

.rd-more__btn:hover {
    background: var(--rd-brand);
    color: #fff;
}

.rd-more__spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: rd-spin .7s linear infinite;
}

.rd-more__btn.is-loading .rd-more__spinner {
    display: inline-block;
}

@keyframes rd-spin {
    to { transform: rotate(360deg); }
}

@keyframes rd-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* Телефоны и планшеты */
@media (max-width: 767px) {
    .rd {
        margin-top: 12px;
    }

    .rd-filter {
        padding: 14px 12px 16px;
    }

    .rd-filter__title {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .rd-chips {
        gap: 6px;
    }

    .rd-chip {
        min-height: 38px;
        padding: 0 6px 0 10px;
        font-size: 13px;
        gap: 6px;
    }

    .rd-chip__icon {
        flex-basis: 18px;
        width: 18px;
        height: 18px;
    }

    .rd-chip--sub {
        min-height: 36px;
    }

    .rd-chips--roots.is-collapsed .rd-chip--extra-m:not(.is-active) {
        display: none;
    }

    .rd-toggle {
        min-height: 38px;
        font-size: 13px;
    }

    .rd-toggle--mobile-only {
        display: inline-flex;
    }

    .rd-toggle__n--d {
        display: none;
    }

    .rd-toggle__n--m {
        display: inline;
    }

    .rd-subs {
        margin-top: 14px;
        padding-top: 14px;
    }

    .rd-status {
        margin-top: 16px;
        font-size: 14px;
    }

    .rd-more__btn {
        width: 100%;
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rd-chip,
    .rd-toggle,
    .rd-toggle__chevron,
    .rd-results,
    .rd-more__btn {
        transition: none;
    }

    .rd-subs {
        animation: none;
    }
}

/* С JavaScript список разделов сворачивается по фактическим строкам (ПК — 3, телефон — 6, вместе с кнопкой) */
.rd.rd-js .rd-chips--roots.is-collapsed .rd-chip--extra-d,
.rd.rd-js .rd-chips--roots.is-collapsed .rd-chip--extra-m {
    display: inline-flex;
}

.rd.rd-js .rd-chips--roots.is-collapsed .rd-chip.rd-chip--fold {
    display: none;
}

.rd.rd-js .rd-toggle {
    display: inline-flex;
}

.rd.rd-js .rd-toggle.rd-toggle--off {
    display: none;
}

/* ---------- v2: заголовок с кнопкой, подразделы в 2 строки (ПК), горизонтальные ленты и нижняя панель (телефон) ---------- */
.rd-filter__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.rd-filter__head .rd-filter__title {
    margin: 0;
}

.rd-chips {
    position: relative; /* offsetLeft чипсов считается от ленты */
}

.rd-sheet-open,
.rd-sheet {
    display: none;
}

.rd-backdrop {
    display: none;
}

.rd.rd-js .rd-chips--subs.is-collapsed .rd-chip.rd-chip--fold {
    display: none;
}

.rd .rd-toggle--subs {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

@media (min-width: 768px) {
    .rd-backdrop {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .rd-filter__head {
        margin-bottom: 10px;
    }

    .rd-sheet-open {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-height: 36px;
        padding: 0 12px;
        border: 1px solid var(--rd-line);
        border-radius: 5px;
        background: #fff;
        color: var(--rd-brand);
        font: inherit;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        cursor: pointer;
    }

    .rd-sheet-open:focus-visible,
    .rd-sheet__close:focus-visible {
        outline: 2px solid var(--rd-brand);
        outline-offset: 2px;
    }

    /* кнопки «+N / Свернуть» на телефоне не нужны: ленты прокручиваются, полный список — в панели */
    .rd.rd-js .rd-chips .rd-toggle {
        display: none;
    }

    /* горизонтальные ленты разделов и подразделов */
    .rd.rd-js .rd-chips--roots:not(.is-sheet),
    .rd.rd-js .rd-chips--subs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        margin: 0 -12px;
        padding: 2px 12px 8px;
        scroll-padding: 0 12px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        -webkit-mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
        mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
    }

    .rd.rd-js .rd-chips--roots:not(.is-sheet)::-webkit-scrollbar,
    .rd.rd-js .rd-chips--subs::-webkit-scrollbar {
        display: none;
    }

    .rd.rd-js .rd-chips--roots:not(.is-sheet) .rd-chip,
    .rd.rd-js .rd-chips--subs .rd-chip {
        flex: 0 0 auto;
    }

    .rd.rd-js .rd-chips--roots .rd-chip.rd-chip--extra-m,
    .rd.rd-js .rd-chips--roots .rd-chip.rd-chip--fold,
    .rd.rd-js .rd-chips--subs .rd-chip.rd-chip--fold {
        display: inline-flex;
    }

    .rd-subs__title {
        margin-bottom: 8px;
    }

    html.rd-noscroll,
    html.rd-noscroll body {
        overflow: hidden;
    }
}

@keyframes rd-up {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@keyframes rd-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .rd-sheet,
    .rd-sheet__list--in,
    .rd-backdrop {
        animation: none;
    }
}


@media (max-width: 767px) {
    .rd-subs__parent {
        display: none;
    }
}

/* ---------- Нижняя панель (телефон): разделы → подразделы. Выше кнопки чата (#mcChatWidget z-index 2147483000) ---------- */
@media (max-width: 767px) {
    .rd-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 2147483001;
        background: rgba(20, 16, 14, .45);
        animation: rd-fade-in .2s var(--rd-ease);
    }

    .rd-backdrop[hidden] {
        display: none;
    }

    .rd-sheet,
    .rd-sheet * {
        box-sizing: border-box;
    }

    .rd-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 2147483002;
        display: flex;
        flex-direction: column;
        max-height: 82vh;
        background: #fff;
        border-radius: 10px 10px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
        animation: rd-up .22s var(--rd-ease);
    }

    .rd-sheet[hidden] {
        display: none;
    }

    .rd-sheet__head {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 4px;
        min-height: 56px;
        padding: 0 8px 0 16px;
        border-bottom: 1px solid var(--rd-line);
    }

    .rd-sheet[data-level="2"] .rd-sheet__head {
        padding-left: 4px;
    }

    .rd-sheet__title {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 17px;
        font-weight: 600;
        color: var(--rd-text);
    }

    .rd-sheet__back,
    .rd-sheet__close {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: 5px;
        background: transparent;
        color: var(--rd-text);
        cursor: pointer;
    }

    .rd-sheet__back[hidden] {
        display: none;
    }

    .rd-sheet__back:focus-visible,
    .rd-sheet__close:focus-visible {
        outline: 2px solid var(--rd-brand);
        outline-offset: -2px;
    }

    .rd-sheet__list {
        position: relative;
        flex: 1 1 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 4px 16px calc(16px + env(safe-area-inset-bottom));
    }

    .rd-sheet__list--in {
        animation: rd-slide .2s var(--rd-ease);
    }

    .rd-sheet .rd-chip {
        display: flex;
        width: 100%;
        min-height: 48px;
        padding: 0 4px;
        gap: 10px;
        border: 0;
        border-bottom: 1px solid #f2f2f2;
        border-radius: 0;
        background: transparent;
        color: var(--rd-text);
        font-size: 15px;
        font-weight: 500;
        box-shadow: none;
    }

    .rd-sheet .rd-chip__label {
        flex: 1 1 auto;
        white-space: normal;
    }

    .rd-sheet .rd-chip__qty {
        background: var(--rd-brand-soft);
        color: var(--rd-brand);
    }

    .rd-sheet .rd-chip.is-active {
        padding: 0 8px;
        border-radius: 5px;
        background: var(--rd-brand-soft);
        color: var(--rd-brand);
    }

    .rd-sheet .rd-chip.is-active .rd-chip__icon {
        filter: none;
    }

    .rd-sheet .rd-chip.is-active .rd-chip__icon--svg {
        color: var(--rd-brand);
    }

    .rd-sheet .rd-chip.is-active .rd-chip__qty {
        background: var(--rd-brand);
        color: #fff;
    }

    /* второй уровень: подразделы без иконок — отступ, чтобы текст стоял ровно под названием раздела */
    .rd-sheet[data-level="2"] .rd-chip:not(:first-child) {
        padding-left: 34px;
    }

    .rd-sheet[data-level="2"] .rd-chip:first-child {
        font-weight: 600;
    }

    .rd-sheet__chevron {
        flex: 0 0 auto;
        width: 8px;
        height: 8px;
        margin: 0 4px 0 2px;
        border-top: 2px solid #b9aea8;
        border-right: 2px solid #b9aea8;
        transform: rotate(45deg);
    }

    .rd-sheet .rd-chip.is-active .rd-sheet__chevron {
        border-color: var(--rd-brand);
    }
}

@keyframes rd-slide {
    from { opacity: 0; transform: translateX(12px); }
    to { opacity: 1; transform: none; }
}

/* Строка «N produse cu reducere» + сортировка (29.09.2026) */
.rd-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin: 18px 0 12px; }
.rd-bar .rd-status { margin: 0; }
.rd-sort { display: flex; align-items: center; gap: 8px; margin: 0; }
.rd-sort label { margin: 0; font-size: 14px; color: var(--rd-muted, #6b625c); font-weight: 400; }
.rd-sort__wrap { position: relative; display: inline-flex; align-items: center; }
.rd-sort__wrap svg { position: absolute; right: 10px; pointer-events: none; color: var(--rd-text, #26221f); }
.rd-sort__sel { -webkit-appearance: none; appearance: none; height: 40px; padding: 0 34px 0 12px; border: 1px solid #d8cfc9; border-radius: 5px; background: #fff;
    font: inherit; font-size: 14px; font-weight: 600; color: var(--rd-text, #26221f); cursor: pointer; }
.rd-sort__sel:hover { border-color: var(--rd-brand, #b74923); }
.rd-sort__sel:focus-visible { outline: 2px solid var(--rd-brand, #b74923); outline-offset: 2px; }
@media (max-width: 767px) {
    .rd-bar { margin: 12px 0 10px; }
    .rd-sort { width: 100%; }
    .rd-sort label { display: none; }
    .rd-sort__wrap, .rd-sort__sel { width: 100%; }
}
