/* ============================================================
   Sprint 16 — Design audit fix-up
   Home stats panel + projects strip + tag chips + TO-BE
   bottleneck cards + SAVOIA grid + minimap floating + KPI tight
   ============================================================ */

/* SP19-1: Minimap di nuovo a DESTRA (era stata spostata a sinistra in SP18-2
   ma copriva la chat). Il TobeReadyCTA bottom-right è stato rimosso (SP19-2)
   quindi non c'è più conflitto. */
.minimap {
  position: fixed !important;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.18);
  background: var(--bg-elev);
}
@media print { .minimap { display: none !important; } }
/* Sotto i 900px nascondi (mobile non ha senso) */
@media (max-width: 900px) { .minimap { display: none !important; } }

/* SP17-2 + SP19-4: KPI bar dimensioni design + altezza -20%.
   Padding verticale ridotto a 8px (era 12), orizzontale 14 invariato.
   Value 28pt, label 9.5pt, sub 11pt. */
.kpibar { padding: 8px var(--pad-x); gap: 2px; }
.kpibar .kpi {
  padding: 8px 14px;
  min-width: 0;
  gap: 2px;
}
.kpibar .kpi__value {
  font-size: 28px !important;
  letter-spacing: -0.02em;
}
.kpibar .kpi__value .u {
  font-size: 11px;
  margin-left: 3px;
}
.kpibar .kpi__sub { font-size: 11px; }
.kpibar .kpi__label { font-size: 9.5px; }
.kpibar .kpi__delta { top: 12px; right: 14px; font-size: 10px; }

/* SP16-1: Home hero stats panel */
.home__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.home__stat {
  background: var(--bg-elev);
  padding: 14px 16px;
}
.home__stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.home__stat-value {
  font-family: var(--font-numeric);
  font-weight: 400;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.home__stat-value .u {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-mute);
  margin-left: 4px;
  vertical-align: 0.65em;
}

/* Section heads coerenti col design (3 colonne) */
.home__sectionhead {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 16px;
}
.home__sectionhead .num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
}
.home__sectionhead h2 { font-size: 20px; }
.home__sectionhead p {
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 44ch;
  margin: 0;
}
@media (max-width: 800px) {
  .home__sectionhead { grid-template-columns: 1fr; }
}

/* SP16-2: Projects row strip */
.projects-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.project-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.project-card:hover {
  transform: translateY(-1px);
  border-color: var(--ink-soft);
}
.project-card.is-active {
  box-shadow: 0 0 0 2px color-mix(in oklch, var(--project-color, var(--ink)), white 70%);
}
.project-card__color {
  width: 8px;
  height: 36px;
  border-radius: 3px;
  flex-shrink: 0;
}
.project-card__body { flex: 1; min-width: 0; }
.project-card__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  line-height: 1.2;
}
.project-card__meta {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 3px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* Project detail bar */
.home__projectbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* SP16-3: Tag filter chip row */
.home__tagfilter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 0;
  margin: 8px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.tag-filter {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-soft);
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.tag-filter:hover { border-color: var(--ink-soft); color: var(--ink); }
.tag-filter.is-active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.home__filterstats {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  margin-left: auto;
}

/* "Inizia nuova intervista" card */
.home__newcard {
  margin-bottom: 16px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
}
.home__newcard:hover {
  border-color: var(--primary);
  background: color-mix(in oklch, var(--primary-soft), var(--bg-elev) 70%);
}
.home__newcard h3 {
  font-size: 16px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.home__newcard p {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0;
}
@media (max-width: 800px) {
  .home__newcard { grid-template-columns: 1fr; gap: 12px; }
}

/* SP16-4: TO-BE big hero */
.tobe__big {
  display: grid;
  grid-template-columns: 1fr 60px 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 24px;
}
.tobe__big-cell {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.tobe__big-cell--waste {
  background: color-mix(in oklch, var(--waste-soft), var(--bg-elev) 60%);
  border-color: color-mix(in oklch, var(--waste), transparent 75%);
}
.tobe__big-cell--save {
  background: color-mix(in oklch, var(--save-soft), var(--bg-elev) 60%);
  border-color: color-mix(in oklch, var(--save), transparent 75%);
}
.tobe__big-cell-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.tobe__big-cell--waste .tobe__big-cell-label { color: var(--waste-ink); }
.tobe__big-cell--save .tobe__big-cell-label { color: var(--save-ink); }
.tobe__big-value {
  font-family: var(--font-numeric);
  font-weight: 400;
  font-size: 52px;
  line-height: 1;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 4px 0 6px;
}
.tobe__big-value .u {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink-mute);
  margin-left: 4px;
  vertical-align: 0.5em;
}
.tobe__big-cell--waste .tobe__big-value { color: var(--waste-ink); }
.tobe__big-cell--save .tobe__big-value { color: var(--save-ink); }
.tobe__big-cell-sub { font-size: 12px; color: var(--ink-soft); line-height: 1.4; }
.tobe__big-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mute);
  font-size: 32px;
  line-height: 1;
}
@media (max-width: 800px) {
  .tobe__big { grid-template-columns: 1fr; }
  .tobe__big-arrow { transform: rotate(90deg); padding: 4px 0; }
}

