/* Phase 5: Statistik-Tab — grafischer Overhaul.
   Eigene Datei, damit das styles.css nicht weiter wächst und Stat-Komponenten
   eindeutig zu finden sind. Farb-Palette ergänzt slate um Akzentfarben für
   Charts (indigo/violet/teal/emerald/amber/rose/sky). Mobile-first. */

:root {
  --acc-indigo: #6366f1;
  --acc-indigo-bg: #eef2ff;
  --acc-violet: #8b5cf6;
  --acc-violet-bg: #f5f3ff;
  --acc-teal: #14b8a6;
  --acc-teal-bg: #ccfbf1;
  --acc-emerald: #10b981;
  --acc-emerald-bg: #d1fae5;
  --acc-amber: #f59e0b;
  --acc-amber-bg: #fef3c7;
  --acc-rose: #f43f5e;
  --acc-rose-bg: #ffe4e6;
  --acc-sky: #0ea5e9;
  --acc-sky-bg: #e0f2fe;
  --acc-track: #f1f5f9;
}

/* Header über den KPIs — Profilname, Zeitraum, Gesamt-Status. */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #ffffff 0%, var(--acc-indigo-bg) 100%);
  border: 1px solid var(--slate-200);
}
.stats-header-text { flex: 1 1 260px; min-width: 220px; }
.stats-eyebrow {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--acc-indigo);
}
#statsProfileName {
  margin: 4px 0 6px;
  font-size: clamp(24px, 3.4vw, 32px);
  letter-spacing: -0.02em;
}
.stats-status {
  min-width: 200px;
  text-align: center;
  border-radius: 20px;
  padding: 14px 18px;
  background: var(--slate-950);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stats-status small { color: var(--slate-300); font-size: 12px; }
.stats-status strong { display: block; font-size: 22px; margin: 4px 0; letter-spacing: -0.01em; }

/* Leer-Zustand, wenn kein Plan / keine Dienste. */
.stats-empty {
  margin-top: 16px;
  padding: 48px 24px;
  border-radius: var(--radius);
  border: 1px dashed var(--slate-300);
  background: white;
  text-align: center;
  color: var(--slate-500);
}
.stats-empty-icon { font-size: 48px; margin-bottom: 8px; }
.stats-empty-title { font-size: 18px; font-weight: 800; color: var(--slate-700); }
.stats-empty-text { margin-top: 6px; font-size: 14px; max-width: 420px; margin-left: auto; margin-right: auto; }

/* KPI-Reihe — vier dichte Kacheln mit großem Wert. */
.stats-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 16px;
}
.kpi-card {
  position: relative;
  border-radius: 22px;
  padding: 18px;
  background: white;
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
}
.kpi-card-driving::before { background: var(--acc-indigo); }
.kpi-card-shift::before    { background: var(--acc-violet); }
.kpi-card-duties::before   { background: var(--acc-emerald); }
.kpi-card-avg::before      { background: var(--acc-sky); }

.kpi-icon { font-size: 22px; line-height: 1; }
.kpi-label {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}
.kpi-value {
  margin-top: 4px;
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--slate-950);
  line-height: 1.1;
}
.kpi-foot {
  margin-top: 8px;
  font-size: 12px;
  color: var(--slate-500);
  line-height: 1.4;
}
.kpi-ring {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 56px;
  height: 56px;
}

/* Gitter aus mittleren Stat-Karten. */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 16px;
}
.stat-card { padding: 18px 18px 20px; }
.stat-card-wide { padding: 18px 20px 22px; margin-top: 16px; }
.stat-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 800;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-body { display: block; }

/* ---------- Donut: Arbeit vs Frei ---------- */
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-svg { flex: 0 0 auto; width: 130px; height: 130px; }
.donut-center {
  font-size: 22px;
  font-weight: 900;
  fill: var(--slate-950);
}
.donut-center-sub {
  font-size: 10px;
  fill: var(--slate-500);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { color: var(--slate-700); font-weight: 600; }
.legend-value { margin-left: auto; font-weight: 800; color: var(--slate-950); }

/* ---------- Pausen-Gauge (Halbring) ---------- */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; }
.gauge-svg { width: 100%; max-width: 220px; height: 130px; }
.gauge-value { font-size: 30px; font-weight: 900; fill: var(--slate-950); }
.gauge-sub { font-size: 11px; fill: var(--slate-500); font-weight: 700; }
.gauge-foot {
  margin-top: 4px;
  font-size: 12px;
  color: var(--slate-500);
  text-align: center;
  line-height: 1.4;
}

/* ---------- Uhren: Frühester / Spätester ---------- */
.clocks-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.clock-block { text-align: center; }
.clock-svg { width: 90px; height: 90px; }
.clock-tick { stroke: var(--slate-300); stroke-width: 1.5; }
.clock-face { fill: var(--slate-50); stroke: var(--slate-200); stroke-width: 2; }
.clock-hand-h { stroke: var(--slate-950); stroke-width: 3; stroke-linecap: round; }
.clock-hand-m { stroke: var(--slate-700); stroke-width: 2; stroke-linecap: round; }
.clock-pin { fill: var(--slate-950); }
.clock-label-time { margin-top: 4px; font-size: 18px; font-weight: 900; letter-spacing: -0.01em; }
.clock-label-tag { font-size: 12px; color: var(--slate-500); margin-top: 1px; }
.clock-label-which {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--acc-indigo);
}
.clock-block.late .clock-label-which { color: var(--acc-violet); }

