/* ============================================================
   物流追蹤系統 — 視覺設計系統（app.css）
   「海港作業台」：暖紙畫布、海港墨綠側欄、貨櫃橘主行動色。
   全部本地資產，內網可離線運作，不依賴任何外部 CDN。
   載入順序在 bootstrap.min.css 之後，用以覆寫其預設樣式。
   ============================================================ */

:root {
  /* 畫布與表面 */
  --canvas:      #f4f2ec;   /* 暖紙色頁面底 */
  --surface:     #ffffff;   /* 卡片/表格表面 */
  --surface-2:   #faf9f5;   /* 次要表面（表頭、hover） */
  --line:        #e6e2d7;   /* 分隔線 */
  --line-strong: #d8d3c5;

  /* 文字 */
  --text:   #17262c;
  --muted:  #5d6b71;
  --faint:  #8a959a;

  /* 海港墨綠（側欄與主色系） */
  --ink:    #0d2b32;
  --ink-2:  #123a42;
  --side-text:   #b7c6c9;
  --side-muted:  #6a8288;
  --side-hover:  rgba(255,255,255,0.06);

  /* 貨櫃橘（主要行動，節制使用） */
  --accent:      #e0632a;
  --accent-ink:  #b64c1c;
  --accent-soft: rgba(224,99,42,0.12);

  /* 語意狀態色（搭配圖示與文字，不單靠顏色辨識） */
  --st-neutral:  #64748b;
  --st-info:     #2563b8;   /* 運送中 */
  --st-port:     #0d8a9e;   /* 到港 */
  --st-good:     #1f9254;   /* 完成/送達 */
  --st-warn:     #c67611;   /* 需注意 */
  --st-bad:      #d24545;   /* 異常/失敗 */

  --radius:   14px;
  --radius-sm: 9px;
  --shadow:   0 1px 3px rgba(20,30,25,0.06), 0 6px 20px rgba(20,30,25,0.05);
  --shadow-sm: 0 1px 2px rgba(20,30,25,0.08);

  --sidebar-w: 244px;
}

/* ── 全域 ────────────────────────────────────────────────── */
body {
  background: var(--canvas);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }
a:hover { color: var(--accent); }

/* 資料型數字（ID、日期、單號）一律等寬，欄位對齊 */
.tabular, .table td, .table th, .stat-value, .mono {
  font-variant-numeric: tabular-nums;
}

/* ── 側欄 ────────────────────────────────────────────────── */
.sidebar {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: var(--side-text);
  width: var(--sidebar-w);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 1px 0 0 rgba(0,0,0,0.15);
}
.sidebar .brand {
  font-size: 1.06rem;
  font-weight: 700;
  color: #fff;
  padding: 1.15rem 1.3rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 0.6rem;
  letter-spacing: 0.01em;
}
.sidebar .brand i { font-size: 1.35rem; color: var(--accent); }

.sidebar .nav-section {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--side-muted);
  padding: 1.25rem 1.3rem 0.4rem;
  font-weight: 700;
}
.sidebar .nav-link {
  color: var(--side-text);
  padding: 0.62rem 1.3rem;
  border-radius: 0;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 0.7rem;
  border-left: 3px solid transparent;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  min-height: 44px;               /* 觸控目標 */
}
.sidebar .nav-link:hover {
  color: #fff;
  background: var(--side-hover);
  border-left-color: rgba(224,99,42,0.45);
}
.sidebar .nav-link.active {
  color: #fff;
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }

