/* ============================================================================
   SDG DESIGN SYSTEM  —  Imateg 93
   ----------------------------------------------------------------------------
   Fonte di verità del linguaggio visivo dell'SDG (token + componenti).
   Canone = homepage SDG (navy #071b38 + turchese #00a9c8, Roboto, pulito/pro).
   Framework-agnostic: usabile dall'app React e dal CPQ HTML standalone.

   Font unico SDGi = Roboto (in app/index.html è già un <link> Google Fonts;
   nei file standalone aggiungere lo stesso <link>).

   Heritage (vecchio brand book, NON canone): font Montserrat, navy #000080,
   logo "imateg dal 1993" con motivo a 3 barrette + variante tricolore.
   v1.0 — 2026-05-22 — chat_cpq_redesign_brand
   ========================================================================== */

:root {
  /* --- Brand -------------------------------------------------------------- */
  --navy: #071b38;          /* primario: titoli, sidebar, testo forte        */
  --navy-soft: #183454;     /* navy secondario / hover scuri                 */
  --navy-ink: #081b36;      /* testo principale                              */

  --accent: #00a9c8;        /* turchese: azione primaria, accenti            */
  --accent-strong: #0090ab; /* hover azione                                  */
  --accent-ink: #1b5b94;    /* testo su tinta chiara / stato attivo          */
  --accent-050: #e8f6fa;    /* sfondo tenue                                  */
  --accent-100: #d4eef5;    /* sfondo tinta                                  */
  --accent-tint: #e8f2f8;   /* stato attivo nav (come homepage)             */

  /* Heritage "Made in Italy" — accento opzionale (motivo 3 barrette logo) */
  --it-green: #149954;
  --it-white: #ffffff;
  --it-red: #d23b3b;

  /* --- Neutri / testo ---------------------------------------------------- */
  --ink: #081b36;           /* testo principale                              */
  --text: #39506d;          /* testo standard (nav idle homepage)            */
  --text-2: #415873;        /* testo azioni                                  */
  --muted: #617089;         /* testo secondario / descrizioni                */
  --faint: #8595a8;         /* testo terziario / placeholder                 */

  /* --- Superfici / linee ------------------------------------------------- */
  --bg: #f7f9fb;            /* sfondo pagina                                 */
  --bg-2: #eef4f8;          /* sfondo alternativo                            */
  --surface: #ffffff;       /* card / pannelli                               */
  --surface-2: #f6f9fc;     /* sidebar / superfici tenui                     */
  --line: #e3e9f0;          /* bordo standard                                */
  --line-2: #cdd8e4;        /* bordo marcato / hover                         */

  /* --- Semantici --------------------------------------------------------- */
  --success: #1b9e6b;  --success-bg: #e7f6ef;  --success-line: #bfe6d4;
  --warning: #c8810a;  --warning-bg: #fdf3e2;  --warning-line: #f3dcb0;
  --danger:  #d64545;  --danger-bg:  #fdecec;  --danger-line:  #f4c9c9;
  --info:    #00a9c8;  --info-bg:    #e8f6fa;  --info-line:    #bfe8f1;

  /* --- Tipografia -------------------------------------------------------- */
  --font: "Roboto", "Segoe UI", Arial, sans-serif;
  --font-num: "Roboto", "Segoe UI", Arial, sans-serif; /* tabular: vedi .num */

  --fs-display: 30px;  /* H1 topbar                                          */
  --fs-h1: 24px;
  --fs-h2: 20px;       /* titolo card                                        */
  --fs-h3: 17px;       /* section header                                     */
  --fs-lg: 16px;
  --fs-body: 15px;     /* corpo                                              */
  --fs-sm: 13px;
  --fs-cap: 12px;      /* didascalie                                         */
  --fs-over: 11px;     /* overline / badge (uppercase)                       */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-black: 800;

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-normal: 1.5;

  /* --- Spaziatura (base 4px) -------------------------------------------- */
  --sp-1: 4px;   --sp-2: 8px;   --sp-3: 12px;  --sp-4: 16px;
  --sp-5: 20px;  --sp-6: 24px;  --sp-7: 28px;  --sp-8: 32px;
  --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* --- Raggi ------------------------------------------------------------- */
  --r-xs: 6px;
  --r-sm: 9px;    /* bottoni, nav-item                                       */
  --r-md: 12px;   /* input, frame                                            */
  --r-lg: 16px;   /* card                                                    */
  --r-xl: 22px;
  --r-pill: 999px;

  /* --- Ombre ------------------------------------------------------------- */
  --shadow-sm: 0 1px 2px rgba(8, 27, 54, 0.06), 0 1px 3px rgba(8, 27, 54, 0.05);
  --shadow: 0 14px 34px rgba(8, 27, 54, 0.08);
  --shadow-hover: 0 18px 42px rgba(8, 27, 54, 0.14);

  /* --- Altro ------------------------------------------------------------- */
  --ring: 0 0 0 3px rgba(0, 169, 200, 0.30); /* focus turchese              */
  --t: 0.2s ease;
  --maxw: 1460px;
}

