/* Fridge Assistant 網頁後台樣式
   色票與字型沿用官網 renakeung.com（正本見 project_1/Brand Website/CLAUDE.md §2、§4）。
   ⚠️ 借色票與字型，不借行銷頁的版面尺度。這是資料密集的 app 介面，
      照抄官網內文那組 17px／1.8／段距 30px 會鬆到一頁看不到幾樣食材。 */

:root {
  --page: #ffffff;
  --card: #ffffff;
  --line: #808080;
  --line-soft: #e0ddd8;
  --ink: #1a1a1a;
  --body: #4a4840;
  --sub: #8a8780;
  --red: #ce4b4d;
  --reddark: #a83a3c;
  --pink: #f6dfe0;
  --pink-line: rgba(206, 75, 77, .22);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--body);
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 1.2px;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 64px; }

/* ── 頁首與導覽 ─────────────────────────────────────────────── */

header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
h1 { font-size: 22px; font-weight: 600; color: var(--ink); margin: 0; letter-spacing: 1.2px; }
.muted { color: var(--sub); font-size: 13px; }
a { color: var(--reddark); text-decoration: none; }
a:hover { text-decoration: underline; }

nav { display: flex; gap: 8px; margin: 16px 0 20px; }
nav a {
  flex: 1; text-align: center; padding: 9px 0; border-radius: var(--radius);
  border: 1px solid var(--line-soft); color: var(--body); font-size: 14px;
  transition: border-color .15s, color .15s;
}
nav a:hover { border-color: var(--line); text-decoration: none; }
nav a[aria-current="page"] { border-color: var(--red); color: var(--reddark); font-weight: 600; }

/* ── 卡片。⚠️ 白卡在純白底上會消失，每張都必須有邊框 ──────────── */

.card {
  background: var(--card); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card > h2 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 10px; letter-spacing: 1.2px; }

/* ── 庫存列 ─────────────────────────────────────────────────── */

.item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border: 1px solid var(--line-soft);
  border-radius: var(--radius); margin-bottom: 8px;
}
.item.soon { border-color: var(--pink-line); background: var(--pink); }
.item .name { flex: 1; min-width: 0; color: var(--ink); }
.item .name b { font-weight: 600; }
.item .qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: block; font-size: 12px; color: var(--sub); letter-spacing: .6px; margin-top: 1px; }
.item.soon .tag { color: var(--reddark); font-weight: 600; }

/* 紀錄頁 */
.item .when { color: var(--sub); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .qty.up   { color: var(--reddark); font-weight: 600; }
.item .qty.down { color: var(--sub); }
.item.undone { opacity: .5; }
.item.undone .name b { text-decoration: line-through; }

/* ── 按鈕 ───────────────────────────────────────────────────── */

button {
  font-family: inherit; font-size: 14px; letter-spacing: 1.2px; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; transition: border-color .15s, background .15s, opacity .15s;
}
.btn { background: #fff; border: 1px solid var(--line-soft); color: var(--body); font-weight: 600; }
.btn:hover { border-color: var(--line); }
.btn-primary { background: var(--red); border: 1px solid var(--red); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--reddark); border-color: var(--reddark); }
.btn:disabled, .btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.step { width: 34px; padding: 6px 0; text-align: center; }

/* ── 表單 ───────────────────────────────────────────────────── */

.row { display: flex; gap: 8px; margin-bottom: 8px; }

/* ⚠️ flex 子項預設 min-width:auto，iOS Safari 的 <input type="date"> 固有寬度很大又不肯縮，
   會擠爆同一列的鄰居（iPhone 11 上「有效期限」跟「放哪」疊在一起）。這兩條是必要的。 */
.row > * { min-width: 0; flex-shrink: 1; }

input, select {
  font-family: inherit;
  /* ⚠️ 16px 不是美感選擇：iOS Safari 對小於 16px 的輸入框會在聚焦時自動放大整頁。 */
  font-size: 16px; letter-spacing: .6px; color: var(--body);
  padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: #fff; min-width: 0; width: 100%; max-width: 100%;
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
input:focus, select:focus { outline: none; border-color: var(--red); }
label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 3px; letter-spacing: .6px; }
.f-name { flex: 2.4; } .f-qty { flex: 1; } .f-unit { flex: 1.1; }

/* 窄螢幕（iPhone 11 是 375px）把「有效期限＋放哪」那列改成上下排。
   側邊擠在一起的風險直接消失，不必賭各家瀏覽器怎麼算日期框的寬度。 */
@media (max-width: 430px) {
  .row.stack { display: block; }
  .row.stack > * { margin-bottom: 8px; }
  .row.stack > *:last-child { margin-bottom: 0; }
}

/* ── 比對結果。⚠️ 這幾行是 fridge.py 算好的成品，原樣顯示 ────── */

.lines { list-style: none; padding: 0; margin: 0; }
.lines li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.lines li:last-child { border-bottom: 0; }
.lines li.warn { color: var(--reddark); font-weight: 600; }

/* ── 提示訊息 ───────────────────────────────────────────────── */

#toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px)); background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 14px; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
#toast.warn { border-color: var(--red); background: var(--pink); color: var(--reddark); }

.empty { color: var(--sub); text-align: center; padding: 22px 0; }