/* SP16-4: TO-BE bottleneck card */
.tobe__bottleneck {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  margin-bottom: 16px;
  overflow: hidden;
}
.tobe__bottleneck-head {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
}
.tobe__bottleneck-rank {
  font-family: var(--font-numeric);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--waste-ink);
  line-height: 1;
  text-align: center;
}
.tobe__bottleneck-title h4 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}
.tobe__bottleneck-title .sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
  line-height: 1.4;
}
.tobe__bottleneck-impact {
  text-align: right;
}
.tobe__bottleneck-impact .num {
  font-family: var(--font-numeric);
  font-size: 22px;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.tobe__bottleneck-impact .sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.tobe__ideas { display: flex; flex-direction: column; }
.tobe__idea {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
  align-items: flex-start;
}
.tobe__idea:last-child { border-bottom: none; }
.tobe__idea:hover {
  background: color-mix(in oklch, var(--primary-soft), var(--bg-elev) 70%);
}
.tobe__idea.is-picked {
  background: color-mix(in oklch, var(--save-soft), var(--bg-elev) 60%);
}
.tobe__idea-icn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-sunken);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mute);
  font-size: 14px;
  flex-shrink: 0;
}
.tobe__idea.is-picked .tobe__idea-icn {
  background: var(--save-ink);
  color: white;
}
.tobe__idea h5 {
  font-size: 14px;
  margin: 0;
  font-weight: 500;
  /* SP24-C: titoli idee non si tagliano mai */
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}
.tobe__idea p {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 4px 0 8px;
  line-height: 1.4;
  /* SP24-C: descrizioni lunghe vanno a capo */
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* SP24-C: la colonna centrale del grid (1fr) deve potersi restringere
   per non far traboccare il contenuto della terza colonna. */
.tobe__idea > div { min-width: 0; }
.tobe__idea-meta { display: flex; gap: 4px; flex-wrap: wrap; }

/* SP16-5: SAVOIA X-Y-Z card */
.savoia {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.savoia__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  /* SP24-C: niente overflow:hidden — il titolo deve poter andare a capo,
     non essere tagliato. Il tag di stato va a capo se non c'è spazio. */
}
.savoia__title {
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-display);
  /* SP24-C: titoli lunghi AI-generati vanno a capo invece di essere
     troncati / scappare fuori dal card. min-width:0 sblocca il break
     dentro flex; overflow-wrap:anywhere copre anche parole molto lunghe
     senza spazi. line-height generoso per leggibilità multi-riga. */
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}
.savoia__xyz {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
}
.savoia__xyz-letter {
  font-family: var(--font-numeric);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.savoia__xyz-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}

/* SP16-8: Report tab bar */
.report__tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-sunken);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.report__tab {
  border: 0;
  background: transparent;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.report__tab:hover:not(.is-active) {
  background: var(--bg-elev);
  color: var(--ink);
}
.report__tab.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ============================================================
   SP24-C — Safety net globale "niente testo tagliato"
   ============================================================
   Regola del prodotto: nessun testo deve mai essere troncato per
   nessun motivo. Se serve, va a capo. Se proprio va a capo male,
   adattiamo il design — non spunto un ellipsis. Queste regole sono
   un fallback per i titoli/h3-h5 e i nodi card più diffusi sulle
   pagine TO-BE / Edit / Report che potrebbero ospitare testo AI
   o input utente lunghi.
   ============================================================ */

/* Headings dentro cards: niente troncamento, vanno a capo */
.card h1, .card h2, .card h3, .card h4, .card h5,
.savoia h1, .savoia h2, .savoia h3, .savoia h4, .savoia h5 {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}

/* Cards con grid devono lasciare le colonne 1fr restringibili */
.savoia, .tobe__idea, .tobe__bn-card, .card {
  min-width: 0;
}

/* Quando un layout flex affianca titolo + tag/button, il titolo
   deve poter restringersi (min-width:0) e il tag deve poter andare
   a capo. Tag/button rimangono "shrink:0" perché sono atomici. */
.savoia__head > .tag,
.card .tag {
  flex-shrink: 0;
}

/* ============================================================
   SP32-D — Mobile audit dei dialog popup (WizardTobeDialog,
   MappingControlWizard, LsmParsePreviewDialog, ecc.)
   ============================================================
   I dialog sono fixed inset:0 con card max-width:1080 centrata.
   Sotto i 600px il padding interno (clamp 20-36px) restringe
   troppo. Mettiamo override più aggressivi su mobile.
   ============================================================ */
@media (max-width: 600px) {
  /* Backdrop padding zero su mobile: card prende l'intero viewport */
  [role="dialog"][aria-modal="true"] {
    padding: 0 !important;
  }
  /* Card interna senza border-radius pieno: full-screen mobile */
  [role="dialog"][aria-modal="true"] > div {
    border-radius: 0 !important;
    max-height: 100dvh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
  }
  /* Header dialog: stack verticale (titolo + chiusura), tutto wrap */
  [role="dialog"][aria-modal="true"] > div > header {
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 8px !important;
  }
  /* Footer dialog: padding ridotto, bottoni full-width se da soli */
  [role="dialog"][aria-modal="true"] > div > footer {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}
