/* ============================================================
   Dragon Fruit Advisory System — dashboard styles

   Every colour and font the page uses is defined in :root below.
   app.js reads --risk-0..5, --c-accent and --font-chart to draw
   the chart, so those colours must stay in hex form (#RRGGBB).
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:       #F4F1EC;
  --c-surface:  #FFFFFF;
  --c-text:     #2C2C2C;
  --c-muted:    #6B6B6B;
  --c-border:   #E0DDD7;
  --c-accent:   #1B6B3A;

  --risk-5: #E24B4A;
  --risk-4: #D85A30;
  --risk-3: #EF9F27;
  --risk-2: #97C459;
  --risk-1: #1D9E75;
  --risk-0: #888780;

  --font-zh: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --font-chart: 'Times New Roman', serif;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

html { font-size: 16px; }
body {
  font-family: var(--font-zh);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.page-body { padding-bottom: 8px; }

/* Risk colours by level: background (risk-bg-N) and text (risk-fg-N) */
.risk-bg-0 { background: var(--risk-0); }
.risk-bg-1 { background: var(--risk-1); }
.risk-bg-2 { background: var(--risk-2); }
.risk-bg-3 { background: var(--risk-3); }
.risk-bg-4 { background: var(--risk-4); }
.risk-bg-5 { background: var(--risk-5); }
.risk-fg-0 { color: var(--risk-0); }
.risk-fg-1 { color: var(--risk-1); }
.risk-fg-2 { color: var(--risk-2); }
.risk-fg-3 { color: var(--risk-3); }
.risk-fg-4 { color: var(--risk-4); }
.risk-fg-5 { color: var(--risk-5); }

/* Header */
.header {
  background: linear-gradient(135deg, #1B4332 0%, #2D6A4F 100%);
  color: #fff;
  padding: 20px 0 16px;
  border-bottom: 3px solid var(--risk-2);
}
.header h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: 0.02em; }
.header .subtitle { font-size: 0.8rem; opacity: 0.7; margin-top: 2px; }
.header .update-time { font-size: 0.75rem; opacity: 0.6; margin-top: 6px; }

