/* Catalog module styles (populated by Tasks 7-11). Created as a shell in
   Task 6 so header.ejs can link it unconditionally on every page; design
   tokens live in tokens.css — use those custom properties, no raw colors.
   Everything here is class-driven: the CSP forbids inline styles, so even the
   scoring-guide weight bars get their widths from utility classes below. */

/* ---------- Dashboard: stat cards ---------- */
.cat-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.cat-stat { display: flex; flex-direction: column; gap: 6px; padding: 20px; }
.cat-stat-label { font-size: 13px; font-weight: 500; color: hsl(var(--text-200)); }
.cat-stat-value { font-family: var(--font-serif); font-size: 30px; line-height: 1.1; }

/* ---------- Dashboard: category tiles ---------- */
.cat-section-title { font-size: 18px; margin: 20px 0 14px; }
.cat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.cat-tile {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 20px; margin: 0;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.cat-tile:hover {
  text-decoration: none;
  border-color: hsl(var(--accent-100) / 0.55);
  background: hsl(var(--border) / 0.04);
}
.cat-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cat-tile-label { font-weight: 600; font-size: 14.5px; }
.cat-tile-head .ic { font-size: 16px; color: hsl(var(--text-400)); }
/* Two lines of description reserved so the series/parts row lines up across
   tiles whose descriptions wrap differently. */
.cat-tile-desc { font-size: 13px; line-height: 1.5; color: hsl(var(--text-200)); min-height: 39px; }
.cat-tile-meta { display: flex; gap: 16px; align-items: baseline; }
.cat-tile-series { font-size: 13px; font-weight: 600; color: hsl(var(--accent-100)); }
.cat-freshness { margin-top: 4px; }

/* ---------- Scoring guide: weight bars ---------- */
.score-bars { display: flex; flex-direction: column; gap: 10px; }
.score-bar { display: flex; align-items: center; gap: 12px; }
.score-bar-label { width: 130px; flex-shrink: 0; font-size: 13.5px; font-weight: 500; }
.score-bar-track {
  flex: 1; height: 18px; border-radius: var(--radius-full);
  background: hsl(var(--border) / 0.1); overflow: hidden;
}
.score-bar-fill { display: block; height: 100%; border-radius: var(--radius-full); }
.score-bar-weight { width: 44px; text-align: right; font-size: 13.5px; font-weight: 700; }

/* Widths as classes (CSP: no inline style attributes). */
.score-w40 { width: 40%; }
.score-w25 { width: 25%; }
.score-w20 { width: 20%; }
.score-w15 { width: 15%; }

/* Component colors mirror the CRM's blue/emerald/amber/rose. */
.score-velocity { background: hsl(var(--info-100)); }
.score-efficiency { background: hsl(var(--success-100)); }
.score-concentration { background: hsl(var(--warning-100)); }
.score-pressure { background: hsl(var(--danger-100)); }

.score-component { margin-top: 22px; }
.score-component:first-of-type { margin-top: 0; }
.score-component h3 { font-size: 14.5px; margin: 0 0 4px; }
.score-component .table-wrap { margin-top: 10px; border: 1px solid hsl(var(--border) / 0.1); border-radius: var(--radius-sm); }
.score-velocity-text { color: hsl(var(--info-100)); }
.score-efficiency-text { color: hsl(var(--success-100)); }
.score-concentration-text { color: hsl(var(--warning-100)); }
.score-pressure-text { color: hsl(var(--danger-100)); }
.score-good-text { color: hsl(var(--success-100)); }
.score-zero-text { color: hsl(var(--danger-100)); }

/* ---------- Scoring guide: classification pills ---------- */
/* Five tiers, four semantic token families: SLOW MOVER and OBSOLETE both read
   "bad", so they are separated by weight (tinted vs. solid danger) rather than
   by inventing an orange that is not in the token set. */
.cls {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.cls-stock-up { background: hsl(var(--success-900)); color: hsl(var(--success-100)); }
.cls-healthy { background: hsl(var(--info-900)); color: hsl(var(--info-100)); }
.cls-review { background: hsl(var(--warning-900)); color: hsl(var(--warning-100)); }
.cls-slow-mover { background: hsl(var(--danger-100) / 0.16); color: hsl(var(--danger-100)); }
.cls-obsolete { background: hsl(var(--danger-900)); color: hsl(var(--danger-000)); }

.col-name { font-weight: 500; width: 150px; }

/* Score bands (inventory table): same four token families as the pills above,
   with the two "bad" tiers separated by weight rather than a new hue. */
.cat-score { font-weight: 600; }
.score-90 { color: hsl(var(--success-100)); }
.score-70 { color: hsl(var(--info-100)); }
.score-50 { color: hsl(var(--warning-100)); }
.score-25 { color: hsl(var(--danger-100)); }
.score-0 { color: hsl(var(--danger-000)); }

/* Shared cell-state colors: good/warn/bad for threshold columns (HHI, days of
   supply, backorders, net position) and up/down/flat for the trend arrow. */
.cat-good { color: hsl(var(--success-100)); }
.cat-warn { color: hsl(var(--warning-100)); }
.cat-bad { color: hsl(var(--danger-100)); }
.cat-up { color: hsl(var(--success-100)); }
.cat-down { color: hsl(var(--danger-100)); }
.cat-flat { color: hsl(var(--text-400)); }

/* ---------- Category / routers pages: series tiles ---------- */
.cat-series-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.cat-series-tile { display: flex; flex-direction: column; gap: 10px; padding: 16px; margin: 0; }
.cat-series-media {
  display: flex; align-items: center; justify-content: center;
  height: 130px; border-radius: var(--radius-sm);
  background: #fff; /* product shots are white-background JPEGs */
  overflow: hidden;
}
.cat-series-img { max-width: 92%; max-height: 92%; object-fit: contain; }
.cat-series-noimg { font-size: 13px; }
.cat-series-name { color: inherit; font-size: 13.5px; line-height: 1.45; }
.cat-series-name strong { color: hsl(var(--accent-100)); margin-right: 4px; }
.cat-series-name:hover { text-decoration: none; color: hsl(var(--accent-100)); }
.cat-series-pdfs { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.cat-series-pdfs a { display: inline-flex; align-items: center; gap: 5px; }
.cat-series-pdfs .ic { font-size: 13px; }

/* ---------- Series page ---------- */
.cat-series-title { display: flex; flex-direction: column; gap: 2px; }
.cat-series-title span:first-child { font-size: 26px; }
.cat-series-title span + span { font-size: 15px; font-weight: 400; color: hsl(var(--text-200)); }

.cat-series-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
}
.cat-media-card, .cat-specs-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; margin: 0; }
.cat-media-label { margin: 0; font-size: 13px; font-weight: 600; color: hsl(var(--text-200)); }
/* The zoom trigger is a real <button> (keyboard-reachable), stripped bare. */
.cat-zoom-btn {
  display: flex; align-items: center; justify-content: center;
  flex: 1; min-height: 150px; padding: 8px;
  border: 0; border-radius: var(--radius-sm);
  background: #fff; cursor: zoom-in;
}
.cat-media-img { max-width: 100%; max-height: 220px; object-fit: contain; }
.cat-media-hint { font-size: 11.5px; }

.cat-specs { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
.cat-specs dt { font-weight: 600; color: hsl(var(--text-200)); white-space: nowrap; }
.cat-specs dd { margin: 0; line-height: 1.5; }
.cat-spec-strong { font-weight: 700; }

/* ---------- Click-to-zoom overlay (built by catalog.js) ---------- */
.cat-zoom-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
  background: hsl(0 0% 0% / 0.72);
  cursor: zoom-out;
}
.cat-zoom-overlay[hidden] { display: none; }
.cat-zoom-overlay img {
  max-width: min(1100px, 94vw); max-height: 90vh;
  object-fit: contain;
  background: #fff; border-radius: var(--radius-sm); padding: 12px;
}

/* ---------- Parts table ---------- */
.cat-table-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; }
.cat-table-count { font-size: 13px; }
.cat-unit-toggle .seg-item { cursor: pointer; font: inherit; font-size: 12.5px; }
.cat-table-card { padding: 0; }
.cat-table th { white-space: nowrap; }
.cat-table .cat-num { text-align: right; }
.cat-sortable { cursor: pointer; user-select: none; }
.cat-sortable:hover { color: hsl(var(--accent-100)); }
/* Sort direction indicator: fixed-width slot so headers don't shift. */
.cat-sortable::after { content: ''; display: inline-block; width: 14px; color: hsl(var(--accent-100)); }
.cat-sort-asc::after { content: ' \25B2'; font-size: 10px; }
.cat-sort-desc::after { content: ' \25BC'; font-size: 10px; }
.cat-filter-row th { padding: 4px 8px 10px; }
.cat-filter-row input {
  width: 100%; min-width: 70px; padding: 5px 8px;
  font: inherit; font-size: 12.5px;
  color: hsl(var(--text-100));
  background: hsl(var(--bg-000));
  border: 1px solid hsl(var(--border) / 0.15);
  border-radius: var(--radius-sm);
}
.cat-filter-row input:focus { outline: none; border-color: hsl(var(--accent-100)); }
.cat-no-match { margin: 10px 2px; }
.cat-parts-empty { padding: 26px 20px; text-align: center; }

