/**
 * AIN 2026 Dashboard 專屬樣式
 * 對位 ~/.claude/DESIGN.md 覺心營全域品牌規範（深色模式 Linear 風格）
 * 2026-05-22 完整套用 brand spec
 * 2026-05-22 polish v2：字 2x / bar datalabels / KPI 視覺重點 / unknown session 隱藏
 */

/* ─────────────────────────────────────────
   封存 Banner（2026-06-12）
───────────────────────────────────────── */
.archive-banner {
  background: rgba(110, 90, 240, 0.12);
  border-bottom: 1px solid rgba(110, 90, 240, 0.3);
  color: #9D8FF5;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  line-height: 1.5;
}

.archive-badge {
  background: rgba(110, 90, 240, 0.25);
  color: #9D8FF5;
  border: 1px solid rgba(110, 90, 240, 0.5);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.archive-back-link {
  color: var(--brand-orange);
  text-decoration: none;
  margin-left: auto;
  white-space: nowrap;
  transition: opacity var(--transition-base);
}
.archive-back-link:hover { opacity: 0.75; }

.title-archived-tag {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #9D8FF5;
  border: 1px solid rgba(110, 90, 240, 0.4);
  border-radius: var(--radius-pill);
  padding: 2px 10px;
  vertical-align: middle;
  margin-left: var(--space-3);
  text-transform: uppercase;
  -webkit-text-fill-color: initial;
  background: none;
}


/* ─────────────────────────────────────────
   Header
───────────────────────────────────────── */
.dash-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(8, 8, 20, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* 頂部品牌漸層條 */
.dash-header::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #FFD600, #FF7200, #E84000);
}

.dash-header-inner {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* 品牌 Logo 文字（取代圖檔，避免外部依賴）*/
.dash-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.dash-logo-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  background: linear-gradient(135deg, #FFD600, #FF7200, #E84000);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.dash-logo-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
}

.dash-logo-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.dash-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.dash-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  margin: 0;
  letter-spacing: 0.5px;
  color: var(--white);
  line-height: 1.3;
}

.dash-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.refresh-btn {
  background: transparent;
  border: 1.5px solid rgba(255, 114, 0, 0.4);
  color: var(--brand-orange);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.refresh-btn:hover  { background: rgba(255, 114, 0, 0.12); border-color: var(--brand-orange); transform: rotate(180deg); }
.refresh-btn:active { transform: scale(0.94) rotate(180deg); }
.refresh-btn:disabled { opacity: 0.4; cursor: wait; }


/* ─────────────────────────────────────────
   Main layout
───────────────────────────────────────── */
.dash-main {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}


/* ─────────────────────────────────────────
   Countdown (倒數) — 覺心營漸層版
───────────────────────────────────────── */
#countdown-section {
  font-size: 18px;
  position: relative;
  overflow: hidden;
}

/* 倒數 ≤ 7 天時套品牌漸層背景 */
.alert-bar.alert-red {
  background: linear-gradient(135deg, #E84000, #FF4444);
  color: var(--white);
}

/* 倒數大數字英雄展示 */
.countdown-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.countdown-days {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 120px;
  line-height: 1;
  background: linear-gradient(135deg, #FFD600, #FF7200, #E84000);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.countdown-label {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--gray);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.countdown-deadline {
  font-family: var(--font-tc);
  font-size: 20px;
  color: var(--white);
}

.countdown-alert-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: var(--space-1);
}
.countdown-alert-chip.chip-yellow { background: rgba(255, 193, 7, 0.15); color: #FFC107; border: 1px solid rgba(255, 193, 7, 0.3); }
.countdown-alert-chip.chip-red    { background: rgba(232, 64, 0, 0.15);  color: #E84000; border: 1px solid rgba(232, 64, 0, 0.3); }
.countdown-alert-chip.chip-green  { background: rgba(52, 211, 153, 0.15);color: #34D399; border: 1px solid rgba(52, 211, 153, 0.3); }


/* ─────────────────────────────────────────
   KPI grid
───────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: background var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.kpi-card:hover {
  background: var(--card-elevated);
  border-color: rgba(255, 114, 0, 0.25);
  transform: translateY(-2px);
}

.kpi-card.kpi-wide { grid-column: 1 / -1; }

.kpi-card .section-title {
  margin: 0 0 var(--space-2) 0;
  font-size: 13px;
  letter-spacing: 2px;
}

.kpi-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 64px;
  color: var(--white);
  letter-spacing: 0.5px;
  line-height: 1;
}

/* 目前報名 + 達標率：主角 — 漸層 + 光暈 */
.kpi-number.kpi-hero {
  background: linear-gradient(135deg, #FFD600, #FF7200, #E84000);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 114, 0, 0.45));
}

/* 每日需淨增：次要 — 不搶眼，灰白小字 */
.kpi-number.kpi-secondary {
  font-size: 40px;
  color: rgba(255, 255, 255, 0.65);
}

/* 舊的 kpi-strong — 重定向到 secondary（向下相容）*/
.kpi-number.kpi-strong {
  font-size: 40px;
  color: rgba(255, 255, 255, 0.65);
}

/* 次要 KPI label */
.kpi-secondary-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.kpi-sub {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--gray);
  line-height: 1.5;
}

/* 合計大卡（5/24 新增）：台灣 + 韓國淨 = 合計，一行三段視覺 */
.kpi-combined-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-2) 0 var(--space-1);
}
.kpi-piece {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.5px;
}
.kpi-piece strong {
  font-size: 44px;
  font-weight: 800;
  margin-left: var(--space-1);
  color: var(--white);
  letter-spacing: 0.5px;
}
.kpi-tw strong { color: rgba(255, 255, 255, 0.92); }
.kpi-kr strong { color: var(--lpurple, #9D8FF5); }
.kpi-total strong {
  font-size: 56px;
  background: linear-gradient(135deg, #FFD600, #FF7200, #E84000);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 12px rgba(255, 114, 0, 0.35));
}
.kpi-op {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
}


/* ─────────────────────────────────────────
   Progress bar — 覺心營漸層
───────────────────────────────────────── */
.progress-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.progress-track {
  width: 100%;
  height: 16px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FFD600, #FF7200, #E84000);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 12px rgba(255, 114, 0, 0.4);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-label > :first-child {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  background: linear-gradient(135deg, #FFD600, #FF7200, #E84000);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}


/* ─────────────────────────────────────────
   Section block 共用
───────────────────────────────────────── */
.section-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}


/* ─────────────────────────────────────────
   時段比較 table
───────────────────────────────────────── */
.time-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 16px;
}

.time-table th,
.time-table td {
  padding: var(--space-4) var(--space-3);
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.time-table th:first-child,
.time-table td:first-child {
  text-align: left;
  font-family: var(--font-tc);
  color: var(--gray);
}

.time-table th {
  color: var(--brand-orange);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1.5px;
}

.time-table tr:last-child td { border-bottom: none; }
.time-table td.num     { color: var(--white); }
.time-table td.pending { color: var(--gray-mute); font-style: italic; font-size: 14px; }


/* ─────────────────────────────────────────
   Funnel 漏斗
───────────────────────────────────────── */
.funnel {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.funnel-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: var(--space-3);
}

.funnel-label {
  font-family: var(--font-tc);
  color: var(--white);
  font-size: 18px;
}

.funnel-bar-track {
  height: 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, #FFD600, #FF7200, #E84000);
  border-radius: var(--radius-pill);
  transition: width 0.6s ease;
}

.funnel-stats {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--gray);
  white-space: nowrap;
}


/* ─────────────────────────────────────────
   說明會
───────────────────────────────────────── */
.info-sessions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.session-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-3) 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}
.session-row:last-child { border-bottom: none; }

.session-date {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--white);
}

.session-stats {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--gray);
}


/* ─────────────────────────────────────────
   Chart canvases
───────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
  max-height: 360px;
}


/* ─────────────────────────────────────────
   Channel cards 6 通路
───────────────────────────────────────── */
.channel-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.channel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: background var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}
.channel-card:hover {
  background: var(--card-elevated);
  border-color: rgba(255, 114, 0, 0.25);
  transform: translateY(-2px);
}

