/*
  Ember Kit — Componenti
  Vendored 1:1 da Smart Design Style (https://github.com/travelermarco/smart-design-style),
  nessuna modifica — resta compatibile upstream, così un fix nel repo
  sorgente si può ri-vendorizzare qui senza conflitti. Richiede tokens.css
  caricato prima di questo file.
  Pattern estratti da: Smartpricing (Calendario, Prezzi, BI), Smartchat (Ticket, Chat,
  Statistiche), Smartconnect (Newsletter, Automazioni) — vedi DESIGN-AUDIT.md
  nel repo sorgente per il ragionamento completo dietro ogni scelta.
*/

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  background: var(--surface-page);
  color: var(--text-primary);
}
h1, h2, h3, h4 { margin: 0; font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); }
h1 { font-size: var(--font-size-lg); }
h2 { font-size: var(--font-size-md); }
.muted { color: var(--text-secondary); }
.small { font-size: var(--font-size-xs); }

/* ---- Layout shell ---- */
.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--surface-topbar);
  border-bottom: 1px solid var(--border-default);
}
.app-sidebar {
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-default);
  width: 240px;
  padding: var(--space-4) var(--space-3);
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  text-decoration: none;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--color-accent-wash);
  color: var(--color-accent-text);
  font-weight: var(--font-weight-semibold);
}
.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--label-letter-spacing);
  color: var(--text-muted);
  padding: var(--space-3) var(--space-3) var(--space-1);
}

/* ---- Bottoni ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 38px; padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base); font-weight: var(--font-weight-medium);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--color-ink); color: var(--text-on-ink); }
.btn-primary:hover { background: var(--color-ink-hover); }
.btn-outline { background: var(--surface-card); color: var(--text-primary); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-card); border: 1px solid var(--border-default); color: var(--text-primary);
}

/* CTA riservata — SOLO per promozioni commerciali, mai per azioni funzionali */
.btn-cta-reserved {
  background: var(--color-cta-reserved); color: var(--text-on-cta-reserved);
  border-radius: var(--radius-pill); font-weight: var(--font-weight-semibold);
  padding: var(--space-2) var(--space-4); height: 34px;
}

/* ---- Badge / pill di stato: SEMPRE icona o testo esplicito, mai colore da solo ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}
.badge-good     { background: var(--status-good-wash);     color: var(--status-good-text); }
.badge-warning  { background: var(--status-warning-wash);  color: var(--status-warning-text); }
.badge-critical { background: var(--status-critical-wash); color: var(--status-critical-text); }
.badge-info     { background: var(--status-info-wash);     color: var(--status-info-text); }
.badge-neutral  { background: var(--surface-hover); color: var(--text-secondary); }
.badge-accent   { background: var(--color-accent-wash); color: var(--color-accent-text); }
.badge-ink      { background: var(--color-ink); color: var(--text-on-ink); }

/* ---- Card ---- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.card-header-group {
  background: var(--color-accent-wash);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-weight: var(--font-weight-semibold);
}

/* ---- Stat tile ---- */
.stat-tile { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-tile .stat-label { display:flex; align-items:center; gap:6px; color: var(--text-secondary); font-size: var(--font-size-sm); }
.stat-tile .stat-value { font-size: var(--font-size-xl); font-weight: var(--font-weight-bold); font-variant-numeric: proportional-nums; }
.stat-tile .stat-delta { font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); }
.stat-tile .stat-delta.up   { color: var(--status-good); }
.stat-tile .stat-delta.down { color: var(--status-critical); }
.stat-tile .stat-sub { font-size: var(--font-size-xs); color: var(--text-muted); }

/* ---- Toggle switch ---- */
.toggle { position: relative; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: var(--radius-pill); transition: background .15s;
}
.toggle .thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .track { background: var(--color-accent); }
.toggle input:checked + .track .thumb { transform: translateX(18px); }

/* ---- Segmented control ---- */
.segmented { display: inline-flex; background: var(--surface-hover); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.segmented button {
  border: none; background: transparent; padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium);
  color: var(--text-secondary); cursor: pointer; font-family: inherit;
}
.segmented button.active { background: var(--color-ink); color: var(--text-on-ink); }

/* ---- Tabella dati ---- */
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.data-table th {
  text-align: left; padding: var(--space-2) var(--space-3);
  color: var(--text-muted); font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs); text-transform: uppercase; letter-spacing: var(--label-letter-spacing);
  border-bottom: 1px solid var(--border-default);
}
.data-table td { padding: var(--space-3); border-bottom: 1px solid var(--gridline); }
.data-table tr:hover td { background: var(--surface-hover); }
.data-table tr.row-urgent td:first-child { border-left: 3px solid var(--status-critical); }
.data-table .cell-positive { color: var(--status-good); font-weight: var(--font-weight-semibold); }
.data-table .cell-negative { color: var(--status-critical); font-weight: var(--font-weight-semibold); }

/* ---- Grafici (linee/aree): riusa SEMPRE --color-accent per la serie principale ---- */
.chart-line-primary { stroke: var(--color-accent); stroke-width: 2px; fill: none; }
.chart-area-primary  { fill: var(--color-accent); opacity: 0.10; }
.chart-gridline { stroke: var(--gridline); stroke-width: 1px; }
.chart-target-line { stroke: var(--text-primary); stroke-dasharray: 4 4; stroke-width: 1.5px; }
.chart-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---- Sezioni maiuscole di form ---- */
.form-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--label-letter-spacing);
  color: var(--text-muted); font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-2);
}

/* ---- Avatar iniziali ---- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-accent-wash); color: var(--color-accent-text);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-xs); font-weight: var(--font-weight-bold);
}
