/* ============================================================
   Beachy Lila — search, filter and list UX
   Global search (top bar), live list filters, filter chips,
   search fields, denser tables, Coins formatting.
   ============================================================ */

/* Components that set their own display (e.g. .btn-badge) must still honour [hidden]. */
[hidden] { display: none !important; }

/* ---------- Top bar: global search trigger ---------- */
.topbar { padding-top: 14px; padding-bottom: 14px; }
.topbar-left { flex: 1 1 auto; max-width: 560px; }

.gs-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  padding: 0 10px 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
  background: rgba(15, 7, 30, 0.6);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
  color: var(--fg-3);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.gs-trigger:hover { border-color: var(--border-medium); background: rgba(20, 10, 40, 0.75); color: var(--fg-2); }
.gs-trigger:focus-visible { outline: none; border-color: var(--border-bright); box-shadow: 0 0 0 3px rgba(169, 114, 244, 0.25); }
.gs-trigger-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.gs-kbd {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  border-bottom-width: 2px;
  background: rgba(255, 247, 236, 0.05);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- Global search dialog ---------- */
.gs-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(10, 4, 22, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.gs-overlay.is-open { display: flex; animation: gs-fade var(--dur-fast) var(--ease-out); }
body.gs-open { overflow: hidden; }

.gs-panel {
  width: 100%;
  max-width: 680px;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-medium);
  background: linear-gradient(180deg, rgba(255, 247, 236, 0.05) 0%, transparent 80px), #22113f;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: gs-pop var(--dur-base) var(--ease-out);
}

.gs-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.gs-head-icon { color: var(--lila-300); font-size: 16px; }
.gs-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--fg-1);
  font: inherit;
  font-size: 17px;
  outline: none;
}
.gs-input::placeholder { color: var(--fg-4); }
.gs-input::-webkit-search-cancel-button { display: none; }

.gs-results { overflow-y: auto; padding: 6px 8px 8px; }
.gs-group + .gs-group { margin-top: 6px; }
.gs-group-label {
  padding: 10px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-4);
}
.gs-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--fg-1);
  text-decoration: none;
  cursor: pointer;
}
.gs-option:hover { color: var(--fg-1); }
.gs-option.is-active { background: rgba(169, 114, 244, 0.18); box-shadow: inset 2px 0 0 var(--lila-400); }
.gs-option.is-inactive .gs-title { color: var(--fg-3); }
.gs-thumb, .gs-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border-soft);
}
.gs-thumb { object-fit: cover; background: rgba(15, 7, 30, 0.6); }
.gs-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(169, 114, 244, 0.12);
  color: var(--lila-300);
  font-size: 14px;
}
.gs-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gs-title, .gs-subtitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-title { font-size: 14px; font-weight: 600; }
.gs-subtitle { font-size: 12px; color: var(--fg-3); }
.gs-meta { flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.gs-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(255, 110, 138, 0.14);
  color: var(--danger);
  font-size: 11px;
  font-weight: 600;
}
.gs-status:not(:empty) { padding: 14px 18px; color: var(--fg-3); font-size: 13px; text-align: center; }
.gs-foot {
  display: flex;
  gap: 18px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  color: var(--fg-4);
  font-size: 12px;
}
.gs-hint { display: inline-flex; align-items: center; gap: 6px; }

@keyframes gs-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gs-pop { from { opacity: 0; transform: translateY(-8px) scale(0.985); } to { opacity: 1; transform: none; } }

/* ---------- Search term highlight ---------- */
mark.hl {
  background: rgba(255, 210, 122, 0.28);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  box-shadow: 0 0 0 1px rgba(255, 210, 122, 0.25);
}

/* ---------- Search field (list pages) ---------- */
.search-field { position: relative; display: flex; align-items: center; flex: 1 1 320px; min-width: 220px; max-width: 480px; }
.search-field .input { padding-left: 40px; padding-right: 72px; height: 42px; font-size: 14px; }
.search-field .search-icon { position: absolute; left: 15px; color: var(--fg-3); font-size: 14px; pointer-events: none; }
.search-field input[type="search"]::-webkit-search-cancel-button,
.search-field input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-field .search-actions { position: absolute; right: 8px; display: flex; align-items: center; gap: 6px; }
.search-field .search-clear {
  display: none;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
}
.search-field .search-clear:hover { background: rgba(255, 247, 236, 0.08); color: var(--fg-1); }
.search-field .input:not(:placeholder-shown) ~ .search-actions .search-clear { display: inline-flex; align-items: center; justify-content: center; }
.search-field .input:not(:placeholder-shown) ~ .search-actions .gs-kbd,
.search-field .input:focus ~ .search-actions .gs-kbd { display: none; }