/* ---------- Schichttyp-Bars ---------- */
.shifttype-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-items: end;
  height: 150px;
}
.shifttype-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  height: 100%;
}
.shifttype-bar-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  background: var(--acc-track);
  border-radius: 10px;
  overflow: hidden;
  min-height: 12px;
  position: relative;
}
.shifttype-bar {
  width: 100%;
  border-radius: 10px;
  transition: height .3s ease;
  position: relative;
}
.shifttype-bar-fruh   { background: linear-gradient(180deg, #fde68a, var(--acc-amber)); }
.shifttype-bar-tag    { background: linear-gradient(180deg, #bae6fd, var(--acc-sky)); }
.shifttype-bar-spaet  { background: linear-gradient(180deg, #c4b5fd, var(--acc-violet)); }
.shifttype-bar-nacht  { background: linear-gradient(180deg, #475569, var(--slate-950)); }
.shifttype-count {
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  margin-top: 6px;
  color: var(--slate-950);
}
.shifttype-name {
  text-align: center;
  font-size: 11px;
  color: var(--slate-500);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.shifttype-time {
  text-align: center;
  font-size: 10px;
  color: var(--slate-400);
}

/* ---------- Streak ---------- */
.streak-wrap { text-align: center; padding: 6px 0 4px; }
.streak-number {
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--acc-rose), var(--acc-violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.04em;
  line-height: 1;
}
.streak-unit { font-size: 14px; color: var(--slate-500); margin-top: 4px; font-weight: 600; }
.streak-range {
  margin-top: 10px;
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--acc-rose-bg);
  color: #9f1239;
  font-size: 12px;
  font-weight: 700;
}

/* ---------- Wochentag-Bars ---------- */
.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  align-items: end;
  height: 140px;
}
.weekday-col {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.weekday-bar-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  background: var(--acc-track);
  border-radius: 8px;
  min-height: 8px;
  overflow: hidden;
}
.weekday-bar {
  width: 100%;
  background: linear-gradient(180deg, #a5b4fc, var(--acc-indigo));
  border-radius: 8px;
  min-height: 4px;
}
.weekday-bar.weekend {
  background: linear-gradient(180deg, #fda4af, var(--acc-rose));
}
.weekday-bar.empty { background: transparent; min-height: 0; }
.weekday-count {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--slate-700);
}
.weekday-name {
  text-align: center;
  font-size: 11px;
  color: var(--slate-500);
  font-weight: 700;
}

/* ---------- Wochenlenkzeit-Chart ---------- */
.weekly-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  padding-top: 10px;
  position: relative;
  border-bottom: 1px solid var(--slate-200);
  padding-bottom: 4px;
}
.weekly-col {
  flex: 1 1 0;
  min-width: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.weekly-bar-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}
.weekly-bar {
  width: 100%;
  background: linear-gradient(180deg, #c7d2fe, var(--acc-indigo));
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  position: relative;
}
.weekly-bar.over { background: linear-gradient(180deg, #fda4af, var(--acc-rose)); }
.weekly-bar.warn { background: linear-gradient(180deg, #fcd34d, var(--acc-amber)); }
.weekly-bar:hover::after {
  content: attr(data-label);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -6px);
  background: var(--slate-950);
  color: white;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
.weekly-tooltip {
  position: absolute;
  font-size: 11px;
  color: var(--slate-700);
  font-weight: 700;
  margin-bottom: 4px;
}
.weekly-axis-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  font-size: 10px;
  color: var(--slate-500);
  font-weight: 600;
}
.weekly-axis-label {
  flex: 1 1 0;
  min-width: 18px;
  text-align: center;
}
.weekly-legend {
  margin-top: 12px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--slate-600);
}
.weekly-legend-item { display: flex; align-items: center; gap: 6px; }
.weekly-legend-swatch { width: 12px; height: 12px; border-radius: 4px; }

/* ---------- Top-5-Dienste ---------- */
.topduties-list { display: flex; flex-direction: column; gap: 10px; }
.topduties-row {
  display: grid;
  grid-template-columns: 50px 1fr 60px;
  align-items: center;
  gap: 12px;
}
.topduties-num {
  font-weight: 900;
  font-size: 15px;
  color: var(--slate-950);
  background: var(--slate-100);
  padding: 4px 8px;
  border-radius: 8px;
  text-align: center;
}
.topduties-track {
  height: 22px;
  background: var(--acc-track);
  border-radius: 11px;
  overflow: hidden;
  position: relative;
}
.topduties-fill {
  height: 100%;
  border-radius: 11px;
  background: linear-gradient(90deg, var(--acc-teal), var(--acc-indigo));
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 24px;
}
.topduties-count {
  font-weight: 800;
  font-size: 14px;
  color: var(--slate-700);
}
.topduties-count-unit { font-size: 11px; color: var(--slate-500); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .stats-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .clocks-wrap { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .stats-header { flex-direction: column; }
  .stats-status { width: 100%; }
  .stats-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut-svg { align-self: center; }
  .topduties-row { grid-template-columns: 44px 1fr 50px; gap: 8px; }
  .weekly-chart { height: 160px; gap: 4px; }
  .shifttype-bars { gap: 6px; }
}
