/* filters.css — левая колонка фильтров каталога: белый блок, сворачиваемые
   группы, ползунок цены (noUiSlider), чекбоксы со счётчиками, цветовые кружки,
   «показать ещё» для длинных списков значений.
   Разметка: templates/partials/filters.html. Поведение: assets/js/catalog.js.
   Подключается на страницах листинга рядом с catalog.css. */

.filters {
    padding: 4px 16px 16px;
    border-radius: var(--radius, 12px);
    background: var(--card, #fff);
    box-shadow: var(--shadow-card, 0 1px 2px rgba(16, 24, 40, .04));
}

/* Шапка — видна только в выезжающей панели на узких экранах */
.filters__head { display: none; align-items: center; justify-content: space-between; padding: 14px 0 10px; }
.filters__title { color: var(--ink, #2d2d32); font-size: 17px; font-weight: 700; }
.filters__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: var(--surface, #f6f5f3);
    color: var(--ink, #2d2d32);
    font-size: 15px;
    cursor: pointer;
}
.filters__close:hover { background: var(--primary-soft, #eeefff); color: var(--primary, #4652ff); }

/* ── Группа фильтра ── */
/* Группы разделены линией: разметка чередует <details> и <div>, поэтому
   разделитель вешаем на соседа, а не на :last-of-type. */
.filter-group { display: block; padding: 14px 0; }
.filter-group + .filter-group { border-top: 1px solid var(--line, #e8e8e8); }

.filter-group__title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--ink, #2d2d32);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.filter-group__title::-webkit-details-marker { display: none; }
/* Стрелка сворачивания рисуется бордюрами — не зависит от набора иконок */
.filter-group__title::after {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-right: 4px;
    border-right: 2px solid var(--muted, #8d8d8d);
    border-bottom: 2px solid var(--muted, #8d8d8d);
    transform: translateY(-2px) rotate(45deg);
    transition: transform .18s ease;
}
.filter-group[open] > .filter-group__title::after { transform: translateY(1px) rotate(225deg); }
.filter-group__title:hover { color: var(--primary, #4652ff); }
.filter-group__body { padding-top: 12px; }

/* ── Цена и числовые диапазоны ── */
.filter-price__slider { margin: 8px 8px 18px; }
.filter-price__inputs { display: flex; align-items: center; gap: 8px; }
.filter-price__input {
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line, #e8e8e8);
    border-radius: var(--radius-sm, 8px);
    background: #fff;
    color: var(--ink, #2d2d32);
    font-family: inherit;
    font-size: 14px;
}
.filter-price__input::placeholder { color: var(--muted, #8d8d8d); }
.filter-price__input:focus { outline: none; border-color: var(--primary, #4652ff); }
.filter-price__dash { flex: none; color: var(--muted, #8d8d8d); }
/* Стрелки числового поля съедают ширину в узкой колонке фильтров и мешают
   попасть по цифрам — границы диапазона задаются ползунком и клавиатурой */
.filter-price__input { appearance: textfield; -moz-appearance: textfield; }
.filter-price__input::-webkit-outer-spin-button,
.filter-price__input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }

/* Тема noUiSlider */
.filter-price__slider.noUi-target { height: 4px; border: 0; border-radius: 4px; background: var(--surface-2, #f4f6f9); box-shadow: none; }
.filter-price__slider .noUi-connect { background: var(--primary, #4652ff); }
.filter-price__slider .noUi-handle {
    width: 16px;
    height: 16px;
    right: -8px;
    top: -6px;
    border: 2px solid var(--primary, #4652ff);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(16, 24, 40, .2);
    cursor: grab;
}
.filter-price__slider .noUi-handle::before,
.filter-price__slider .noUi-handle::after { display: none; }
.filter-price__slider .noUi-handle:active { cursor: grabbing; }

/* ── Значения-чекбоксы ── */
.filter-values { display: flex; flex-direction: column; gap: 2px; }
.filter-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 2px;
    color: var(--ink-2, #3a3a44);
    font-size: 14px;
    cursor: pointer;
}
.filter-check.is-hidden { display: none; }
.filter-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.filter-check__box {
    position: relative;
    flex: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--line, #e8e8e8);
    border-radius: 5px;
    background: #fff;
    transition: border-color .15s ease, background .15s ease;
}
.filter-check:hover .filter-check__box { border-color: var(--primary, #4652ff); }
.filter-check input:checked + .filter-check__box {
    background: var(--primary, #4652ff);
    border-color: var(--primary, #4652ff);
}
.filter-check input:checked + .filter-check__box::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.filter-check input:focus-visible + .filter-check__box { box-shadow: 0 0 0 3px var(--primary-soft, #eeefff); }

/* Радио (склады — одиночный выбор) */
.filter-check__box--radio { border-radius: 50%; }
.filter-check input:checked + .filter-check__box--radio { background: #fff; border-color: var(--primary, #4652ff); }
.filter-check input:checked + .filter-check__box--radio::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 8px;
    height: 8px;
    border: 0;
    border-radius: 50%;
    background: var(--primary, #4652ff);
    transform: translate(-50%, -50%);
}

.filter-check__label { flex: 1; min-width: 0; }
.filter-check__cnt { color: var(--muted, #8d8d8d); font-size: 12px; }
.filter-check:hover .filter-check__label { color: var(--primary, #4652ff); }

/* Значение, недоступное при текущем выборе */
.filter-check.is-disabled { opacity: .4; cursor: not-allowed; }
.filter-check.is-disabled:hover .filter-check__label,
.filter-check.is-disabled:hover .filter-check__box { color: var(--ink-2, #3a3a44); border-color: var(--line, #e8e8e8); }

/* Ссылка на готовую подборку (SEO-фильтр) */
.filter-link {
    margin-left: auto;
    padding: 0 2px;
    color: var(--muted, #8d8d8d);
    font-size: 11px;
    opacity: 0;
    transition: opacity .15s ease, color .15s ease;
}
.filter-check:hover .filter-link { opacity: 1; }
.filter-link:hover { color: var(--primary, #4652ff); }

/* «Показать ещё» в длинном списке значений (кнопку создаёт catalog.js).
   Порядок в списке фиксируем: кнопка всегда последняя, даже если выбранные
   значения перескакивают вверх. */
.filter-more {
    order: 99;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--primary, #4652ff);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.filter-more::after {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform .15s ease;
}
.filter-more.is-open::after { transform: translateY(1px) rotate(225deg); }
.filter-more:hover { color: var(--primary-600, #3742e0); }

/* ── Цветовые кружки ── */
.filter-colors { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-color { position: relative; line-height: 0; cursor: pointer; }
.filter-color input { position: absolute; opacity: 0; width: 0; height: 0; }
.filter-color__dot {
    display: block;
    width: 26px;
    height: 26px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--line, #e8e8e8);
    transition: box-shadow .15s ease, transform .15s ease;
}
.filter-color:hover .filter-color__dot { transform: scale(1.08); }
.filter-color.is-active .filter-color__dot { box-shadow: 0 0 0 2px var(--primary, #4652ff); }
.filter-color.is-disabled { opacity: .35; cursor: not-allowed; }

/* ── Кнопки под фильтрами ── */
.filters__actions { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; }
.filters__apply,
.filters__done {
    height: 44px;
    border: 0;
    border-radius: var(--radius, 12px);
    background: var(--primary, #4652ff);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s ease;
}
.filters__apply:hover,
.filters__done:hover { background: var(--primary-600, #3742e0); }
/* «Показать товары» нужна только в выехавшей панели на узком экране */
.filters__done { display: none; }

/* Сброс — не строчка мелким серым, а понятная кнопка-контур */
.filters__reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    border: 1px solid var(--line, #e8e8e8);
    border-radius: var(--radius, 12px);
    color: var(--muted, #8d8d8d);
    font-size: 13px;
    font-weight: 500;
    transition: border-color .15s ease, color .15s ease;
}
.filters__reset i { font-size: 11px; }
.filters__reset:hover { border-color: var(--badge, #ff0638); color: var(--badge, #ff0638); }

@media (max-width: 992px) {
    .filters { border-radius: 0; box-shadow: none; padding: 0 18px 24px; }
    .filters__head {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 2;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--line, #e8e8e8);
        background: var(--card, #fff);
    }
    /* Кнопки прилипают к низу панели: список значений длинный, а вернуться к
       товарам нужно с любого места прокрутки */
    .filters__actions {
        position: sticky;
        bottom: 0;
        z-index: 2;
        margin: 0 -18px;
        padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid var(--line, #e8e8e8);
        background: var(--card, #fff);
    }
    .filters__done { display: block; }
}

@media (max-width: 480px) {
    .filters { padding: 0 14px 20px; }
    .filters__actions { margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
    .filter-price__slider { margin: 8px 10px 16px; }
    /* 16px — ниже этого размера мобильный Safari зумит страницу при фокусе */
    .filter-price__input { height: 40px; font-size: 16px; }
    .filter-check { padding: 7px 2px; }
    .filter-colors { gap: 12px; }
    .filter-color__dot { width: 28px; height: 28px; }
}