/* ============================================================================
   BASE  —  applicare la classe .sdg al contenitore radice (body o wrapper)
   ========================================================================== */
.sdg,
.sdg * {
  box-sizing: border-box;
}

.sdg {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sdg h1, .sdg h2, .sdg h3, .sdg h4 {
  color: var(--navy);
  line-height: var(--lh-tight);
  margin: 0 0 var(--sp-3);
  letter-spacing: -0.2px;
}
.sdg h1 { font-size: var(--fs-display); font-weight: var(--fw-black); letter-spacing: -0.3px; }
.sdg h2 { font-size: var(--fs-h2); font-weight: var(--fw-black); }
.sdg h3 { font-size: var(--fs-h3); font-weight: var(--fw-bold); }
.sdg p  { margin: 0 0 var(--sp-3); }
.sdg a  { color: var(--accent-ink); text-decoration: none; }
.sdg a:hover { text-decoration: underline; }
.sdg small { font-size: var(--fs-sm); }

/* Numeri tabellari (importi, quantità) */
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* Overline / etichetta sezione */
.overline {
  font-size: var(--fs-over);
  font-weight: var(--fw-bold);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

/* Nota: .accent-line è definita in sdg.css (app) per non confliggere col guscio. */

/* ============================================================================
   ICONE  —  stile linea unico per tutto l'SDG
   tratto ~1.6, fill none, terminali tondi, griglia 24, colore currentColor.
   ========================================================================== */
.ico {
  width: 1.5em; height: 1.5em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.ico--sm { width: 1.1em; height: 1.1em; }
.ico--lg { width: 2.6em; height: 2.6em; stroke-width: 1.5; }
.ico--xl { width: 4em;   height: 4em;   stroke-width: 1.45; }

/* ============================================================================
   BOTTONI
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 42px;
  padding: 0 var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--t);
  text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn .ico { width: 1.25em; height: 1.25em; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); }

.btn--secondary { background: #fff; color: var(--navy); border-color: var(--line-2); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--accent); color: var(--accent-ink); }

.btn--navy { background: var(--navy); color: #fff; }
.btn--navy:hover { background: var(--navy-soft); }

.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--bg-2); }

/* bottoni-link (<a class="btn ...">): NON devono ereditare il colore dei link (.sdg a = turchese).
   Specificita' >= .sdg a (0,1,1) per garantire il contrasto corretto (es. navy = testo bianco). */
a.btn--navy, .sdg a.btn--navy, a.btn--primary, .sdg a.btn--primary, a.btn--danger, .sdg a.btn--danger { color: #fff; }
a.btn--secondary, .sdg a.btn--secondary { color: var(--navy); }
a.btn--ghost, .sdg a.btn--ghost { color: var(--text-2); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(0.94); }

.btn--sm { height: 34px; padding: 0 var(--sp-4); font-size: var(--fs-sm); }
.btn--lg { height: 50px; padding: 0 var(--sp-7); font-size: var(--fs-lg); }
.btn--block { width: 100%; }

.btn--icon {
  width: 38px; height: 38px; padding: 0;
  border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  border-color: var(--line);
}
.btn--icon:hover { background: var(--bg-2); color: var(--accent-ink); }

/* ============================================================================
   FORM
   ========================================================================== */
.field { display: block; margin-bottom: var(--sp-4); }
.field__label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
  margin-bottom: var(--sp-2);
}
.req { color: var(--danger); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px var(--sp-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: #fff;
  font-family: inherit;
  font-size: var(--fs-body);
  color: var(--ink);
  transition: var(--t);
}
.textarea { min-height: 92px; padding: var(--sp-3); resize: vertical; line-height: var(--lh-normal); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23617089' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
}
/* Stato errore / campo obbligatorio mancante */
.input--invalid, .select--invalid, .is-invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.field-help { display: block; font-size: var(--fs-cap); color: var(--muted); margin-top: var(--sp-1); }
.field-help--error { color: var(--danger); }

/* Checkbox / radio (accent nativo coerente) */
.check, .radio { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-body); }
.check input, .radio input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

/* Switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--line-2); border-radius: var(--r-pill); transition: var(--t);
}
.switch__slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: var(--t);
}
.switch input:checked + .switch__slider { background: var(--accent); }
.switch input:checked + .switch__slider::before { transform: translateX(18px); }

/* ============================================================================
   BADGE / TAG / CHIP
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  font-size: var(--fs-over);
  font-weight: var(--fw-bold);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  background: var(--bg-2); color: var(--text-2);
  line-height: 1;
}
.badge--accent  { background: var(--accent-100); color: var(--accent-ink); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--navy    { background: var(--navy); color: #fff; }

/* Tag = pillola informativa non-uppercase */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  background: #fff; border: 1px solid var(--line-2); color: var(--text-2);
}
.tag .ico { width: 1em; height: 1em; }

/* ============================================================================
   PANNELLI / CARD / SECTION HEADER
   ========================================================================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-6);
}
.panel--flush { padding: 0; overflow: hidden; }

/* Section header: titoletto con icona turchese (come .shdr del CPQ) */
.shead {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: 0 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.shead .ico { color: var(--accent); width: 1.4em; height: 1.4em; }
.shead h3 { margin: 0; }
.shead__sub { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); }

/* ============================================================================
   TABS
   ========================================================================== */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none; border: none; background: none; font-family: inherit;
  padding: 12px var(--sp-5);
  font-size: var(--fs-body); font-weight: var(--fw-semibold);
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: var(--t);
  display: inline-flex; align-items: center; gap: var(--sp-2);
}
.tab:hover { color: var(--navy); }
.tab.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* ============================================================================
   TABELLE DATI  (es. cost breakdown CPQ)
   ========================================================================== */
.dtable { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.dtable th, .dtable td { padding: 11px var(--sp-3); text-align: left; }
.dtable thead th {
  font-size: var(--fs-cap); font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.dtable tbody td { border-bottom: 1px solid var(--line); color: var(--text); }
.dtable tbody tr:hover td { background: var(--surface-2); }
.dtable .num, .dtable td.r, .dtable th.r { text-align: right; font-variant-numeric: tabular-nums; }
.dtable tr.is-sub td { color: var(--muted); font-size: var(--fs-sm); }
.dtable tr.is-total td {
  font-weight: var(--fw-bold); color: var(--navy);
  border-top: 2px solid var(--navy); border-bottom: none;
  background: var(--surface-2);
}

/* ============================================================================
   ALERT / BANNER
   ========================================================================== */
.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-sm); color: var(--text);
}
.alert .ico { width: 1.25em; height: 1.25em; margin-top: 1px; flex: none; }
.alert--info    { background: var(--info-bg);    border-color: var(--info-line);    border-left-color: var(--info); }
.alert--success { background: var(--success-bg); border-color: var(--success-line); border-left-color: var(--success); }
.alert--warning { background: var(--warning-bg); border-color: var(--warning-line); border-left-color: var(--warning); }
.alert--danger  { background: var(--danger-bg);  border-color: var(--danger-line);  border-left-color: var(--danger); }
.alert__title { font-weight: var(--fw-bold); color: var(--ink); display: block; margin-bottom: 2px; }

/* ============================================================================
   KPI / STAT
   ========================================================================== */
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-4) var(--sp-5);
}
.kpi__label { font-size: var(--fs-cap); color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: var(--fw-semibold); }
.kpi__val { font-size: clamp(17px, 1.7vw, 22px); font-weight: var(--fw-black); color: var(--navy); line-height: 1.15; margin-top: 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi__val.pos { color: var(--success); }
.kpi__val.neg { color: var(--danger); }
.kpi--accent { background: linear-gradient(135deg, var(--navy), var(--navy-soft)); border: none; }
.kpi--accent .kpi__label { color: rgba(255,255,255,0.7); }
.kpi--accent .kpi__val { color: #fff; }

/* ============================================================================
   UTILITY minime
   ========================================================================== */
.u-navy { color: var(--navy) !important; }
.u-accent { color: var(--accent) !important; }
.u-muted { color: var(--muted) !important; }
.u-right { text-align: right; }
.u-center { text-align: center; }
.row { display: flex; gap: var(--sp-3); align-items: center; }
.row--wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.divider-x { height: 1px; background: var(--line); border: none; margin: var(--sp-5) 0; }
.divider-y { width: 1px; align-self: stretch; background: var(--line); }
