/* Filters — soft-modern (2026-05-08, JSX target).
   Desktop: panel rounded-3xl, 6-полевая адаптивная сетка, чёткие labels.
   Mobile: bottom-sheet (rounded-top-3xl), кнопка «Фильтры» снизу
   синхронизируется с floating-bar (см. public.css).

   Цвета — токены design.css. Никаких хардкод-фоллбэков (палитра единая
   и всегда задана). Радиусы и spacing — JSX-mapping. */

/* ── Desktop panel — 6 fields в одну строку на ≥1280, как в JSX ───── */
.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 0 0 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
}
@media (min-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1280px) {
  /* JSX: 1.1fr 1.1fr 0.8fr 0.8fr 0.8fr 0.9fr — 6 колонок одной строкой */
  .filters {
    grid-template-columns: 1.1fr 1.1fr 0.8fr 0.8fr 0.8fr 0.9fr;
  }
}

/* Header фильтров — заголовок «Фильтры» + actions справа.
 * На desktop: title + (Сбросить, Показать N) в одной строке.
 * На mobile: title + крестик; actions переезжают в sticky footer. */
.filters-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.filters-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.filters-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.filters-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
}
.filters-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.filters-head-actions .head-favourite[aria-pressed="true"] {
  background: var(--accent-weak);
  color: var(--accent-text);
  border-color: var(--accent);
}
.filters .sheet-close-btn { display: none; }   /* видим только на мобиле */
.filters .sheet-footer { display: none; }      /* sticky footer — только мобиле */

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.filter-group > label,
.filter-group > legend {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.005em;
  padding: 0;
  margin: 0;
}

/* Inputs/Select наследуют базу из design.css (h-44, radius 12). */
.filter-group select,
.filter-group input[type=number],
.filter-group input[type=text],
.filter-group input[type=search],
.filter-group .culture-search {
  width: 100%;
}

/* Кастомная стрелка для select (chevron-down) — native arrow убираем,
 * рисуем SVG-стрелку через background-image. */
.filter-group select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236D786E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  cursor: pointer;
}
[data-theme="dark"] .filter-group select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239AA3AD' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
}

/* Подсветка select/input когда выбрано не-дефолтное значение. */
.filter-group select.has-value,
.filter-group input.has-value {
  border-color: var(--accent-border);
  background: var(--accent-weak);
  color: var(--accent-text);
}

/* ── Input + ✕ clear ─────────────────────────────────────────────────── */
.input-with-clear {
  position: relative;
}
.input-with-clear input {
  padding-right: 38px !important;
}
.input-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.input-clear:hover {
  color: var(--text);
  background: var(--accent-weak);
}
.input-clear[hidden] { display: none; }
.input-clear .icon { width: 14px; height: 14px; }

/* Скрыть native datalist-стрелку (Chrome/Edge) — мешает с нашим ✕. */
.input-with-clear input::-webkit-calendar-picker-indicator {
  display: none !important;
  -webkit-appearance: none;
  appearance: none;
}
.input-with-clear input::-webkit-list-button {
  display: none !important;
  -webkit-appearance: none;
}

/* ── Culture tagger ─────────────────────────────────────────────────── */
/* JSX-style: 6 fields в одну строку, культуры тоже 1 column. */
.filter-cultures { /* без span — обычная колонка */ }

.culture-tagger {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  padding: 8px 10px;
  min-height: 44px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.culture-tagger:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.culture-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.culture-tags:empty { display: none; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  background: var(--accent-weak);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  line-height: 1;
}
.tag-remove {
  border: none;
  background: none;
  color: var(--accent-text);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  transition: background 150ms var(--ease);
}
.tag-remove:hover { background: rgba(0, 0, 0, 0.08); }

.culture-search {
  border: 0 !important;
  padding: 0 4px !important;
  background: transparent !important;
  min-height: 28px !important;
  width: 100%;
  font-size: 14px;
}
.culture-search:focus {
  outline: 0 !important;
  box-shadow: none !important;
}

.culture-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: 30;
  box-shadow: var(--shadow-lg);
}
.culture-suggestions li {
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: background 100ms var(--ease);
}
.culture-suggestions li:hover,
.culture-suggestions li[aria-selected="true"] {
  background: var(--accent-weak);
  color: var(--accent-text);
}

/* ── Actions (Reset, spinner) ───────────────────────────────────────── */
.filters-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  align-self: end;
}

.filters-actions .btn-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms var(--ease), color 150ms var(--ease),
              background 150ms var(--ease);
}
.filters-actions .btn-reset:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.filters-actions .btn-reset:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Spinner — заменяет dots при htmx-загрузке. */
.filters-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: filters-spin 0.7s linear infinite;
  opacity: 0;
  transition: opacity 150ms;
  vertical-align: middle;
}
.htmx-request .filters-spinner,
.htmx-request.filters-spinner { opacity: 1; }

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

#orders-block { transition: opacity 0.15s; }
.htmx-request #orders-block { opacity: 0.55; }

/* На десктопе .filters-actions (старая) и .sheet-footer (новая) спрятаны —
 * actions живут в .filters-head. На мобиле наоборот. */
.filters-actions { display: none; }

/* ── Старый .filters-sheet-btn — оставлен для filters.js compat,
     но скрыт визуально (триггер живёт в floating bottom-bar). ────────── */
.filters-sheet-btn { display: none; }

/* ── Mobile sheet view (≤720) ───────────────────────────────────────── */
/* Триггер фильтра живёт в floating bottom-bar (см. base.html .bb-filters).
 * Старая .filters-sheet-btn остаётся в _filters.html для совместимости с
 * filters.js, но скрывается визуально — на мобиле работает bottom-bar,
 * на десктопе — inline filter panel. */
@media (max-width: 720px) {
  .filters {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 100;
    grid-template-columns: 1fr;
    border-radius: 24px 24px 0 0;
    margin: 0;
    padding: 16px 16px 0;     /* footer добавит своё padding-bottom */
    background: var(--surface);
    overflow-y: auto;
    box-shadow: var(--shadow-sheet);
    max-height: 88vh;
  }
  .filters.sheet-open { display: grid; }
  .filter-cultures { grid-column: span 1; }
  .filters-sheet-btn { display: none; }
  body.body-sheet-lock { overflow: hidden; }

  /* На мобиле в head оставляем title + close, скрываем head-actions
   * (они переезжают в sticky-footer внизу sheet'а). */
  .filters .filters-head-actions { display: none; }
  .filters .sheet-close-btn { display: inline-flex; }

  /* Sticky footer — сверху «В избранное» (full-width), снизу Сбросить+Готово. */
  .filters .sheet-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    grid-column: 1 / -1;
    position: sticky;
    bottom: 0;
    margin: 8px -16px 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border-soft);
  }
  .filters .sheet-footer .sheet-favourite {
    width: 100%;
    height: 44px;
    justify-content: center;
  }
  .filters .sheet-footer .sheet-favourite[aria-pressed="true"] {
    background: var(--accent-weak);
    color: var(--accent-text);
    border-color: var(--accent);
  }
  .filters .sheet-footer-actions {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
  }
  .filters .sheet-footer-actions .btn { height: 48px; font-size: 15px; }
  .filters .sheet-footer-actions .sheet-reset { padding: 0 18px; }
}