/* ---------- Parts list page (server-side sort / filter / pagination) ---------- */
.cat-parts-bar { flex-wrap: wrap; gap: 10px 16px; }
.cat-parts-search input { flex: 1; min-width: 220px; }
.cat-parts-tools { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.cat-parts-table th { vertical-align: bottom; }
/* Ids, quantities and dates never wrap; ERP descriptions are long
   dash-separated codes, so only that column wraps — otherwise it pushes Last
   Order out of view and the whole table needs horizontal scrolling. */
.cat-parts-table td { white-space: nowrap; }
.cat-parts-table .cat-desc { white-space: normal; min-width: 240px; }
.cat-mono { font-family: var(--font-mono); font-size: 12.5px; }
/* Header links carry the sort marker; ::after reserves the arrow slot so
   headers don't shift when the active column changes (mirrors .cat-sortable,
   which is the client-side table's equivalent). */
.cat-sort { color: inherit; }
.cat-sort:hover { color: hsl(var(--accent-100)); text-decoration: none; }
.cat-sort::after { content: ''; display: inline-block; width: 14px; color: hsl(var(--accent-100)); }
/* Two classes so these win over the single-class .cat-sort::after reset above
   regardless of source order (the client table's markers are th-level). */
.cat-sort.cat-sort-asc::after { content: ' \25B2'; font-size: 10px; }
.cat-sort.cat-sort-desc::after { content: ' \25BC'; font-size: 10px; }
.cat-parts-hint { margin: 0 2px 10px; font-size: 12.5px; }
.cat-parts-none { padding: 26px 12px; text-align: center; color: hsl(var(--text-200)); }
.cat-pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; }
.cat-pager-off { opacity: 0.45; pointer-events: none; }

