/* НСА: панель поиска и фильтров (списки по старшинству, описи vostok-gen).
   Таблицы — общие стили сайта (global.css, components.css), здесь не меняются. */

.nsa-search {
    --nsa-field-border: #ddd5cc;
    --nsa-field-height: 44px;
    --nsa-radius: 8px;
    margin: 30px 0 20px;
    padding: 22px 24px;
    background: #faf8f5;
    border: 1px solid #ece7e1;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    font-size: 15px;
}

/* Общие поля формы сайта (forms.css) имеют min/max-width под формы заявок — здесь поля тянутся по сетке */
.nsa-search input,
.nsa-search select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: var(--nsa-field-height);
    padding: 0 12px;
    border: 1px solid var(--nsa-field-border);
    border-radius: var(--nsa-radius);
    background-color: #fff;
    color: #2b2b2b;
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nsa-search input:hover,
.nsa-search select:hover {
    border-color: #c4b9ad;
}

.nsa-search input:focus-visible,
.nsa-search select:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 93, 93, 0.15);
}

.nsa-search input::placeholder {
    color: #8a8580;
}

.nsa-search label,
.nsa-search legend {
    display: block;
    margin-bottom: 6px;
    color: #4a4a4a;
    font-size: 14px;
    font-weight: 500;
}

/* ---------- Строка поиска ---------- */
.nsa-search__row {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 10px;
}

.nsa-search__label {
    grid-column: 1 / -1;
}

.nsa-search__field {
    position: relative;
}

.nsa-search__field input {
    padding-right: 44px;
}

/* Свой крестик «Очистить» — ссылка без параметра поиска; встроенный крестик браузера скрываем */
.nsa-search__field input::-webkit-search-cancel-button {
    display: none;
}

.nsa-search .nsa-search__clear {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: var(--nsa-field-height);
    border-radius: 0 var(--nsa-radius) var(--nsa-radius) 0;
    color: #8a8580;
    font-size: 18px;
    transition: color 0.15s;
}

.nsa-search .nsa-search__clear:hover {
    color: var(--link-hover-color);
}

/* ---------- Кнопки ---------- */
.nsa-search .nsa-btn {
    display: inline-block;
    width: auto;
    height: var(--nsa-field-height);
    margin: 0;
    padding: 0 24px;
    border: none;
    border-radius: var(--nsa-radius);
    background: var(--primary-color);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s;
}

.nsa-search .nsa-btn:hover {
    background: #582929;
    box-shadow: 0 2px 8px rgba(108, 51, 51, 0.25);
}

.nsa-search .nsa-btn:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* ---------- Фильтры: свёрнуты под кнопкой «Фильтры (N)»; раскрыты, если какой-то фильтр выбран ---------- */
.nsa-filters {
    margin-top: 20px;
}

.nsa-filters__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1px solid var(--nsa-field-border);
    border-radius: 999px;
    background: #fff;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.nsa-filters__toggle:hover {
    border-color: var(--primary-color);
}

.nsa-filters[open] > .nsa-filters__toggle {
    background: #f4ecea;
    border-color: #e3cfcc;
}

.nsa-filters__toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 93, 93, 0.15);
}

.nsa-filters__toggle::-webkit-details-marker {
    display: none;
}

.nsa-filters__toggle::after {
    content: "\f078"; /* fa-chevron-down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 11px;
    transition: transform 0.2s;
}

.nsa-filters[open] > .nsa-filters__toggle::after {
    transform: rotate(180deg);
}

.nsa-filters__groups {
    display: grid;
    gap: 20px;
    margin-top: 16px;
    padding: 20px;
    background: #fff;
    border: 1px solid #ece7e1;
    border-radius: 10px;
}

.nsa-filters__group {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.nsa-filters__group legend {
    padding: 0;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-family: "Merriweather", serif;
    font-size: 15px;
    font-weight: 400;
}

.nsa-filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px 16px;
}

.nsa-field {
    min-width: 0;
}

.nsa-filters__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    margin-top: 20px;
}

/* ---------- Сортировка: на компьютере — по заголовкам колонок, на телефоне — выпадающий список ---------- */
.nsa-sort {
    display: none;
}

/* ---------- Итоги и выбранные фильтры ---------- */
.nsa-results {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    margin: 0 0 16px;
    scroll-margin-top: 70px; /* переход к #results — не под «липкой» шапкой */
}

.nsa-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nsa-results .nsa-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #f1ece6;
    color: #2b2b2b;
    font-size: 14px;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.nsa-results .nsa-chip span {
    color: #8a8580;
    font-size: 16px;
    line-height: 1;
}

.nsa-results .nsa-chip:hover {
    background: #fff;
    border-color: #e3cfcc;
}

.nsa-results .nsa-chip:hover,
.nsa-results .nsa-chip:hover span {
    color: var(--link-hover-color);
}

/* Колонки таблицы — ссылки сортировки: стрелка у текущей колонки */
/* Заголовки колонок — ссылки сортировки: у каждой значок ⇅ (бледный), у текущей — направление */
th .sort-link i {
    --fa-display: inline; /* не inline-block: тогда &nbsp; держит значок рядом с последним словом, без переноса */
    font-size: 11px;
    color: #b8b0a8;
    transition: color 0.15s;
}

th .sort-link:hover i,
th .sort-link.active i {
    color: inherit;
}

/* ---------- Компьютер ---------- */
@media (width >= 700px) {
    .nsa-filters__groups {
        grid-template-columns: minmax(0, 3fr) minmax(0, 3fr);
    }

    .nsa-filters__group:last-child {
        grid-column: 1 / -1;
    }

    .nsa-filters__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nsa-filters__group:last-child .nsa-filters__grid {
        grid-template-columns: repeat(5, 120px); /* номера короткие */
    }
}

/* ---------- Телефон ---------- */
@media (width < 700px) {
    .nsa-search {
        margin: 20px 0 16px;
        padding: 16px;
    }

    .nsa-filters__groups {
        padding: 16px;
    }

    .nsa-search .nsa-btn {
        padding: 0 16px;
    }

    .nsa-filters__group:last-child .nsa-filters__grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    .nsa-sort {
        display: block;
        margin-top: 16px;
    }
}