/* ---------- List toolbar (search + filters in one row) ---------- */
.list-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.list-toolbar .toolbar-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.list-toolbar .input-wrap { min-width: 0; }
.list-toolbar select.input { height: 42px; }

/* Result summary + active filter chips under the toolbar */
.filter-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
  margin: 14px 0 14px;
  font-size: 13px;
  color: var(--fg-3);
}
.card > .filter-summary:first-child { margin-top: 0; }
.filter-summary .summary-end { margin-left: auto; }
.filter-summary .result-count { color: var(--fg-2); }
.filter-summary .result-count strong { color: var(--fg-1); font-variant-numeric: tabular-nums; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-medium);
  background: rgba(169, 114, 244, 0.14);
  color: var(--fg-1);
  font-size: 12px;
  font-weight: 500;
}
.filter-chip .chip-label { color: var(--fg-3); }
.filter-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 11px;
}
.filter-chip button:hover { background: rgba(255, 247, 236, 0.12); color: var(--fg-1); }
.filter-reset-all {
  border: none;
  background: none;
  color: var(--lila-300);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.filter-reset-all:hover { color: var(--lila-200); }

/* ---------- Live loading state ---------- */
.card { position: relative; }
.card.is-live-loading::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--lila-300), var(--coral), transparent);
  background-size: 200% 100%;
  animation: live-progress 0.9s linear infinite;
}
.card.is-live-loading [data-live-dim] { opacity: 0.55; transition: opacity var(--dur-fast) var(--ease-out); }
@keyframes live-progress { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Denser data tables ---------- */
.data-table.is-compact tbody td { padding: 8px 11px; }
.data-table.is-compact thead th { padding: 11px; }
.data-table.is-compact .row-thumb,
.data-table.is-compact .row-thumb-placeholder { width: 44px; height: 44px; border-radius: 10px; }
.data-table.is-compact .row-thumb-wrap { width: 44px; }
.data-table .col-actions .flex-row { gap: 6px; }
.data-table.is-compact td:has(.row-thumb),
.data-table.is-compact td:has(.row-thumb-placeholder) { padding-top: 5px; padding-bottom: 5px; }
.data-table .nowrap, .data-table td.num { white-space: nowrap; }
.data-table .cell-sub { margin-top: 3px; }

/* Actions column stays visible when the table scrolls sideways */
.data-table .col-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #2a1550;
  box-shadow: -10px 0 14px -10px rgba(10, 4, 22, 0.9);
}
.data-table thead th.col-actions { background: #2f1a57; }
/* Opaque on zebra rows too (the striped-row rule is more specific than .col-actions),
   otherwise cells scrolling underneath show through. */
.data-table tbody tr:nth-child(even) td.col-actions { background: #2c1754; }
.data-table tbody tr:hover td.col-actions { background: #331c5e; }
/* On phones a sticky column would cover half the table: let it scroll with the rest. */
@media (max-width: 640px) {
  .data-table .col-actions { position: static; box-shadow: none; }
}

/* ---------- Coins ---------- */
.coins { white-space: nowrap; font-variant-numeric: tabular-nums; }
.coins-unit { margin-left: 4px; font-size: 0.78em; font-weight: 500; color: var(--fg-3); }
.stat-card-value .coins-unit,
.stat-readout .coins-unit { font-size: 0.45em; font-weight: 600; letter-spacing: 0; }

/* ---------- Categories list ---------- */
.category-row.is-subcategory { background: rgba(255, 247, 236, 0.025); }
.category-row .category-branch { font-size: 11px; margin-left: 12px; }
/* Main category shown only because one of its subcategories matches */
.category-row.is-context td:not(.col-actions) { opacity: 0.5; }

/* ---------- Empty state actions ---------- */
.empty-state .empty-state-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

/* ---------- Item pickers (package & notification editors) ---------- */
.item-picker { display: flex; flex-direction: column; gap: 14px; }
.picker-filters { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr); gap: 10px; }
.picker-filters select.input { height: 42px; }
.picker-panel {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: rgba(15, 7, 30, 0.45);
  overflow: hidden;
}
.picker-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-hairline);
  background: rgba(169, 114, 244, 0.06);
}
.picker-section-head .label { display: inline-flex; align-items: center; gap: 8px; }
.picker-section-head .caption { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-section-head .filter-reset-all { margin-left: auto; }
.picker-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: rgba(169, 114, 244, 0.22);
  color: var(--lila-100);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.picker-selected-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; max-height: 190px; overflow-y: auto; }
