/* 查价页样式 —— 手机优先（销售在企微里用手机点开）
 *
 * 【颜色纪律】颜色值只允许出现在下方 :root 里，本文件其余部分一律用 var()。
 * 【不用紫→粉渐变】项目 P0 红线，本文件无任何 gradient。
 * 【不用 emoji 作功能图标】图标全是内联 SVG stroke。
 */

/* ---- Design Tokens（引自 docs/phase1/design-tokens.css，只取用到的） ---- */
:root {
  /* 表面与前景 */
  --bg:            #F4F6F7;
  --surface:       #FFFFFF;
  --surface-muted: #FAFBFC;
  --surface-sunken:#EAEEF0;
  --fg:            #16232B;
  --fg-2:          #4A5C66;
  --muted:         #64757F;
  --meta:          #7D8F98;

  /* 边框 */
  --border:        #DCE2E6;
  --border-strong: #7D8F98;

  /* 品牌（墨青） */
  --brand:         #1D4E5F;
  --brand-hover:   #16404E;
  --brand-tint:    #E8F0F3;
  --brand-ring:    rgba(29, 78, 95, 0.32);

  /* 语义 */
  --danger:        #B42318;
  --danger-tint:   #FDE7E4;
  --success:       #15803D;
  --success-tint:  #D8F2E0;
  --warn:          #A15C00;
  --warn-tint:     #FDF0DC;
  --info:          #175CD3;
  --info-tint:     #E3EDFC;

  /* 行状态 */
  --row-best-bg:   #E4EFF2;
  --row-best-ink:  #0F323D;
  --row-none-bg:   #F1F3F4;

  /* 字体 */
  --font-body: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --text-xs:  0.75rem;
  --text-sm:  0.8125rem;
  --text-base:0.875rem;
  --text-lg:  1.125rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.75rem;

  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;

  /* 触摸与焦点（无障碍硬要求） */
  --a11y-min-touch: 44px;
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand-ring);
  --shadow-float: rgba(22, 35, 43, 0.12);
  --gutter: var(--space-4);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 768px) {
  :root { --gutter: var(--space-6); }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- 顶栏 + 搜索框（吸顶） ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { max-width: 720px; margin: 0 auto; padding: var(--space-3) var(--gutter); }
.topbar__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg); font-weight: 600;
  letter-spacing: -0.01em;
}

.search { display: flex; align-items: center; gap: var(--space-2); position: relative; }
.search__icon {
  position: absolute; left: var(--space-3);
  width: 20px; height: 20px; pointer-events: none;
  fill: none; stroke: var(--muted); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.search__input {
  flex: 1; min-width: 0;
  /* 🔴 触摸目标 ≥44px */
  height: var(--a11y-min-touch);
  padding: 0 var(--space-3) 0 40px;
  font-family: inherit; font-size: 1rem; color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}
.search__input::placeholder { color: var(--meta); }
.search__input:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
.search__btn {
  height: var(--a11y-min-touch); padding: 0 var(--space-4);
  font-family: inherit; font-size: var(--text-base); font-weight: 500;
  color: var(--surface); background: var(--brand);
  border: none; border-radius: var(--radius-md); cursor: pointer;
}
.search__btn:hover { background: var(--brand-hover); }
.search__btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---- 主体 ---- */
.main {
  max-width: 720px; margin: 0 auto;
  padding: var(--space-4) var(--gutter) calc(var(--space-8) + var(--safe-bottom));
}

/* ---- 首屏提示 ---- */
.hint {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.hint__lead { margin: 0 0 var(--space-3); color: var(--fg-2); }
.hint__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  min-height: var(--a11y-min-touch); padding: 0 var(--space-4);
  font-family: inherit; font-size: var(--text-base);
  color: var(--brand); background: var(--brand-tint);
  border: 1px solid var(--brand); border-radius: var(--radius-pill);
  cursor: pointer;
}
.chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---- 结果计数条 ---- */
.count {
  margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm); color: var(--fg-2);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.count strong { color: var(--fg); font-variant-numeric: tabular-nums; }

/* ---- 候选清单 ---- */
.cand {
  display: block; width: 100%; text-align: left;
  min-height: var(--a11y-min-touch);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  font-family: inherit; color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
}
.cand:hover { border-color: var(--brand); }
.cand:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--brand); }
.cand__name {
  margin: 0 0 var(--space-1);
  font-size: var(--text-base); font-weight: 500; line-height: 1.4;
  word-break: break-word;
}
.cand__meta {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-2); font-size: var(--text-sm); color: var(--muted);
}
.cand__cap { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.cand__price {
  margin-top: var(--space-2);
  font-size: var(--text-lg); font-weight: 600;
  font-variant-numeric: tabular-nums; color: var(--brand);
}
.cand__none { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--muted); }