/* 語言切換 */
.lang-switcher { padding: 0.65rem 1.15rem; border-top: 1px solid rgba(255,255,255,0.07); }
.lang-select-wrap {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem; cursor: pointer; transition: background 0.15s;
}
.lang-select-wrap:hover { background: rgba(255,255,255,0.1); }
.lang-select-wrap i { color: var(--accent); font-size: 0.9rem; flex-shrink: 0; }
.lang-select-wrap select {
  background: transparent; border: none; color: var(--side-text);
  font-size: 0.82rem; cursor: pointer; outline: none; width: 100%;
  appearance: none; -webkit-appearance: none;
}
.lang-select-wrap select option { background: var(--ink-2); color: #e2e8f0; }

/* 使用者footer */
.sidebar-footer { margin-top: auto; padding: 0.95rem 1.15rem; border-top: 1px solid rgba(255,255,255,0.07); }
.sidebar-footer .user-name { font-size: 0.86rem; color: #e6edee; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-email { font-size: 0.72rem; color: var(--side-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.6rem; }

/* ── 主內容 ──────────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); padding: 1.9rem 2.2rem; min-height: 100vh; }
.page-header {
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: 1.75rem; padding-bottom: 0.9rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.page-header h4 {
  margin: 0; font-weight: 700; font-size: 1.32rem; letter-spacing: -0.01em;
  color: var(--text); display: flex; align-items: center; gap: 0.55rem;
}
.page-header h4 i { color: var(--accent); }
.page-subtitle { color: var(--muted); font-size: 0.85rem; }

/* ── 卡片 ────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.card-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 700; font-size: 0.98rem; padding: 0.9rem 1.15rem;
}
.card-body { padding: 1.15rem; }

/* ── 統計「作業板」磚 ─────────────────────────────────────── */
.stat-tile {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
a.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(20,30,25,0.10), 0 12px 28px rgba(20,30,25,0.07);
  border-color: var(--line-strong);
}
.stat-tile .stat-icon {
  width: 46px; height: 46px; border-radius: 11px;
  display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0;
}
.stat-tile .stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.stat-tile .stat-label { font-size: 0.82rem; color: var(--muted); margin-top: 0.1rem; }
.tile-accent  .stat-icon { background: var(--accent-soft);          color: var(--accent-ink); }
.tile-info    .stat-icon { background: rgba(37,99,184,0.12);        color: var(--st-info); }
.tile-warn    .stat-icon { background: rgba(198,118,17,0.14);       color: var(--st-warn); }
.tile-bad     .stat-icon { background: rgba(210,69,69,0.12);        color: var(--st-bad); }
.tile-good    .stat-icon { background: rgba(31,146,84,0.12);        color: var(--st-good); }

/* ── 表格 ────────────────────────────────────────────────── */
.table { --bs-table-bg: var(--surface); margin-bottom: 0; }
.table thead th {
  font-weight: 700; font-size: 0.72rem; background: var(--surface-2);
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line-strong); padding: 0.7rem 0.85rem; white-space: nowrap;
}
.table td { font-size: 0.9rem; vertical-align: middle; padding: 0.72rem 0.85rem; border-bottom: 1px solid var(--line); color: var(--text); }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: var(--surface); }
.table-card .table { border-radius: var(--radius); }

/* ── 狀態晶片（本系統的識別元件：圖示＋文字＋語意色）────────── */
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600; line-height: 1;
  padding: 0.34rem 0.62rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.chip i { font-size: 0.82rem; }
.chip-neutral { background: rgba(100,116,139,0.12); color: #475569;  border-color: rgba(100,116,139,0.22); }
.chip-info    { background: rgba(37,99,184,0.11);   color: #1d4e8f; border-color: rgba(37,99,184,0.20); }
.chip-port    { background: rgba(13,138,158,0.12);  color: #0a6c7c; border-color: rgba(13,138,158,0.22); }
.chip-good    { background: rgba(31,146,84,0.12);    color: #167243; border-color: rgba(31,146,84,0.22); }
.chip-warn    { background: rgba(198,118,17,0.14);   color: #97590b; border-color: rgba(198,118,17,0.24); }
.chip-bad     { background: rgba(210,69,69,0.11);    color: #a83232; border-color: rgba(210,69,69,0.22); }

/* ── 按鈕 ────────────────────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
}
.btn-primary:hover, .btn-primary:focus { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-outline-primary { color: var(--accent-ink); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-lg { font-size: 1rem; padding: 0.6rem 1.15rem; }
/* 表格內的操作鈕仍維持足夠觸控大小 */
.btn-row { min-height: 34px; display: inline-flex; align-items: center; gap: 0.35rem; }

/* ── Flash 訊息 ──────────────────────────────────────────── */
.flash-messages { position: sticky; top: 0.5rem; z-index: 500; }
.alert { border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }

/* ── 空狀態 ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2.6rem 1rem; color: var(--muted); }
.empty-state .empty-icon { font-size: 2.6rem; color: var(--faint); margin-bottom: 0.6rem; }
.empty-state .empty-title { font-weight: 600; color: var(--text); margin-bottom: 0.3rem; }

/* ── 響應式：窄螢幕收合側欄為頂列 ───────────────────────────── */
@media (max-width: 860px) {
  .sidebar {
    position: static; width: 100%; min-height: auto; flex-direction: column;
    box-shadow: 0 2px 0 rgba(0,0,0,0.12);
  }
  .sidebar .nav-link { border-left: none; border-bottom: 2px solid transparent; }
  .sidebar .nav-link.active { border-left: none; border-bottom-color: var(--accent); }
  .main-content { margin-left: 0; padding: 1.15rem; }
  .table-responsive-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
