/* =====================================================================
   CICA Group VI 設計系統 (Phase 1b)
   嚴格套用品牌色；--status-* 僅用於系統狀態提示，不可作裝飾色。
   ===================================================================== */
:root {
  /* 品牌色 */
  --cica-black:  #000000;  /* Sidebar 背景、主標題 */
  --cica-gold:   #D4BE8F;  /* Active、KPI 強調 */
  --cica-gold60: #E5D4B6;  /* 圖表填充、次要強調、Hover */
  --cica-gold20: #F5EBDF;  /* 淺色背景區塊 */
  --cica-mid:    #A49B96;  /* 輔助文字 */
  --cica-light:  #D7D3D3;  /* Border、分隔線 */
  --cica-white:  #FFFFFF;  /* 卡片背景 */

  /* 系統狀態色 */
  --status-danger:  #C0392B;  /* 鎖貨、逾期 */
  --status-warning: #D4830A;  /* 低庫存、警示 */
  --status-success: #1E6B3C;  /* 已收、正常 */

  /* 字體 */
  --font-en: 'Montserrat', 'Futura', sans-serif;
  --font-zh: 'Noto Sans TC', '思源黑體', sans-serif;

  --sidebar-w: 200px;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-zh);
  color: #1a1a1a;
  background: #F4F2F0;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- App 版面 ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 20px 24px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--cica-black);
  color: var(--cica-mid);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo {
  font-family: var(--font-en);
  font-weight: 700;
  color: var(--cica-gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 17px;
  padding: 22px 18px 6px;
}
.sidebar .logo small {
  display: block;
  font-family: var(--font-zh);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--cica-mid);
  font-size: 10px;
  margin-top: 4px;
}
.sidebar nav { margin-top: 14px; }
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 18px;
  color: var(--cica-mid);
  border-left: 3px solid transparent;
  font-size: 13px;
  cursor: pointer;
}
.nav-item:hover { color: var(--cica-gold60); }
.nav-item.active {
  color: var(--cica-gold);
  border-left: 3px solid var(--cica-gold);
  background: #111;
}
.nav-item.alert { color: var(--status-danger); }
.nav-badge {
  background: var(--status-danger);
  color: #fff;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--cica-white);
  border-bottom: 1px solid var(--cica-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
}
.topbar .page-title {
  font-family: var(--font-zh);
  font-weight: 700;
  font-size: 14px;
}
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .user { font-family: var(--font-en); font-size: 12px; color: #333; }

/* ---------- KPI 卡片 ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.kpi {
  position: relative;
  background: var(--cica-white);
  border: 1px solid var(--cica-light);
  border-radius: var(--radius);
  padding: 16px 16px 16px 20px;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--cica-gold);
}
.kpi.danger::before  { background: var(--status-danger); }
.kpi.warning::before { background: var(--status-warning); }
.kpi .num {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0;
}
.kpi.danger .num  { color: var(--status-danger); }
.kpi.warning .num { color: var(--status-warning); }
.kpi .label {
  font-family: var(--font-zh);
  font-size: 10px;
  color: var(--cica-mid);
  margin-top: 2px;
}

/* ---------- 鎖貨警示橫幅 ---------- */
.lock-banner {
  background: #FFF0EE;
  border-left: 4px solid var(--status-danger);
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 13px;
  color: #5a1f18;
}
.lock-banner b { color: var(--status-danger); }

/* ---------- 狀態 Pill ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-zh);
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 11px;
  white-space: nowrap;
}
.pill.paid       { background: #E8F5ED; color: var(--status-success); }
.pill.due        { background: #FEF3E2; color: var(--status-warning); }
.pill.overdue    { background: #FFF0EE; color: var(--status-danger); }
.pill.locked     { background: #FFF0EE; color: var(--status-danger); border: 1px solid var(--status-danger); }
.pill.shipping   { background: #E8F0FB; color: #1A56A0; }
.pill.done       { background: #E8F5ED; color: var(--status-success); }

/* ---------- 卡片區塊 ---------- */
.card {
  background: var(--cica-white);
  border: 1px solid var(--cica-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.card h2 {
  font-family: var(--font-zh);
  font-weight: 700;
  font-size: 13px;
  margin: 0 0 12px;
}

/* ---------- 資料表格 ---------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
table.data thead th {
  background: var(--cica-black);
  color: var(--cica-gold);
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: left;
  padding: 8px 10px;
}
table.data tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #F5F5F5;
  font-family: var(--font-zh);
}
table.data tbody tr:nth-child(even) { background: #FAFAFA; }
table.data td.amount { font-family: var(--font-en); font-weight: 400; text-align: right; }
table.data td.code   { font-family: 'Courier New', monospace; font-size: 12px; }

/* ---------- 按鈕 ---------- */
.btn {
  font-family: var(--font-en);
  font-size: 12px;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
}
.btn-primary   { background: var(--cica-black); color: var(--cica-gold); font-weight: 600; }
.btn-secondary { background: transparent; border: 1px solid var(--cica-light); color: var(--cica-black); }
.btn-danger    { background: var(--status-danger); color: #fff; }
.btn-ghost     { background: transparent; color: var(--cica-mid); }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* ---------- 表單 ---------- */
.input {
  font-family: var(--font-zh);
  font-size: 13px;
  border: 1px solid var(--cica-light);
  border-radius: 6px;
  padding: 8px 12px;
  width: 100%;
}
.input:focus { outline: 2px solid var(--cica-gold60); border-color: var(--cica-gold); }

/* ---------- 響應式（手機） ---------- */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    flex-direction: row;
    overflow-x: auto;
  }
  .sidebar .logo { white-space: nowrap; }
  .sidebar nav { display: flex; margin-top: 0; }
  .nav-item { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; }
  .nav-item.active { border-left: none; border-bottom: 3px solid var(--cica-gold); }
}