/* ---------- Infinite scroll (progressive enhancement) ---------- */
/* Both of these set `display` themselves, so the UA's [hidden] rule loses to
   them — the author-level overrides below are what actually hide them when
   public/catalog.js sets .hidden. */
.cat-pager[hidden] { display: none; }
.cat-infinite-retry[hidden] { display: none; }
.cat-infinite-retry { margin-top: 14px; }
/* The observed sentinel: zero visual weight, just a position after the table. */
.cat-infinite-sentinel { height: 1px; }
.cat-infinite-sentinel[hidden] { display: none; }

/* ---------- Inventory management page ---------- */
/* Filter bar: search box, four selects and the record count on one wrapping
   row. Fields are labeled above their control so 21-column jargon ("HHI",
   "Net Pos") is explained by the guide link rather than by the bar. */
.cat-inv-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin: 0 0 12px; }
.cat-inv-search { flex: 1 1 260px; }
.cat-inv-search input { flex: 1; min-width: 200px; }
.cat-inv-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.cat-inv-label { font-size: 12px; font-weight: 500; color: hsl(var(--text-400)); }
.cat-inv-field select { margin-top: 0; font-size: 13px; padding: 6px 8px; }
.cat-inv-tools { display: flex; align-items: baseline; gap: 14px; font-size: 13px; margin-left: auto; }
/* 21 columns: nothing wraps, and .table-wrap does the scrolling so the page
   itself never gains a horizontal scrollbar. Descriptions are capped instead
   of wrapped — a wrapped one would make every row three lines tall. */
