/* APGO 社群留言中控 — 色彩與元件沿用 APGO 產品系統（apgo-product-console）*/
:root {
  --bg: #F4F3F0; --surface: #FFFFFF; --surface-2: #FAF9F7; --sunk: #EEECE8;
  --border: #E7E5E4; --border-strong: #D6D3D1;
  --text: #1C1917; --text-2: #57534E; --text-3: #6F6A64;
  --pri: #C2410C; --pri-hover: #9A3412; --on-pri: #FFFFFF; --pri-soft: #FFEDD5; --pri-text: #9A3412; --pri-wash: #FFF7ED;
  --ok: #15803D; --ok-soft: #DCFCE7; --warn: #92400E; --warn-soft: #FEF3C7;
  --bad: #B91C1C; --bad-soft: #FEE2E2; --ai: #1D4ED8; --ai-soft: #DBEAFE;
  --neu: #44403C; --neu-soft: #EFEDEA;
  --side-bg: #1C1917; --side-text: #E7E5E4; --side-muted: #A8A29E; --side-active: #35302B; --side-badge: #F97316;
  --fb: #1668D9; --ig: #B5306E; --threads: #1C1917;
  --shadow: 0 1px 2px rgba(28,25,23,.06), 0 8px 24px rgba(28,25,23,.08);
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 14px; line-height: 1.55;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--pri-text); }
a:hover { color: #7C2D12; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }

/* ---------- 版面 ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; padding: 28px 32px 40px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- 側欄 ---------- */
.side {
  flex: 0 0 236px; width: 236px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; gap: 18px; padding: 18px 12px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--side-text); text-decoration: none; }
