/* ═══════════════════════════════════════════════════════════
 * AI 洞察 ai.html — 2026-05 大改版「今日人流彙報」敘事化版型
 *
 * 範圍鎖在 #page-ai 內;載入順序在 style.css 之後。
 * 舊 .select-mock 等規則仍保留(自訂生成 form 在 details 內仍會用到)。
 * ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────
 * 自訂模式提示列(sticky)
 * 自訂生成成功後出現,讓使用者知道「目前看的不是自動日報」+ 提供下載 / 返回
 * ───────────────────────────────────────────── */
#page-ai .ai-mode-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(155,137,201,0.16) 0%, rgba(59,130,246,0.10) 100%);
  border: 1px solid rgba(155,137,201,0.30);
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: aiMbSlide 0.22s ease;
  white-space: nowrap;
}
[data-theme="dark"] #page-ai .ai-mode-banner {
  background: linear-gradient(90deg, rgba(232,121,249,0.16) 0%, rgba(59,157,255,0.12) 100%);
  border-color: rgba(232,121,249,0.30);
}
@keyframes aiMbSlide {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#page-ai .ai-mb-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-magenta);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
#page-ai .ai-mb-meta { flex: 1; min-width: 0; line-height: 1.5; }
#page-ai .ai-mb-meta b { color: var(--ink); font-weight: 700; }
#page-ai .ai-mb-actions { display: inline-flex; gap: 6px; flex-shrink: 0; }
#page-ai .ai-mb-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
#page-ai .ai-mb-btn:hover { border-color: var(--ink); color: var(--ink); background: var(--surface-2); }
#page-ai .ai-mb-btn.primary {
  background: var(--accent-magenta);
  border-color: var(--accent-magenta);
  color: #fff;
}
#page-ai .ai-mb-btn.primary:hover { filter: brightness(1.06); color: #fff; }
@media (max-width: 600px) {
  #page-ai .ai-mb-meta { width: 100%; order: 2; }
  #page-ai .ai-mb-actions { order: 3; margin-left: auto; }
}

/* ─────────────────────────────────────────────
 * 報告頭部:AI 自動生成 + 三段式更新狀態 + 立即重生成
 * ───────────────────────────────────────────── */
#page-ai .ai-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
#page-ai .ai-report-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}
#page-ai .ai-pill-auto {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(155,137,201,0.18);
  color: var(--accent-magenta);
  font-size: 14px;
  font-weight: 700;
}
[data-theme="dark"] #page-ai .ai-pill-auto {
  background: rgba(232,121,249,0.20);
}
#page-ai .ai-update-state b {
  color: var(--ink);
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  margin-left: 2px;
}
#page-ai .ai-update-sep {
  color: var(--muted);
  opacity: 0.55;
}

#page-ai .ai-report-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 8px 0 4px;
}
#page-ai .ai-report-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 18px;
}
#page-ai .ai-print-snapshot-note { display: none; }

/* ─────────────────────────────────────────────
 * 執行摘要(藍底大卡 + 4 KPI strip)
 * ───────────────────────────────────────────── */
#page-ai .ai-summary-card {
  background: linear-gradient(180deg, rgba(59,130,246,0.10) 0%, rgba(59,130,246,0.04) 100%);
  border: 1px solid rgba(59,130,246,0.22);
  border-radius: 16px;
  padding: 20px 22px;
}
[data-theme="dark"] #page-ai .ai-summary-card {
  background: linear-gradient(180deg, rgba(59,157,255,0.14) 0%, rgba(59,157,255,0.05) 100%);
  border-color: rgba(59,157,255,0.28);
}
#page-ai .ai-summary-tag {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  background: rgba(59,130,246,0.14);
  padding: 3px 10px;
  border-radius: 6px;
}
#page-ai .ai-summary-text {
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-2);
  margin: 0 0 18px;
  font-weight: 500;
}
#page-ai .ai-summary-text b { color: var(--ink); font-weight: 700; }
#page-ai .ai-summary-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(59,130,246,0.18);
}
@media (max-width: 600px) {
  #page-ai .ai-summary-kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
#page-ai .ai-summary-kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
#page-ai .ai-summary-kpi-unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  margin-left: 1px;
}
#page-ai .ai-summary-kpi-label {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ─────────────────────────────────────────────
 * 今日的故事 timeline
 * ───────────────────────────────────────────── */
#page-ai .ai-story-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
}
#page-ai .ai-story-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
#page-ai .ai-story-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}
#page-ai .ai-story-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
#page-ai .ai-story-legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: var(--muted);
}
#page-ai .ai-story-legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
#page-ai .ai-story-legend-dot.k-anchor   { background: var(--muted); }
#page-ai .ai-story-legend-dot.k-summary  { background: var(--muted); opacity: 0.55; }
#page-ai .ai-story-legend-dot.k-peak     { background: var(--accent-amber); }
#page-ai .ai-story-legend-dot.k-forecast { background: var(--accent-blue); }