/* Station Tabs */
.station-tabs {
  display: flex; gap: 6px; padding: 12px 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.station-tab {
  flex-shrink: 0; padding: 8px 18px; border-radius: 24px;
  border: 1.5px solid var(--c-border); background: var(--c-surface);
  font-size: 0.9rem; font-weight: 500; color: var(--c-muted);
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-zh);
}
.station-tab:hover { border-color: var(--c-accent); color: var(--c-accent); }
.station-tab.active {
  background: var(--c-accent); color: #fff; border-color: var(--c-accent);
}
.station-tab .risk-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.station-tab.active .risk-dot { background: #fff; }

/* Card */
.card {
  background: var(--c-surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
  border: 1px solid var(--c-border);
}
.card-title {
  font-size: 0.8rem; font-weight: 600; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}

/* Risk Card */
.risk-banner {
  border-radius: 10px; padding: 16px 20px; color: #fff;
}
.risk-banner .risk-level { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.risk-banner .risk-sub { font-size: 0.85rem; opacity: 0.9; margin-top: 4px; }
.risk-meta {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 12px; margin-top: 14px;
}
.risk-meta-item {
  text-align: center; padding: 8px; background: var(--c-bg); border-radius: 8px;
}
.risk-meta-item .label { font-size: 0.7rem; color: var(--c-muted); }
.risk-meta-item .value { font-size: 1.05rem; font-weight: 600; margin-top: 2px; }
.advisory-text {
  margin-top: 14px; padding: 12px 14px; background: var(--c-bg);
  border-radius: 8px; font-size: 0.88rem; line-height: 1.65;
  color: var(--c-text); border-left: 3px solid var(--c-accent);
}

/* Chart */
.chart-wrapper { position: relative; width: 100%; height: 300px; }
@media (min-width: 640px) { .chart-wrapper { height: 360px; } }

/* Onset Alerts */
.onset-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; background: #FFF5F5;
  border: 1px solid #FED7D7; border-radius: 8px; margin-bottom: 8px;
}
.onset-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 2px; }
.onset-info { font-size: 0.85rem; line-height: 1.6; }
.onset-date { font-weight: 600; color: var(--risk-5); }
.onset-detail { color: var(--c-muted); font-size: 0.8rem; margin-top: 2px; }
.no-onset {
  text-align: left; padding: 20px;
  color: var(--c-muted); font-size: 0.88rem;
}

/* Map */
.map-container {
  height: 220px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--c-border);
}
@media (min-width: 640px) { .map-container { height: 260px; } }
/* Station marker. Its size is set by app.js (buildMarkerIcon), 24px or 30px. */
.station-marker {
  width: 100%; height: 100%; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer; transition: all 0.2s;
}
.station-marker.active {
  border: 4px solid #1B4332; box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}

/* Legend */
.legend-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.78rem; color: var(--c-muted);
}
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.legend-note { margin-top: 12px; font-size: 0.75rem; color: #888; }

/* Footer */
.footer {
  text-align: center; padding: 24px 0 32px;
  font-size: 0.72rem; color: var(--c-muted);
}

/* Loading / Error */
.loading {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 60vh; gap: 12px; color: var(--c-muted);
}
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--c-border);
  border-top-color: var(--c-accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box {
  text-align: center; padding: 40px 20px; margin-top: 40px; color: var(--risk-5);
}
.error-icon { font-size: 2rem; margin-bottom: 12px; }
.error-title { font-weight: 600; }
.error-detail { font-size: 0.82rem; margin-top: 8px; color: #888; }
.error-help { font-size: 0.78rem; margin-top: 12px; color: #aaa; }
.error-inline {
  padding: 16px; background: #FFF5F5; border: 1px solid #FED7D7;
  border-radius: 8px; color: var(--risk-5); font-size: 0.85rem;
  margin-bottom: 16px;
}
.error-hint { font-size: 0.75rem; color: #888; }

/* ── Disclaimer Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: #fff; border-radius: 16px;
  max-width: 560px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  padding: 28px 24px 24px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-card h2 {
  font-size: 1.15rem; font-weight: 700; color: #1B4332;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.modal-intro {
  font-size: 0.88rem; line-height: 1.7; color: #444; margin-bottom: 14px;
}
.modal-card ol {
  list-style: none; counter-reset: disclaimer;
  padding: 0; margin: 0 0 20px 0;
}
.modal-card ol li {
  counter-increment: disclaimer;
  position: relative;
  padding: 10px 12px 10px 38px;
  margin-bottom: 6px;
  font-size: 0.88rem; line-height: 1.7;
  color: var(--c-text);
  background: #F8F7F4;
  border-radius: 8px;
}
.modal-card ol li::before {
  content: counter(disclaimer);
  position: absolute; left: 12px; top: 10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--c-accent); color: #fff;
  font-size: 0.72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.modal-accept-btn {
  display: block; width: 100%; padding: 14px;
  background: linear-gradient(135deg, #1B4332 0%, #2D6A4F 100%);
  color: #fff; border: none; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: opacity 0.2s;
  font-family: var(--font-zh);
}
.modal-accept-btn:hover { opacity: 0.9; }
.modal-accept-btn:active { transform: scale(0.98); }

/* ── Marquee Banner ── */
.marquee-banner {
  background: linear-gradient(90deg, #8B2500, #C0392B, #8B2500);
  color: #fff; overflow: hidden;
  white-space: nowrap; font-size: 0.78rem;
  padding: 6px 0; position: relative; z-index: 100;
}
.marquee-banner.top { border-bottom: 2px solid #E74C3C; }
.marquee-banner.bottom { border-top: 2px solid #E74C3C; }
.marquee-track {
  display: inline-block;
  animation: marqueeScroll 35s linear infinite;
}
.marquee-track span { padding: 0 3em; }
@keyframes marqueeScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Feedback Link ── */
.feedback-card {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.feedback-left {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.feedback-left .fb-icon { font-size: 1.15rem; flex-shrink: 0; }
.feedback-left .fb-title { font-size: 0.88rem; font-weight: 600; }
.feedback-left .fb-sub {
  font-size: 0.75rem; color: var(--c-muted); margin-top: 2px;
}
.feedback-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px;
  background: linear-gradient(135deg, #1B4332, #2D6A4F);
  color: #fff; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  flex-shrink: 0; transition: opacity 0.2s;
  font-family: var(--font-zh);
}
.feedback-btn:hover { opacity: 0.88; }
.feedback-btn .arrow { font-size: 0.75rem; }