.cat-inv-table th, .cat-inv-table td { white-space: nowrap; }
.cat-inv-table .cat-inv-desc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.cat-inv-table td { padding-top: 7px; padding-bottom: 7px; }

/* ---------- Part detail page ---------- */
.cat-back { margin: 0 0 12px; font-size: 13px; }
.cat-back a { display: inline-flex; align-items: center; gap: 5px; }
.cat-back .ic { font-size: 13px; }
.cat-part-title { margin: 0; }
.cat-part-id-text { color: hsl(var(--accent-100)); }
.cat-part-desc { margin: 4px 0 0; font-size: 14px; }
/* Five cards; the value line shrinks for the two text-y cards so MIN/MAX and
   the year range fit without wrapping badly. */
.cat-part-cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.cat-stat-value-sm { font-size: 20px; line-height: 1.3; }

/* ---------- Charts (server-rendered SVG; colors ONLY via these classes) ---------- */
.cat-charts { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.cat-chart-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; margin: 0; }
.cat-chart-card h3 { margin: 0; font-size: 14.5px; }
.cat-chart-sub { font-weight: 400; font-size: 12.5px; }
.cat-chart svg { display: block; width: 100%; height: auto; }
.chart-bar { fill: hsl(var(--accent-100)); }
.chart-line { fill: none; stroke: hsl(var(--accent-100)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: hsl(var(--accent-100) / 0.18); stroke: none; }
.chart-dot { fill: hsl(var(--accent-100)); }
.chart-axis { stroke: hsl(var(--border) / 0.35); stroke-width: 1; }
.chart-grid { stroke: hsl(var(--border) / 0.1); stroke-width: 1; }
.chart-tick { fill: hsl(var(--text-400)); font-size: 10.5px; }
.chart-empty { fill: hsl(var(--text-400)); font-size: 13px; }

/* Rolling-demand controls: view links (styled as the segmented toggle) plus a
   plain GET form — no JS involved. */
.cat-chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.cat-view-toggle .seg-item { cursor: pointer; }
.cat-weeks-form { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cat-weeks-form label { color: hsl(var(--text-200)); }
.cat-weeks-form input[type="number"] {
  width: 74px; padding: 5px 8px;
  font: inherit; font-size: 13px;
  color: hsl(var(--text-100));
  background: hsl(var(--bg-000));
  border: 1px solid hsl(var(--border) / 0.15);
  border-radius: var(--radius-sm);
}
.cat-weeks-form input[type="number"]:focus { outline: none; border-color: hsl(var(--accent-100)); }

/* Part-page tables: every cell is short (dates, money, ids) — keep them on
   one line and let .table-wrap's horizontal scroll do its job. */
.cat-nowrap td { white-space: nowrap; }

/* ---------- Order status badges (order-level status, CRM mapping) ---------- */
.cat-badge {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.cat-badge-complete { background: hsl(var(--success-900)); color: hsl(var(--success-100)); }
.cat-badge-shipped { background: hsl(var(--info-900)); color: hsl(var(--info-100)); }
.cat-badge-remaining { background: hsl(var(--accent-900)); color: hsl(var(--accent-100)); }
.cat-badge-onhold { background: hsl(var(--warning-900)); color: hsl(var(--warning-100)); }
.cat-badge-cancelled { background: hsl(var(--danger-900)); color: hsl(var(--danger-000)); }
.cat-badge-pending { background: hsl(var(--border) / 0.1); color: hsl(var(--text-200)); }

