/* ============================================================
   ChefsMate 後台主控台 — 設計系統
   日系侘寂 / 暖米白 + sage teal + 粉彩分類色（不做 dark mode）
   ============================================================ */

:root {
  --bg:        #F0EEEA;
  --bg-2:      #E8E5DF;
  --surface:   #FFFFFF;
  --surface-2: #F7F5F1;
  --line:      #E4DFD7;
  --line-soft: #EDE9E2;

  --ink:   #3A3530;
  --ink-2: #6E665C;
  --ink-3: #9E968B;

  /* sage teal primary */
  --accent:      #7CA39C;
  --accent-2:    #688B84;
  --accent-soft: #DEEAE7;
  --brand:       #97B3AE;

  /* pastel category colours */
  --c-sage:      #97B3AE;
  --c-mint:      #9FBE9C;
  --c-blush:     #D8A7A0;
  --c-coral:     #C58A7E;
  --c-taupe:     #B7A99A;
  --c-tan:       #C9A180;
  --c-sand:      #D8BE92;
  --c-bluegrey:  #97A8B6;
  --c-purple:    #B8A0BD;

  /* semantic */
  --ok:        #7FA083;
  --ok-soft:   #E1ECDF;
  --warn:      #C9A180;
  --warn-soft: #F2E7D6;
  --block:     #C58A7E;
  --block-soft:#F3E1DC;
  --info:      #97A8B6;
  --info-soft: #E2E8ED;
  --idle:      #C8C1B6;

  /* gantt stage hues (reused GanttView) */
  --st-spec:    #C9A180;
  --st-design:  #D8A7A0;
  --st-develop: #7CA39C;
  --st-test:    #97A8B6;
  --st-review:  #B8A0BD;
  --st-deploy:  #7FA083;

  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px rgba(58,53,48,0.05), 0 1px 3px rgba(58,53,48,0.04);
  --shadow:    0 4px 16px rgba(58,53,48,0.07), 0 1px 4px rgba(58,53,48,0.05);
  --shadow-lg: 0 22px 60px rgba(58,53,48,0.16), 0 6px 18px rgba(58,53,48,0.08);

  --sans:  -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --serif: var(--sans);
  --mono:  ui-monospace, "SF Mono", "JetBrains Mono", "Noto Sans Mono", monospace;

  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
  line-height: 1.5;
}
#root { height: 100%; }
::selection { background: var(--accent-soft); }

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 20px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ---------- shell ---------- */
.app { display: flex; height: 100%; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px; gap: 2px;
  min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 14px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(150deg, var(--brand), var(--accent-2));
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--ink-3); }

.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); padding: 14px 10px 5px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 13.5px; font-weight: 600;
  border: none; background: none; width: 100%; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-2); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--ink-3);
}
.nav-badge.alert { background: var(--block); color: #fff; }

/* ---------- topbar ---------- */
.topbar {
  height: 62px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: rgba(240,238,234,0.82); backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.topbar .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }

.scroll-area { flex: 1; overflow-y: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-size: 13px; font-weight: 600;
  transition: all 0.15s; box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--accent-2); border-color: transparent; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-icon { padding: 8px; width: 38px; height: 38px; justify-content: center; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-top { height: 5px; border-radius: 999px; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.prio { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em; }

/* author tag */
.author { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.input, .textarea, .select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13.5px; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 70px; line-height: 1.55; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.kan-col { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px; min-height: 120px; }
.kan-head { display: flex; align-items: center; gap: 8px; padding: 2px 6px 12px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.kan-list { display: flex; flex-direction: column; gap: 9px; }

/* ---------- modal / drawer ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(58,53,48,0.30);
  backdrop-filter: blur(3px); display: grid; place-items: center;
  z-index: 60; padding: 24px; animation: fade 0.18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop 0.22s cubic-bezier(0.2,0.8,0.2,1) forwards;
}
.drawer-scrim { position: fixed; inset: 0; background: rgba(58,53,48,0.28); backdrop-filter: blur(2px); z-index: 50; animation: fade 0.2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 94vw);
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg); z-index: 51; display: flex; flex-direction: column;
  animation: slideIn 0.28s cubic-bezier(0.2,0.8,0.2,1) forwards;
}

/* ---------- quick capture ---------- */
.qc-wrap { display: flex; gap: 9px; }
.qc-input { flex: 1; }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: 340px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 11px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 12px 14px;
  animation: toastIn 0.4s cubic-bezier(0.2,0.9,0.2,1);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(0.96); } to { opacity: 1; transform: none; } }

/* fresh entrance + flash */
@keyframes updateIn { 0% { opacity: 0; transform: translateY(-8px); } 100% { opacity: 1; transform: none; } }
.update-fresh { animation: updateIn 0.45s cubic-bezier(0.2,0.8,0.2,1); }
.update-fresh .update-bubble { box-shadow: 0 0 0 2px var(--accent-soft); animation: bubblePulse 2.2s ease; }
@keyframes bubblePulse { 0%,60% { box-shadow: 0 0 0 2px var(--accent-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes cardFlash { 0% { box-shadow: 0 0 0 3px var(--accent-soft); } 100% { box-shadow: var(--shadow-sm); } }
.card-flash { animation: cardFlash 2.2s ease; }
@keyframes rowFlash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.gantt-flash { animation: rowFlash 2.4s ease; }

/* subtask drag */
.subtask-row.dragging { opacity: 0.4; }
.subtask-row.drop-target { box-shadow: inset 0 2px 0 var(--accent); }
.grip { cursor: grab; color: var(--ink-3); opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.subtask-row:hover .grip, .item-card:hover .grip { opacity: 1; }

/* hover affordances */
.item-card { transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; cursor: pointer; }
.item-card:hover { transform: translateY(-2px); border-color: var(--ink-3); box-shadow: var(--shadow); }
.gantt-label:hover, .gantt-row:hover { background: var(--surface-2) !important; }
.subtask-row:hover { background: var(--surface-2); }
.opt-btn { transition: all 0.14s; }
.opt-btn:hover { border-color: var(--accent) !important; background: var(--accent-soft) !important; color: var(--accent-2) !important; }

.muted { color: var(--ink-3); }
.section-intro { font-size: 13px; color: var(--ink-2); line-height: 1.6; }

/* ---------- mobile ---------- */
.hamburger { display: none; }
.sidebar-scrim { display: none; }
@media (max-width: 880px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 70; transform: translateX(-100%); transition: transform 0.26s cubic-bezier(0.2,0.8,0.2,1); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(58,53,48,0.4); z-index: 69; animation: fade 0.2s ease; }
  .hamburger { display: inline-flex; }
  .drawer { width: 100vw; }
  .topbar { padding: 0 14px; }
  .kanban { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
}