.channel-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--brand-orange);
}

.channel-card-stats {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--white);
}

.channel-card-rate {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--gray);
}

.channel-card-note {
  font-family: var(--font-tc);
  font-size: 15px;
  color: var(--gray-mute);
  margin-top: var(--space-1);
  line-height: 1.6;
}


/* ─────────────────────────────────────────
   Footer
───────────────────────────────────────── */
.dash-footer {
  max-width: 480px;
  margin: var(--space-8) auto 0;
  padding: var(--space-4) var(--space-4) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.footer-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.footer-copyright {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gray);
}


/* ─────────────────────────────────────────
   Error toast（漸層紅邊框版）
───────────────────────────────────────── */
.error-toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(420px, 92vw);
  width: 100%;
  background: rgba(8, 8, 20, 0.97);
  border: 1px solid rgba(232, 64, 0, 0.5);
  border-left: 3px solid #E84000;
  color: var(--white);
  padding: var(--space-5) var(--space-5);
  border-radius: var(--radius-md);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  backdrop-filter: blur(12px);
}
/* HTML [hidden] 屬性被 display:flex override，必須明寫 — 否則紅框初載就顯示 */
.error-toast[hidden] { display: none; }

.error-toast strong {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #E84000;
}

.error-toast .meta { color: rgba(255, 255, 255, 0.75); font-size: 13px; }

