/* ==========================================================================
   inventory.css — Inventory 頁面樣式（Stock / Ingredients / Suppliers 三 tab 共用）
   規格來源：reference/assets/inventory-GeD0i0NB.css + index--oEMGL0U.css
   （.table / .seg / .inline-search / .pill / .po / .sup 原值照抄）
   + docs/design-tokens.md §3（.inv-kpis margin 26 / .sup-grid 5fr·7fr）§6。
   所有顏色/字級/圓角經 styles/tokens.css variables；
   hover/狀態變色即時跳變，唔加 transition（原版 CSS 零 transition，§5.0）。
   ========================================================================== */

/* ---- 原 bundle 嘅 list/heading reset（main.css 冇，喺 .inv 範圍補返） ---- */
.inv h2, .inv h3, .inv p, .inv dl, .inv dd,
.inv ul, .inv ol { margin: 0; padding: 0; }
.inv ul, .inv ol { list-style: none; }

/* ==========================================================================
   KPI 列：4 欄 grid，margin-bottom 26px（§3 inventory 版面）
   ========================================================================== */
.inv-kpis {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 26px;
}
.inv-kpis .kpi__foot .link { font-size: var(--fs-xs); }

/* ==========================================================================
   Tabs（shell .tabs 已有底樣；呢度只補原版 tab 計數徽章細節：
   b 為 --muted 色、padding 2px 7px）
   ========================================================================== */
.inv .tab b { color: var(--muted); padding: 2px 7px; }

/* ==========================================================================
   工具列（.inv-tools）：search pill + seg + collection select
   gap 10 / margin-bottom 14（原值）
   ========================================================================== */
.inv-tools {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 10px; margin-bottom: 14px;
}

/* inline search：40px 高、20px 圓角 pill（原值） */
.inline-search { flex: 1; min-width: 180px; max-width: 320px; position: relative; }
.inline-search .ico {
  width: 16px; height: 16px; color: var(--muted);
  position: absolute; top: 50%; left: 14px; margin-top: -8px;
}
.inline-search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 20px;
  font: inherit; font-size: var(--fs-md); color: var(--text);
  outline: none;
}
.inline-search input::placeholder { color: var(--muted); }
.inline-search input:focus { border-color: var(--primary); }

/* Seg：--well 底、22px 圓角、4px padding；thumb 面 --surface + FLIP（§5.2）。
   thumb 位置由 scripts/views/inventory.js 用 Olvara.flipTo 管理 clip-path。 */
.seg {
  position: relative; display: inline-flex; flex: none;
  width: max-content; padding: 4px;
  background: var(--well); border-radius: 22px;
}
.seg__thumb {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--surface);
  clip-path: inset(4px calc(100% - 4px) 4px 4px round 18px);
  opacity: 0;
  box-shadow: 0 1px 2px #00000014, 0 4px 12px -6px #00000040;
}
.seg button {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border: 0; background: none; border-radius: 18px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted);
  white-space: nowrap; cursor: pointer;
}
.seg button[aria-pressed="true"] { color: var(--text); }

/* Low 計數徽章：bad tone 14% mix、radius 8 */
.inv-badge {
  padding: 1px 6px;
  background: color-mix(in srgb, var(--bad) var(--soft), transparent);
  color: var(--bad); border-radius: 8px;
  font-size: var(--fs-2xs); font-weight: 700;
}

/* Collection select：base 44px/--r-ctl/--surface-2 → inv 版 40px/20px/--surface */
.select {
  appearance: none;
  width: 100%; height: 44px; padding: 0 14px;
  background-color: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: var(--r-ctl);
  font: inherit; font-size: var(--fs-md); color: var(--text);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2359645e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 36px;
  cursor: pointer;
}
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.inv-select { width: auto; height: 40px; background-color: var(--surface); border-radius: 20px; }

/* ==========================================================================
   表格（原 bundle .table 原值）
   ========================================================================== */
.table-wrap { margin: 0 -20px -20px; overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; font-size: var(--fs-md); }
.table th {
  padding: 10px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table :is(th, td):first-child { padding-left: 20px; }
.table :is(th, td):last-child { padding-right: 20px; }
.table .num { text-align: right; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--text) 3%, transparent); }
.tnum { font-variant-numeric: tabular-nums; }

