/* ════════════════════════════════════════
   STATS PAGE
════════════════════════════════════════ */

/* ── Header ──────────────────────────── */
.stats-hd {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px 20px;
  margin-bottom: 14px;
}
.stats-hd-icon {
  font-size: 2rem; width: 52px; height: 52px;
  background: var(--purple-light); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stats-hd-text { flex: 1; min-width: 0; }
.stats-hd-title { font-size: 1.2rem; font-weight: 700; color: var(--text); margin: 0 0 3px; }
.stats-hd-sub   { font-size: 0.8rem; color: var(--text-muted); margin: 0; }
.stats-export-btn {
  flex-shrink: 0; padding: 9px 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 0.83rem; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.stats-export-btn:hover { border-color: var(--purple); color: var(--purple); }

/* ── 4 Stat cards ────────────────────── */
.stats-cards-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px; margin-bottom: 14px;
}
.stat-card-v2 {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px;
  display: flex; align-items: center; gap: 14px;
}
.scv2-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.scv2-purple { background: #E0F2FE; }
.scv2-green  { background: #ECFDF5; }
.scv2-orange { background: #FFF7ED; }
.scv2-blue   { background: #EFF6FF; }
.scv2-body   { min-width: 0; }
.scv2-num    { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.scv2-label  { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.scv2-sub    { font-size: 0.72rem; color: var(--purple); font-weight: 600; margin-top: 3px; }

/* ── Mid row: chart + donut / deck + heatmap ── */
.stats-mid-row {
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px;
}

/* ── Section wrapper ─────────────────── */
.stats-section {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px;
}
.stats-sh {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.stats-sh-title { font-size: 0.92rem; font-weight: 700; color: var(--text); }

/* ── Line chart ──────────────────────── */
.stats-chart-wrap  { overflow: hidden; border-radius: var(--radius-sm); }
.stats-linechart   { width: 100%; display: block; }
.stats-chart-legend{ display: flex; gap: 12px; }
.scl-item { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.scl-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Donut chart ─────────────────────── */
.stats-donut-wrap {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.stats-donut-svg-wrap {
  position: relative; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stats-donut-center {
  position: absolute; text-align: center; pointer-events: none;
}
.stats-donut-num { font-size: 1.25rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.stats-donut-lbl { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }
.stats-donut-legend { flex: 1; min-width: 120px; }
.sdl-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 0.8rem;
}
.sdl-dot {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.sdl-name  { flex: 1; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sdl-count { color: var(--text); font-weight: 700; flex-shrink: 0; }
.sdl-pct   { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }

/* ── Heatmap ─────────────────────────── */
.stats-heatmap { overflow-x: auto; }
.hm-month-row  { display: flex; align-items: flex-end; gap: 3px; padding-bottom: 4px; }
.hm-day-spacer { width: 22px; flex-shrink: 0; }
.hm-month-cell { flex: 1; font-size: 0.68rem; color: var(--text-muted); min-width: 14px; text-align: left; white-space: nowrap; }
.hm-body       { display: flex; gap: 4px; }
.hm-day-labels { display: flex; flex-direction: column; gap: 3px; justify-content: space-between; padding-top: 1px; }
.hm-day-label  { font-size: 0.65rem; color: var(--text-muted); width: 18px; text-align: right; height: 13px; line-height: 13px; }
.hm-weeks      { display: flex; gap: 3px; }
.hm-week       { display: flex; flex-direction: column; gap: 3px; }
.hm-cell       { width: 13px; height: 13px; border-radius: 2px; background: var(--border); }
.hm-cell.lv0       { background: var(--border); }
.hm-cell.lv1       { background: #C7D2FE; }
.hm-cell.lv2       { background: #A5B4FC; }
.hm-cell.lv3       { background: #818CF8; }
.hm-cell.lv4       { background: #6366F1; }
.hm-cell.lv-future { background: transparent; border: 1px dashed var(--border); }
.hm-footer      { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.hm-footer-text { font-size: 0.72rem; color: var(--text-muted); }
.hm-legend      { display: flex; align-items: center; gap: 3px; }
.hm-legend-label{ font-size: 0.68rem; color: var(--text-muted); }
.hm-legend .hm-cell { width: 11px; height: 11px; }

/* ── Deck progress ───────────────────── */
.stats-deck-item {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
}
.stats-deck-item:last-child { margin-bottom: 0; }
.sdeck-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.sdeck-content { flex: 1; min-width: 0; }
.sdeck-top  { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 5px; }
.sdeck-name { font-weight: 700; font-size: 0.88rem; }
.sdeck-total{ font-size: 0.75rem; color: var(--text-muted); }
.sdeck-bar-wrap { background: var(--border); border-radius: 4px; height: 7px; overflow: hidden; margin-bottom: 4px; }
.sdeck-bar  { height: 100%; border-radius: 4px; transition: width 0.5s; }
.sdeck-pct-row { display: flex; align-items: center; justify-content: space-between; }
.sdeck-chips{ display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.sdeck-pct  { font-size: 0.78rem; font-weight: 700; color: var(--purple); }

/* ── Streak banner ───────────────────── */
.stats-streak-banner {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
  border: 1.5px solid #FDE68A; border-radius: var(--radius);
  padding: 18px 20px; margin-top: 14px;
}
.ssb-star { font-size: 2.2rem; flex-shrink: 0; }
.ssb-body { flex: 1; }
.ssb-label{ font-size: 0.78rem; color: #92400E; font-weight: 600; margin-bottom: 3px; }
.ssb-num  { font-size: 1.6rem; font-weight: 800; color: #78350F; line-height: 1.1; }
.ssb-sub  { font-size: 0.78rem; color: #92400E; margin-top: 4px; }
.ssb-right{ font-size: 2.5rem; flex-shrink: 0; }

/* ── Empty state ─────────────────────── */
.stats-empty { font-size: 0.85rem; color: var(--text-muted); text-align: center; padding: 12px 0; }

/* ── FSRS Forecast ───────────────────── */
.sfc-overdue {
  font-size: 0.82rem; font-weight: 600; color: #92400E;
  background: rgba(217,119,6,0.1); border-radius: 6px;
  padding: 6px 10px; margin-bottom: 10px;
}
.sfc-bars    { display: flex; flex-direction: column; gap: 7px; }
.sfc-row     { display: flex; align-items: center; gap: 8px; }
.sfc-label   { width: 70px; font-size: 0.75rem; color: var(--text-muted); flex-shrink: 0; }
.sfc-bar-wrap {
  flex: 1; height: 18px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
.sfc-bar      { height: 100%; background: var(--purple); border-radius: 4px; transition: width 0.35s ease; min-width: 0; }
.sfc-bar--today { background: var(--green); }
.sfc-count   { width: 26px; text-align: right; font-size: 0.8rem; font-weight: 700; color: var(--text); flex-shrink: 0; }

/* ── Tablet ≥ 640px: 3 cards/row ──────── */
@media (min-width: 640px) {
  .stats-cards-row { grid-template-columns: repeat(3, 1fr); }
}

/* ── Desktop ≥ 1024px: 4 cards/row ─────── */
@media (min-width: 1024px) {
  .stats-cards-row  { grid-template-columns: repeat(4, 1fr); }
  .stats-mid-row    { flex-direction: row; }
  .stats-mid-row .stats-section { flex: 1; min-width: 0; }
  .hm-cell          { width: 16px; height: 16px; border-radius: 3px; }
  .hm-day-label     { height: 16px; line-height: 16px; }
  .hm-legend .hm-cell { width: 13px; height: 13px; }
}