.picker-selected-list .caption { margin: 0; }
.picker-list { max-height: 380px; overflow-y: auto; }
.picker-row:focus-visible { outline: none; background: rgba(169, 114, 244, 0.2); box-shadow: inset 2px 0 0 var(--lila-400); }
.picker-inactive { margin-left: 8px; padding: 1px 7px; font-size: 10px; vertical-align: middle; }
.picker-state { padding: 26px 16px; text-align: center; color: var(--fg-3); font-size: 13px; }
.picker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-hairline);
}
@media (max-width: 900px) { .picker-filters { grid-template-columns: 1fr; } }
.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-hairline);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.picker-row:last-child { border-bottom: none; }
.picker-row:hover { background: rgba(196, 154, 255, 0.08); }
.picker-row.is-selected { background: rgba(169, 114, 244, 0.16); }
.picker-thumb {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border-soft);
  background: rgba(15, 7, 30, 0.6);
}
.picker-thumb.is-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--fg-4); font-size: 13px; }
.picker-text { flex: 1; min-width: 0; }
.picker-title { font-size: 14px; font-weight: 600; color: var(--fg-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-sub { font-size: 12px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-price { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.picker-check { flex: 0 0 auto; font-size: 17px; color: var(--fg-4); }
.picker-row.is-selected .picker-check { color: var(--lila-300); }

.picked-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 6px 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-medium);
  background: rgba(169, 114, 244, 0.14);
  font-size: 13px;
  color: var(--fg-1);
}
.picked-chip .picked-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked-chip .picked-price { color: var(--gold); font-weight: 600; white-space: nowrap; }
.picked-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
}
.picked-chip button:hover { background: rgba(255, 110, 138, 0.18); color: var(--danger); }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .gs-trigger-text { display: none; }
  .gs-trigger { width: 42px; padding: 0; justify-content: center; }
  .gs-trigger .gs-kbd { display: none; }
  .gs-foot { display: none; }
  .list-toolbar .toolbar-filters { margin-left: 0; width: 100%; }
  /* The filter dropdowns carry fixed inline widths for desktop. */
  .list-toolbar .toolbar-filters > * { flex: 1 1 150px; width: auto !important; }
  .list-toolbar .toolbar-filters .filter-popover-wrap > .btn { width: 100%; justify-content: center; }
  .search-field { max-width: none; }
}

/* ---------- Notice (inline status message) ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1px solid rgba(143, 183, 255, 0.35);
  background: rgba(143, 183, 255, 0.1);
  color: var(--fg-1);
  font-size: 13px;
  line-height: 1.45;
}
.notice > i { margin-top: 2px; color: var(--info); }
.notice-success { border-color: rgba(95, 216, 166, 0.4); background: rgba(95, 216, 166, 0.12); }
.notice-success > i { color: var(--success); }
.notice-warning { border-color: rgba(255, 194, 103, 0.4); background: rgba(255, 194, 103, 0.12); }
.notice-warning > i { color: var(--warning); }
.notice-danger { border-color: rgba(255, 110, 138, 0.4); background: rgba(255, 110, 138, 0.12); }
.notice-danger > i { color: var(--danger); }

/* ---------- Category order (drag & drop) ---------- */
.order-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr);
  gap: 24px;
  align-items: start;
}
.order-side { display: flex; flex-direction: column; gap: 24px; position: sticky; top: 96px; }
.order-list { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.order-row {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: rgba(15, 7, 30, 0.55);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.order-row:hover { border-color: var(--border-medium); }
.order-row-main { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 7px 10px 7px 6px; }
.order-row .drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  border-radius: 8px;
  color: var(--fg-4);
  cursor: grab;
}
.order-row .drag-handle:hover { color: var(--fg-2); background: rgba(196, 154, 255, 0.08); }
.order-row-label { font-weight: 600; color: var(--fg-1); }
.order-row-name { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); }
.order-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 10px 10px 34px;
  padding-left: 12px;
  border-left: 2px solid rgba(196, 154, 255, 0.18);
}
.order-children:not(:has(> .order-row)) { margin: 0; padding: 0; border: 0; }
.subcategory-item.order-row { background: rgba(255, 247, 236, 0.03); }
.subcategory-item .order-row-main { min-height: 42px; }
.order-row.sortable-chosen { border-color: var(--lila-400); box-shadow: var(--glow-lila); }
.order-row.sortable-ghost { opacity: 0.45; border-style: dashed; }
.order-status:not(:empty) { margin-top: 16px; }
.order-side-btn { width: 100%; justify-content: center; }
.order-help { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 13px; color: var(--fg-2); }
.order-help li { display: flex; align-items: flex-start; gap: 12px; line-height: 1.5; }
.order-help li > i { flex: 0 0 18px; margin-top: 3px; color: var(--lila-300); text-align: center; }
.order-help strong { color: var(--fg-1); font-weight: 600; }
@media (max-width: 1100px) {
  .order-layout { grid-template-columns: minmax(0, 1fr); }
  .order-side { position: static; }
}