/* ---- 商品详情 ---- */
.detail__title { margin: 0 0 var(--space-1); font-size: var(--text-lg); font-weight: 600; line-height: 1.4; }
.detail__sub { margin: 0 0 var(--space-4); font-size: var(--text-sm); color: var(--muted); }

.lowest {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  background: var(--row-best-bg); color: var(--row-best-ink);
  border-radius: var(--radius-lg);
}
.lowest__label { font-size: var(--text-sm); }
.lowest__value { font-size: var(--text-3xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.lowest__note { flex-basis: 100%; font-size: var(--text-sm); }

/* 「有 0 元报价」与「价格可能已变动」都是要销售注意的事，
   共用 warn 色系 —— 不是 danger：这两种都不是系统故障。 */
.zero, .stale {
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3);
  font-size: var(--text-sm); color: var(--warn);
  background: var(--warn-tint); border-radius: var(--radius-sm);
}
.zero { padding: var(--space-2) var(--space-3); }

/* 🔴 陈旧提示条刻意醒目：销售拿着旧价去报客户会直接亏钱。
   左侧色条让它在长列表里一眼可见。 */
.stale { border-left: 3px solid var(--warn); }
.stale p { margin: 0 0 var(--space-1); font-size: var(--text-sm); color: var(--fg-2); }
.stale__lead { font-size: var(--text-base); font-weight: 600; color: var(--warn); }
.stale__hint { margin-bottom: 0; }

/* 🔴 窄屏表格必须横向滚动，而不是挤成一团 */
.tablewrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.groups { width: 100%; border-collapse: collapse; min-width: 320px; }
.groups th, .groups td {
  padding: var(--space-2) var(--space-3); text-align: left;
  vertical-align: top; border-bottom: 1px solid var(--border);
  font-size: var(--text-sm); line-height: 1.5;
}
.groups thead th {
  position: sticky; top: 0; background: var(--surface-sunken);
  color: var(--fg-2); font-weight: 500; white-space: nowrap;
}
.groups tbody tr:last-child td { border-bottom: none; }
.groups tbody tr.is-best { background: var(--row-best-bg); }
.g-label { font-weight: 500; color: var(--fg); white-space: nowrap; }
.g-price {
  font-size: var(--text-base); font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.g-price--zero { color: var(--warn); }
.g-src { color: var(--fg-2); }
.g-src span { display: block; }
.g-time { color: var(--meta); font-size: var(--text-xs); }
.g-badge {
  display: inline-block; margin-left: var(--space-1);
  padding: 0 var(--space-2);
  font-size: var(--text-xs); color: var(--success);
  background: var(--success-tint); border-radius: var(--radius-sm);
}

.empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }
.empty__lead { margin: 0 0 var(--space-2); font-size: var(--text-base); color: var(--fg-2); }
.empty__hint { margin: 0; font-size: var(--text-sm); }

/* ---- 返回按钮（固定底部，拇指可及） ---- */
.back {
  position: fixed; left: var(--gutter); bottom: calc(var(--space-4) + var(--safe-bottom));
  z-index: 20;
  display: flex; align-items: center; gap: var(--space-1);
  min-height: var(--a11y-min-touch); padding: 0 var(--space-4);
  font-family: inherit; font-size: var(--text-base);
  color: var(--brand); background: var(--surface);
  border: 1px solid var(--brand); border-radius: var(--radius-pill);
  box-shadow: 0 2px 8px var(--shadow-float);
  cursor: pointer;
}
/* 🔴 `[hidden]` 的默认 `display: none` 会被上面的 `display: flex` 覆盖
   （同特异度下后声明者胜），导致 hidden=true 时按钮**依然可见**、
   悬浮在候选清单上遮内容。必须显式声明。 */
.back[hidden] { display: none; }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* 详情页打开时给底部留出返回按钮的位置，避免遮住最后一行 */
body.detail .main { padding-bottom: calc(var(--space-16) + var(--safe-bottom)); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