.error-toast-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

/* Retry 按鈕（品牌漸層）*/
.btn-retry {
  background: linear-gradient(135deg, #FFD600, #FF7200, #E84000);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: opacity var(--transition-base), transform var(--transition-base);
}
.btn-retry:hover  { opacity: 0.9; transform: translateY(-1px); }
.btn-retry:active { transform: scale(0.97); }


/* ─────────────────────────────────────────
   Loading state
───────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  background: rgba(8, 8, 20, 0.9);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.loading-overlay .loading-label {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--gray);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* 品牌色 spinner（大）*/
.spinner-lg {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 114, 0, 0.15);
  border-top-color: var(--brand-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}


/* ─────────────────────────────────────────
   手機 (< 768px) 字級與 layout
───────────────────────────────────────── */
@media (max-width: 767px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .kpi-card.kpi-wide {
    grid-column: auto;
  }
  /* 手機 KPI 主角縮到 64px（仍遠大於原版 36px）*/
  .kpi-number.kpi-hero {
    font-size: 64px;
  }
  /* 手機次要 KPI */
  .kpi-number.kpi-secondary,
  .kpi-number.kpi-strong {
    font-size: 36px;
  }
  /* 手機合計大卡：縮數字 + 留 wrap 自然換行 */
  .kpi-piece { font-size: 16px; }
  .kpi-piece strong { font-size: 32px; }
  .kpi-total strong { font-size: 44px; }
  .kpi-op { font-size: 18px; }
  /* 手機倒數英雄 */
  .countdown-days { font-size: 96px; }
  .countdown-label { font-size: 15px; }
  .countdown-deadline { font-size: 17px; }

  /* 圖表高度手機限制 */
  .chart-wrap { max-height: 280px; }

  /* 手機 dash title */
  .dash-title { font-size: 22px; }

  /* 手機 progress 百分比 */
  .progress-label > :first-child { font-size: 22px; }
}

/* ─────────────────────────────────────────
   Tablet+ 響應式
───────────────────────────────────────── */
@media (min-width: 768px) {
  .dash-header-inner,
  .dash-main,
  .dash-footer { max-width: 720px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-card.kpi-wide { grid-column: 1 / -1; }

  .channel-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }
}

@media (min-width: 1024px) {
  .dash-header-inner,
  .dash-main,
  .dash-footer { max-width: 1100px; }

  .kpi-grid { grid-template-columns: 1fr 1fr 1fr; }
  .kpi-card.kpi-wide { grid-column: auto; }
  .channel-cards { grid-template-columns: 1fr 1fr 1fr; }
  .chart-wrap { max-height: 480px; }

  .countdown-days { font-size: 140px; }
}
