/* ==========================================================================
   FX Hub — pagina Statistiche (H2). Stili specifici delle 5 sezioni: KPI,
   donut SVG, heatmap SVG, controlli, tabella Live e theming uPlot. I token
   colore/tipografia vengono da base.css (var(--*)). La griglia (.fx-grid,
   colonne 280px, data-cols, cap 2080) è definita in shell.css: qui solo il
   contenuto delle card di sezione.
   ========================================================================== */

.fx-stats-grid { align-items: start; }

/* Card di sezione: il contenuto scorre in verticale; l'header sta in alto. */
.fx-stats-section { display: flex; flex-direction: column; gap: 12px; }
.fx-stats-section__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fx-stats-section .fx-card__title { margin-bottom: 0; }

/* Stato di caricamento/vuoto/nota comuni. */
.fx-stats-loading,
.fx-stats-empty { padding: 24px 4px; font-size: 14px; text-align: center; }
.fx-stats-note { font-size: 12px; margin: 4px 0 0; }

/* ------------------------------ Sezione A: KPI --------------------------- */
.fx-stats-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.fx-stats-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 0;
}
.fx-stats-kpi__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fx-stats-kpi__label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --------------------------- Sezione B: Andamento ------------------------ */
.fx-stats-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.fx-stats-field { display: flex; flex-direction: column; gap: 4px; }
.fx-stats-field__label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted);
}
.fx-stats-chart { min-height: 260px; width: 100%; overflow: hidden; }
/* Theming uPlot: font e colori coerenti col design system. */
.fx-stats-chart .uplot { width: 100% !important; font-family: var(--font-body); }
.fx-stats-chart .u-title,
.fx-stats-chart .u-legend { color: var(--text-muted); font-size: 12px; }
.fx-stats-chart .u-legend .u-value { color: var(--text); font-weight: 600; }

/* --------------------------- Sezione C: Donut ---------------------------- */
.fx-stats-donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.fx-donut { position: relative; width: 120px; height: 120px; flex: 0 0 120px; }
.fx-donut__svg { width: 100%; height: 100%; display: block; }
.fx-donut__track { fill: none; stroke: var(--border); stroke-width: 14; }
.fx-donut__seg { fill: none; stroke-width: 14; transition: stroke-dasharray .5s ease; }
.fx-donut__center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.fx-donut__total {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.fx-donut__legend {
  list-style: none; margin: 0; padding: 0; flex: 1 1 140px; min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.fx-donut__legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.fx-donut__swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.fx-donut__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-donut__count { font-variant-numeric: tabular-nums; font-weight: 600; flex: 0 0 auto; }

/* --------------------------- Sezione D: Heatmap -------------------------- */
.fx-stats-heatmap { width: 100%; }
.fx-heatmap__scroll { overflow-x: auto; padding-bottom: 4px; }
.fx-heatmap__svg { display: block; }
.fx-heatmap__cell { stroke: var(--surface-2); stroke-width: 1; }
.fx-heatmap__axis { fill: var(--text-subtle); font-size: 9px; font-family: var(--font-body); }
.fx-heatmap__scale { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; }
.fx-heatmap__grad {
  display: inline-block; width: 120px; height: 10px; border-radius: 5px;
  background: linear-gradient(to right,
    color-mix(in srgb, var(--primary) 15%, var(--surface)),
    var(--primary));
}

/* --------------------------- Sezione E: Live ----------------------------- */
.fx-stats-live-head { display: flex; justify-content: flex-end; }
.fx-stats-live-summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 12px; background: var(--surface); border-radius: var(--r-md);
}
.fx-stats-live-total { display: flex; flex-direction: column; }
.fx-stats-live-total__num {
  font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.fx-stats-live-total__label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.fx-stats-live-ctx { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-badge--muted { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.fx-table-wrap { overflow-x: auto; }
.fx-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.fx-nowrap { white-space: nowrap; }
.fx-ellip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-table__empty { text-align: center; color: var(--text-muted); padding: 20px; }
