/**
 * jpms-theme.css — Design system condiviso JPMS Italia
 * Palette ufficiale + tipografia + componenti base
 *
 * FONT: Helvetica Neue LT Std 75 Bold (headline) + 55 Roman (body)
 * File font da caricare in assets/fonts/ — vedi README.
 */

/* ─── Font Face (decommentare dopo aver caricato i .woff2) ───────────────── */
/*
@font-face {
  font-family: 'HelveticaNeueLTStd';
  src: url('fonts/HelveticaNeueLTStd-Bd.woff2') format('woff2'),
       url('fonts/HelveticaNeueLTStd-Bd.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'HelveticaNeueLTStd';
  src: url('fonts/HelveticaNeueLTStd-Roman.woff2') format('woff2'),
       url('fonts/HelveticaNeueLTStd-Roman.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
*/

/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  /* Palette JPMS ufficiale */
  --jpms-taupe:        #B7A99A;
  --jpms-beige:        #F0EBE3;
  --jpms-brown:        #7A5C44;
  --jpms-charcoal:     #2D2D2D;
  --jpms-lilla:        #8D89A5;
  --jpms-lilla-med:    #7B76A0;
  --jpms-lilla-dark:   #5C5880;
  --jpms-cyan:         #4EA8B8;
  --jpms-ocra:         #C9973B;

  /* Colori semantici */
  --pos:         #2E7D32;
  --pos-soft:    rgba(46,125,50,.1);
  --neg:         #C62828;
  --neg-soft:    rgba(198,40,40,.08);
  --warn:        #E65100;
  --warn-soft:   rgba(230,81,0,.1);
  --info:        #0277BD;
  --info-soft:   rgba(2,119,189,.1);

  /* Superfici */
  --bg:          #F7F5F2;
  --surface:     #FFFFFF;
  --surface-alt: #F5F3EF;
  --line:        #E0D9D1;
  --line-soft:   #EDE8E2;

  /* Testo */
  --ink:         #1E1E1E;
  --ink-soft:    #5A5550;
  --muted:       #9E9690;
  --accent-soft: rgba(141,137,165,.12);

  /* Ombre */
  --shadow:       0 1px 3px rgba(0,0,0,.07), 0 1px 8px rgba(0,0,0,.04);
  --shadow-hover: 0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);

  /* Tipografia */
  --font-headline: 'HelveticaNeueLTStd', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:     'HelveticaNeueLTStd', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Border radius */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   18px;
}

/* ─── Reset base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* ─── Componente: Badge ──────────────────────────────────────────────────── */
.jpms-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--jpms-lilla-dark);
}
.jpms-badge.brown  { background: #EFE7DE; color: var(--jpms-brown); }
.jpms-badge.taupe  { background: #EFEAE3; color: #6B543C; }
.jpms-badge.green  { background: var(--pos-soft); color: var(--pos); }
.jpms-badge.ocra   { background: var(--warn-soft); color: var(--warn); }
.jpms-badge.cyan   { background: var(--info-soft); color: var(--info); }
.jpms-badge.muted  { background: rgba(0,0,0,.05); color: var(--muted); }
.jpms-badge.red    { background: var(--neg-soft); color: var(--neg); }

/* ─── Componente: KPI Card ───────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.kpi-value {
  font-family: var(--font-headline);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}
.kpi-delta {
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.kpi-delta.pos { color: var(--pos); }
.kpi-delta.neg { color: var(--neg); }
.kpi-delta.neu { color: var(--muted); }

/* ─── Componente: Sezione con titolo ─────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.section-title {
  font-family: var(--font-headline);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Layout: KPI grid ──────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Componente: Tab bar ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn.active {
  color: var(--jpms-lilla-dark);
  border-bottom-color: var(--jpms-lilla-med);
}
.tab-btn:hover:not(.active) { color: var(--ink-soft); }

/* ─── Componente: Chart container ───────────────────────────────────────── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-title {
  font-family: var(--font-headline);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
}
.chart-wrap {
  position: relative;
  height: 220px;
}

/* ─── Componente: Sync status badge ─────────────────────────────────────── */
.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.sync-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--pos);
  flex-shrink: 0;
}
.sync-dot.stale { background: var(--warn); }
.sync-dot.error { background: var(--neg); }

/* ─── Componente: Tabella dati ──────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-alt); }
.data-table td.num {
  font-family: var(--font-headline);
  font-weight: 700;
  color: var(--ink);
  text-align: right;
}

/* ─── No-data state ─────────────────────────────────────────────────────── */
.no-data {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.no-data .icon { font-size: 36px; margin-bottom: 10px; opacity: .5; }
.no-data p { font-size: 13px; margin: 0; }