/* 產品格（icon/縮圖 + 名 + 細字） */
.cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell b { display: block; font-weight: 600; }
.cell small { display: block; color: var(--muted); }
.cell > div { min-width: 0; }

/* 縮圖 placeholder：分類色 tint gradient + 縮寫（原版照片唔搬） */
.thumb {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px;
  border-radius: 12px; overflow: hidden;
}
.thumb--sm { width: 34px; height: 34px; border-radius: 10px; }
.thumb--ph {
  background: var(--grad-thumb);
  color: color-mix(in srgb, var(--mono-ink) 72%, transparent);
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: .02em;
}
/* 分類 tint：用 chart 分類色 tokens（design-tokens §1 分類色） */
.t-serums   { background: linear-gradient(135deg, color-mix(in srgb, var(--c-serums) 16%, var(--surface)), color-mix(in srgb, var(--c-serums) 42%, var(--surface))); color: color-mix(in srgb, var(--c-serums) 60%, var(--mono-ink)); }
.t-oils     { background: linear-gradient(135deg, color-mix(in srgb, var(--c-oils) 20%, var(--surface)), color-mix(in srgb, var(--c-oils) 48%, var(--surface))); color: color-mix(in srgb, var(--c-oils) 62%, var(--mono-ink)); }
.t-cleansers{ background: linear-gradient(135deg, color-mix(in srgb, var(--c-cleansers) 16%, var(--surface)), color-mix(in srgb, var(--c-cleansers) 42%, var(--surface))); color: color-mix(in srgb, var(--c-cleansers) 60%, var(--mono-ink)); }
.t-balms    { background: linear-gradient(135deg, color-mix(in srgb, var(--c-balms) 18%, var(--surface)), color-mix(in srgb, var(--c-balms) 44%, var(--surface))); color: color-mix(in srgb, var(--c-balms) 60%, var(--mono-ink)); }
.t-body     { background: linear-gradient(135deg, color-mix(in srgb, var(--c-body) 18%, var(--surface)), color-mix(in srgb, var(--c-body) 44%, var(--surface))); color: color-mix(in srgb, var(--c-body) 62%, var(--mono-ink)); }
.t-home     { background: linear-gradient(135deg, color-mix(in srgb, var(--c-home) 18%, var(--surface)), color-mix(in srgb, var(--c-home) 44%, var(--surface))); color: color-mix(in srgb, var(--c-home) 62%, var(--mono-ink)); }

/* ---- inventory 表格專屬 ---- */
.inv-table td { vertical-align: middle; }
.inv-level { min-width: 200px; }
.inv-level .meter { max-width: 220px; margin-bottom: 6px; }
.inv-level small { display: block; color: var(--muted); }
.inv-level b { color: var(--text); font-weight: 600; }
.inv-level b.is-low, .is-low { color: var(--bad) !important; }
.inv-acts { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }

/* Ingredient 格：學名斜體 / 供應商國家兩行 */
.inv-inci {
  display: block; max-width: 32ch; overflow: hidden;
  color: var(--muted);
  font-style: italic;
  white-space: nowrap; text-overflow: ellipsis;
}
.inv-sub { display: block; }

/* 淺綠圓 icon（葉/滴）：40px、12px 圓角、tile-sage 底 */
.inv-ico {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px;
  background: var(--tile-sage); color: var(--on-tile);
  border-radius: 12px;
}
.inv-ico .ico { width: 18px; height: 18px; }

/* Used in：34px 縮圖疊（-8px）、白 2px ring */
.inv-used { display: flex; }
.inv-used > span + span { margin-left: -8px; }
.inv-used .thumb { box-shadow: 0 0 0 2px var(--surface); }

/* ==========================================================================
   Tone pill（原 bundle 版本：帶 6px 圓點；default muted；
   覆蓋 main.css 嘅簡化版——原版 spec 優先）
   ========================================================================== */
.pill {
  --t: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  background: color-mix(in srgb, var(--t) var(--soft), transparent);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; color: var(--t);
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill[data-tone="good"] { --t: var(--good); }
.pill[data-tone="warn"] { --t: var(--warn); }
.pill[data-tone="bad"] { --t: var(--bad); }
.pill[data-tone="info"] { --t: var(--info); }
.pill[data-tone="primary"] { --t: var(--primary); }

/* ==========================================================================
   Suppliers tab：.sup-grid 5fr/7fr + PO 卡 + supplier 卡 grid
   ========================================================================== */
.sup-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--gap);
  align-items: start;
}

