/**
 * Sort + filter controls, shared by the make-order list and Quick Shopping.
 *
 * Web mirror of Android's CatalogSortFilterSheets. Both catalogues offer the
 * same axes, so they get the same controls rather than two implementations that
 * drift — which is how the two pages ended up with different sorts.
 *
 * Theme-aware throughout: every colour is a token from colors.css so the
 * controls follow the page in light and dark.
 */

/* ---- control row ---------------------------------------------------------- */

.cat-controls {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
}
.cat-controls::-webkit-scrollbar { display: none; }

.cat-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--outline-tint, #d5d5d5);
  background: var(--surface-variant);
  color: var(--on-surface);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.cat-chip:hover { border-color: var(--primary); }
.cat-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* Count of applied filters, so the number is visible without opening the sheet. */
.cat-chip .cat-badge {
  background: var(--error-strong, #b3261e);
  color: #fff;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cat-chip .cat-x { font-size: 15px; line-height: 1; opacity: .85; }
.cat-chip .cat-caret { font-size: 10px; opacity: .7; }

/* ---- modals --------------------------------------------------------------- */

.cat-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.cat-modal.open { display: flex; }

.cat-sheet {
  background: var(--surface);
  color: var(--on-surface);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  animation: cat-rise .2s ease-out;
}
@keyframes cat-rise { from { transform: translateY(24px); opacity: .6; } }

@media (min-width: 700px) {
  .cat-modal { align-items: center; }
  .cat-sheet { border-radius: 18px; max-height: 82vh; }
}

.cat-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--outline-variant, #e4e4e4);
}
.cat-sheet-title { font-size: 17px; font-weight: 700; margin: 0; }
/* Clear-all and close sit on one line; without this the buttons stack. */
.cat-sheet-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.cat-sheet-clear {
  border: none;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 8px;
  border-radius: 8px;
}
.cat-sheet-clear:hover { background: var(--primary-container); }
.cat-sheet-close {
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.cat-sheet-body { overflow-y: auto; padding: 4px 20px 16px; flex: 1; }

.cat-sheet-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--outline-variant, #e4e4e4);
}
.cat-apply {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  font-size: 15px;
  padding: 13px;
  cursor: pointer;
  font-family: inherit;
}
.cat-apply:hover { opacity: .93; }

/* ---- sort options --------------------------------------------------------- */

.cat-sort-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--on-surface);
  font-size: 15px;
  font-family: inherit;
  text-align: left;
  padding: 13px 4px;
  cursor: pointer;
  border-radius: 8px;
}
.cat-sort-option:hover { background: var(--surface-variant); }
.cat-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--outline, #9a9a9a);
  flex: none;
  position: relative;
}
.cat-sort-option.selected .cat-radio { border-color: var(--primary); }
.cat-sort-option.selected .cat-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--primary);
}

/* ---- filter groups -------------------------------------------------------- */

.cat-group { padding-top: 18px; }
.cat-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--on-surface);
  margin: 0 0 8px;
}
.cat-group-options { display: flex; flex-wrap: wrap; gap: 8px; }

.cat-opt {
  border: 1px solid var(--outline-tint, #d5d5d5);
  background: var(--surface-variant);
  color: var(--on-surface);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.cat-opt:hover { border-color: var(--primary); }
.cat-opt.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
/* The count is what makes a dead end visible BEFORE it is chosen. */
.cat-opt .cat-opt-count { opacity: .75; }

.cat-range { display: flex; gap: 12px; }
.cat-range input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--outline, #9a9a9a);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  color: var(--input-text, var(--on-surface));
  outline: none;
}
.cat-range input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring, rgba(11, 106, 82, .18));
}

/* ---- empty state ---------------------------------------------------------- */

.cat-empty-clear {
  margin-top: 10px;
  border: 1px solid var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.cat-empty-clear:hover { background: var(--primary-container); }