.side-brand:hover { color: #fff; }
.side-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--side-badge); color: var(--side-bg); display: grid; place-items: center; font-weight: 800; }
.side-brand b { display: block; font-size: 15px; letter-spacing: .06em; }
.side-brand small { display: block; font-size: 12px; color: var(--side-muted); }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title { margin: 0 0 4px; padding: 0 10px; font-size: 12px; font-weight: 600; color: var(--side-muted); letter-spacing: .08em; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--side-text); font-size: 14px; text-align: left;
}
button.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.nav-item svg { flex: none; }
.nav-item span { flex: 1; }
.nav-item.is-static { cursor: default; }
.nav-badge { min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 999px; background: var(--side-badge); color: var(--side-bg); font-size: 12px; font-weight: 700; }
.nav-badge:empty { display: none; }
.nav-note { font-size: 11px; color: var(--side-muted); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-stage { margin: 0 6px; padding: 10px 12px; border-radius: 8px; background: #292524; }
.side-stage small { display: block; font-size: 12px; color: var(--side-muted); }
.side-stage b { display: block; font-size: 13px; color: #fff; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.1); }
.side-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #44403C; color: #fff; display: grid; place-items: center; font-weight: 700; }
.side-user .who { flex: 1; min-width: 0; }
.side-user .who b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who small { display: block; font-size: 12px; color: var(--side-muted); }
.side-icon-btn { width: 40px; height: 40px; border-radius: 8px; border: 0; background: transparent; color: var(--side-muted); display: grid; place-items: center; }
.side-icon-btn:hover, .side-icon-btn[aria-expanded="true"] { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- 設定列 ---------- */
.settings {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.settings[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; }
.field-sm { flex: 0 1 160px; }
.field label { font-size: 13px; font-weight: 600; }
.field input { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); }
.settings-hint { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text-2); }
.settings-hint:empty { display: none; }
.settings-hint.err { color: var(--bad); }

/* ---------- 按鈕（同產品系統 .btn）---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--pri); background: var(--pri); color: var(--on-pri); font-size: 14px; font-weight: 700; white-space: nowrap;
}
.btn:hover { background: var(--pri-hover); border-color: var(--pri-hover); }
.btn:disabled { background: var(--sunk); border-color: var(--sunk); color: var(--text-3); cursor: not-allowed; }
.btn.lg { min-height: 44px; padding: 0 20px; font-size: 15px; }
.btn.out { background: var(--surface); border-color: var(--border-strong); color: var(--text); font-weight: 600; }
.btn.out:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn.text-bad { background: transparent; border-color: transparent; color: var(--bad); font-weight: 600; }
.btn.text-bad:hover { background: var(--bad-soft); }
.btn.out:disabled, .btn.text-bad:disabled { background: var(--sunk); border-color: var(--sunk); color: var(--text-3); }

/* ---------- 頁首 ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.page-head .eyebrow { margin: 0; font-size: 13px; color: var(--text-3); }
.page-head h1 { margin: 4px 0 0; font-size: 26px; font-weight: 700; }
.page-head .sub { margin: 4px 0 0; font-size: 14px; color: var(--text-2); }
.stats { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stat { padding: 8px 16px; min-width: 92px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat small { display: block; font-size: 12px; color: var(--text-3); }
.stat b { display: block; font-size: 22px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-pri { background: var(--pri-soft); border-color: #FED7AA; }
.stat-pri small, .stat-pri b { color: var(--pri-text); }

/* ---------- 篩選 ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 600;
}
.chipbtn[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.account-filter { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.account-filter label { font-size: 13px; color: var(--text-2); }
.account-filter select { min-height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; }

/* ---------- 工作區：清單 + 處理區 ---------- */
.work { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }
.list { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.pane {
  flex: 999 1 520px; min-width: 0; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}

/* 清單卡片 */
.card {
  display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: inherit;
}
.card:hover { border-color: var(--border-strong); }
.card[aria-current="true"] { background: var(--pri-wash); border: 2px solid var(--pri); padding: 13px 15px; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-acct { font-size: 13px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-time { margin-left: auto; flex: none; font-size: 12px; color: var(--text-3); }
.card-text { margin-top: 8px; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-post { display: block; margin-top: 8px; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

/* 平台標記 */
.plat { flex: none; padding: 1px 7px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700; }
.plat-fb { background: var(--fb); }
.plat-ig { background: var(--ig); }
.plat-threads { background: var(--threads); }

/* 標籤（顏色語意同產品系統：橘=等你、綠=完成、紅=卡住、藍=系統/建議、灰=中性） */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; line-height: 1.6; background: var(--neu-soft); color: var(--neu); white-space: nowrap; }
.t-pri { background: var(--pri-soft); color: var(--pri-text); }
.t-ok { background: var(--ok-soft); color: var(--ok); }
.t-bad { background: var(--bad-soft); color: var(--bad); }
.t-ai { background: var(--ai-soft); color: var(--ai); }
.t-warn { background: var(--warn-soft); color: var(--warn); }

/* 處理區 */
.pane-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.pane-head .acct { font-weight: 600; }
.pane-head .open { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 10px; border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; }
.pane-head .open:hover { background: var(--sunk); }
.pane-body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }

.post { display: flex; flex-direction: column; gap: 12px; }
.post-who { display: flex; align-items: center; gap: 10px; }
.post-avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--side-bg); color: var(--side-badge); display: grid; place-items: center; font-weight: 800; }
.post-who b { display: block; }
.post-who small { display: block; font-size: 12px; color: var(--text-3); }
.post-body { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.post-img { flex: 0 1 240px; min-width: 180px; height: 240px; border-radius: 10px; background: var(--sunk); object-fit: cover; }
.post-img-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); font-size: 12px; }
.post-text { flex: 1 1 240px; margin: 0; font-size: 15px; line-height: 1.75; white-space: pre-line; word-break: break-word; }
.post-missing { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.post-missing p { flex: 1 1 240px; margin: 0; word-break: break-word; }

.thread { display: flex; gap: 12px; padding-left: 18px; }
.thread-line { flex: none; width: 2px; border-radius: 2px; background: var(--border); }
.thread-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.label-sm { font-size: 12px; font-weight: 600; color: var(--text-3); }
.comment { display: flex; gap: 10px; }
.comment-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--neu-soft); color: var(--neu); display: grid; place-items: center; font-weight: 700; }
.comment-bubble { flex: 1; min-width: 0; padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.comment-meta small { font-size: 12px; color: var(--text-3); }
.comment-meta .tags { margin-left: auto; display: flex; gap: 6px; }
.comment-text { margin-top: 4px; font-size: 16px; line-height: 1.6; word-break: break-word; }

.compose { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--border); }
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--ai-soft); }
.suggest .k { font-size: 12px; font-weight: 700; color: var(--ai); }
.suggest .v { flex: 1 1 240px; min-width: 0; color: #1E3A8A; }
.suggest button { min-height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid #BFDBFE; background: var(--surface); color: var(--ai); font-size: 13px; font-weight: 600; }
.compose label { font-size: 13px; font-weight: 600; }
.compose textarea {
  width: 100%; min-height: 128px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 15px; line-height: 1.65; resize: vertical;
}
.compose textarea:disabled { background: var(--sunk); color: var(--text-3); }
.compose-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-3); }
.compose-meta .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.compose-actions .push { margin-left: auto; }
.done-note { padding: 10px 14px; border-radius: 10px; background: var(--neu-soft); color: var(--neu); font-size: 13px; }

.booster { padding: 14px; border-radius: var(--radius); border: 1.5px dashed var(--border-strong); background: var(--surface-2); }
.booster b { margin-right: 8px; }
.booster p { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.pill { display: inline-flex; padding: 1px 8px; border-radius: 999px; background: var(--neu-soft); color: var(--neu); font-size: 12px; font-weight: 700; }

/* 空狀態 */
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.list .empty { border-radius: var(--radius); border: 1px dashed var(--border-strong); background: var(--surface-2); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); z-index: 80; max-width: 80vw;
  padding: 10px 16px; border-radius: 10px; background: var(--text); color: #fff; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* ---------- 窄螢幕：側欄改到上方、處理區不黏住 ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { position: static; width: auto; height: auto; flex: none; }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-group-title { flex-basis: 100%; }
  .nav-item { width: auto; }
  .main { padding: 20px 16px 32px; }
  .pane { position: static; max-height: none; }
  .account-filter { margin-left: 0; }
}