/* card head（PO 卡 title + sub + seg） */
.card__head { display: flex; align-items: center; gap: 12px; min-height: 34px; margin-bottom: 16px; }
.card__head > div:first-child { flex: 1; min-width: 0; }
.card__sub { margin-top: 2px; font-size: var(--fs-sm); color: var(--muted); }

/* ---- PO 卡 ---- */
.po-list { display: grid; gap: 10px; }
.po {
  display: grid; gap: 12px; padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 16px;
}
.po__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.po__head b { display: block; font-size: var(--fs-lg); font-weight: 600; }
.po__head small { font-size: var(--fs-xs); }
.po__lines { display: grid; gap: 4px; font-size: var(--fs-md); }
.po__lines li { display: flex; justify-content: space-between; gap: 10px; }
.po__lines b { font-weight: 600; }
.po__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line); padding-top: 10px;
}
.po__foot > b { font-size: var(--fs-lg); font-weight: 600; }

/* PO stepper：三點兩線；完成段深綠實心、未完成空心（原值） */
.po-step { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); }
.po-step li {
  position: relative; display: grid; justify-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
}
.po-step li::before {
  content: ""; position: absolute; top: 6px; left: -50%;
  width: 100%; height: 2px; background: var(--line-2);
}
.po-step li:first-child::before { display: none; }
.po-step li.is-done::before { background: var(--primary); }
.po-step i {
  position: relative; z-index: 1;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--line-2);
}
.po-step li.is-done i { background: var(--primary); border-color: var(--primary); }
.po-step li.is-done { color: var(--text); }

/* ---- Supplier 卡 grid（2 欄）----
   mono 方塊底色輪換：1/4 apricot、3n+2 mist、3n sage（原 bundle nth 規則照抄） */
.sup-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.sup { display: flex; flex-direction: column; gap: 12px; }
/* 原版截圖入面 Nordic Actives 係淡出狀態（照任務規格還原；
   原版 raw 呢個狀態係進場 stagger 動畫中途） */
.sup--dim { opacity: .45; }
.sup__head { display: flex; align-items: center; gap: 12px; }
.sup__mono {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--tile-apricot); color: var(--on-tile);
  font-size: var(--fs-md); font-weight: 700;
}
.sup:nth-child(3n+2) .sup__mono { background: var(--tile-mist); }
.sup:nth-child(3n) .sup__mono { background: var(--tile-sage); }
.sup__makes { font-size: var(--fs-md); color: var(--muted); }
.sup__facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 8px; }
.sup__facts dt { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.sup__facts dd { display: flex; align-items: center; gap: 4px; font-weight: 600; }
.sup__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
}

/* 五粒星（amber fill，13px） */
.stars { display: inline-flex; gap: 1px; color: var(--amber-fill); }
.stars svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.stars svg.off { color: var(--line-2); }

/* ==========================================================================
   Responsive（原 bundle 斷點照抄）
   ========================================================================== */
@media (max-width: 1279px) {
  .sup-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .inv-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 999px) {
  .hide-md { display: none !important; }
}
@media (max-width: 760px) {
  .inv-kpis { gap: 10px; margin-bottom: 20px; }
  .inv .card { padding: 16px; }
  .inv-tools .inline-search { flex-basis: 100%; max-width: none; }
  .card__head { flex-wrap: wrap; row-gap: 10px; }
  .card__head > div:first-child { min-width: min(100%, 170px); }
  .sup-cards { grid-template-columns: minmax(0, 1fr); }

  .table-wrap { margin: 0 -16px -16px; }
  .inv-acts { flex-wrap: wrap; justify-content: flex-start; }
  .inv-level .meter { max-width: none; }

  /* table--stack：表格變卡（原 bundle ≤760 規則照抄） */
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { width: 100%; display: block; }
  .table--stack tr { display: grid; grid-template-columns: 1fr; align-items: center; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .inv-table tr { grid-template-columns: 1fr; }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: 0 !important; }
  .inv-table td.num { text-align: left; }
  .table--stack td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: var(--fs-xs); }
}