/* timeline wrapper */
#page-ai .ai-story-timeline {
  position: relative;
  padding-left: 96px;       /* 左欄留給時間 + 標籤 */
}
#page-ai .ai-story-timeline::before {
  content: '';
  position: absolute;
  left: 84px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  background: var(--line);
}
#page-ai .ai-story-node {
  position: relative;
  padding-bottom: 22px;
}
#page-ai .ai-story-node:last-child { padding-bottom: 0; }
#page-ai .ai-story-node-time {
  position: absolute;
  left: -96px;
  top: 0;
  width: 86px;
  text-align: right;
  padding-right: 18px;
}
#page-ai .ai-story-node-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
#page-ai .ai-story-node-tag.k-anchor   { background: var(--surface-2); color: var(--muted); }
#page-ai .ai-story-node-tag.k-summary  { background: var(--surface-2); color: var(--muted); }
#page-ai .ai-story-node-tag.k-peak     { background: rgba(245,158,11,0.16); color: var(--accent-amber); }
#page-ai .ai-story-node-tag.k-forecast { background: rgba(59,130,246,0.16); color: var(--accent-blue); }
#page-ai .ai-story-node-time-val {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
  letter-spacing: -0.01em;
}
#page-ai .ai-story-node-tag-label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

/* dot on the line */
#page-ai .ai-story-node::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 3px var(--surface);
  z-index: 2;
}
#page-ai .ai-story-node.k-peak::before     { border-color: var(--accent-amber); background: var(--accent-amber); }
#page-ai .ai-story-node.k-forecast::before { border-color: var(--accent-blue);  background: var(--accent-blue); }
#page-ai .ai-story-node.k-anchor::before   { background: var(--ink); }

#page-ai .ai-story-node-body {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 16px;
  min-height: 76px;
}
[data-theme="dark"] #page-ai .ai-story-node-body { background: var(--bg); }
#page-ai .ai-story-node-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 4px;
}
#page-ai .ai-story-node-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
}

/* explainer collapsible */
#page-ai .ai-story-explainer {
  margin-top: 18px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
}
[data-theme="dark"] #page-ai .ai-story-explainer { background: var(--bg); }
#page-ai .ai-story-explainer summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-weight: 600;
}
#page-ai .ai-story-explainer summary::-webkit-details-marker { display: none; }
#page-ai .ai-explainer-caret { transition: transform 0.18s ease; color: var(--muted); }
#page-ai .ai-story-explainer[open] .ai-explainer-caret { transform: rotate(90deg); }
#page-ai .ai-story-explainer-body {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 10px;
}
@media (max-width: 700px) {
  #page-ai .ai-story-explainer-body { grid-template-columns: 1fr; gap: 10px; }
}
#page-ai .ai-explainer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
#page-ai .ai-explainer-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 4px;
}
#page-ai .ai-explainer-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* ─────────────────────────────────────────────
 * 三個關鍵發現
 * ───────────────────────────────────────────── */
#page-ai .ai-section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

/* ─────────────────────────────────────────────
 * 明日營運建議
 * ───────────────────────────────────────────── */
#page-ai .ai-tomorrow-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
}
#page-ai .ai-tomorrow-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
#page-ai .ai-tomorrow-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-amber);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
#page-ai .ai-tomorrow-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
}
#page-ai .ai-tomorrow-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
#page-ai .ai-tomorrow-stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 14px 16px;
}
[data-theme="dark"] #page-ai .ai-tomorrow-stat { background: var(--bg); }
#page-ai .ai-tomorrow-stat-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
#page-ai .ai-tomorrow-weather-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
#page-ai .ai-tomorrow-weather-icon {
  font-size: 36px;
  line-height: 1;
}
#page-ai .ai-tomorrow-weather-temp {
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
#page-ai .ai-tomorrow-weather-sep {
  color: var(--muted);
  margin: 0 4px;
  font-weight: 500;
}
#page-ai .ai-tomorrow-weather-cond {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

/* 推薦排程 */
#page-ai .ai-schedule-block {
  margin-bottom: 16px;
}
#page-ai .ai-schedule-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}
#page-ai .ai-schedule-list {
  display: flex;
  flex-direction: column;
}
#page-ai .ai-schedule-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  align-items: center;
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 4px;
}
#page-ai .ai-schedule-row.warn {
  background: rgba(245,158,11,0.10);
}
[data-theme="dark"] #page-ai .ai-schedule-row.warn {
  background: rgba(245,165,36,0.14);
}
#page-ai .ai-schedule-row.normal {
  background: transparent;
  border: 1px solid var(--line);
}
#page-ai .ai-schedule-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}
#page-ai .ai-schedule-row.warn .ai-schedule-time { color: var(--accent-amber); }
#page-ai .ai-schedule-text {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
}
#page-ai .ai-schedule-text b { color: var(--ink); font-weight: 700; }


/* ─────────────────────────────────────────────
 * 今日報告快照卡（取代舊「自訂生成」）
 * ───────────────────────────────────────────── */
#page-ai .ai-snapshot-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px 20px;
  margin-top: 16px;
}
#page-ai .ai-snapshot-head {
  margin-bottom: 14px;
}
#page-ai .ai-snapshot-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 4px;
}
#page-ai .ai-snapshot-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}
#page-ai .ai-snapshot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#page-ai .ai-snap-chip {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
#page-ai .ai-snap-chip:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}
#page-ai .ai-snap-chip.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
#page-ai .ai-snap-empty {
  font-size: 13px;
  color: var(--muted);
}

