/* GV Note Spese – stili del prototipo.
 * Base: tema PrimeNG saga-blue + PrimeFlex come gv-fe (styles.scss).
 * Sezione 1: struttura dei componenti PrimeNG (in Angular arriva dagli stili dei componenti).
 * Sezione 2: stili ripresi da fatture-passive (pillar, code-kind, avvisi).
 * Sezione 3: specifici del prototipo. */

/* ---------- base gv-fe ---------- */
html, body { font-size: 14px; }
body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--surface-ground);
  color: var(--text-color);
}
/* Il tema PrimeNG 17 sta in @layer primeng: le regole qui sotto (fuori layer) vincono sempre,
   quindi niente selettori generici che tocchino i componenti (es. "a" colorerebbe i p-button-link). */
a:not([class]) { color: var(--primary-color); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
body.nsp-noscroll { overflow: hidden; }

/* ======================================================= 1. struttura PrimeNG */
.p-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.p-toolbar-group-start, .p-toolbar-group-end { display: flex; align-items: center; }
.nsp-toolbar { padding: .5rem .75rem; }
.nsp-vdivider { width: 1px; height: 1.5rem; margin: 0 .5rem; background: var(--surface-border); align-self: center; }

.p-button { text-decoration: none; }
a.p-button:hover { text-decoration: none; }

.p-tag { display: inline-flex; align-items: center; justify-content: center; gap: .25rem; line-height: 1.2; white-space: nowrap; }
.p-tag .p-tag-icon { font-size: .75rem; }
.p-tag.p-tag-secondary { background: #6b7280; color: #ffffff; } /* come .p-tag-stato-grigio di gv-fe */
.p-tag.p-tag-help { background: #7c3aed; color: #ffffff; }      /* come .p-tag-cambio-anno di gv-fe */

.p-card { height: auto; }
.p-card.h-full { height: 100%; }

.p-datatable { position: relative; }
.p-datatable-wrapper { overflow-x: auto; }
.p-datatable-table { border-spacing: 0; width: 100%; }
.p-datatable .p-datatable-thead > tr > th { text-align: left; white-space: nowrap; }
.p-datatable.p-datatable-sm .p-datatable-tbody > tr > td { font-size: 0.9rem; vertical-align: middle; }
.p-datatable .p-datatable-tbody > tr.p-highlight > td { background: var(--highlight-bg); }
.p-datatable th.text-right, .p-datatable td.text-right { text-align: right; }
.p-datatable th.text-center, .p-datatable td.text-center { text-align: center; }

.p-fieldset { min-width: 0; }
.p-fieldset-legend > a { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: inherit; }
.p-fieldset-collapsed .p-fieldset-legend { margin-bottom: 0; }

.p-menubar { display: flex; align-items: center; }
.p-menubar-root-list { margin: 0; padding: 0; list-style: none; display: flex; align-items: center; flex-wrap: wrap; }
.p-menubar .p-menuitem-link { display: flex; align-items: center; text-decoration: none; cursor: pointer; }
.p-menubar-end { margin-left: auto; align-self: center; }

.p-sidebar { position: fixed; display: flex; flex-direction: column; }
.p-sidebar-header { display: flex; align-items: center; }
.p-sidebar-content { position: relative; overflow-y: auto; flex-grow: 1; }

.p-tabview-nav-container { position: relative; }
.p-tabview-nav-content { overflow-x: auto; scrollbar-width: thin; }
.p-tabview-nav { display: flex; margin: 0; padding: 0; list-style: none; flex: 1 1 auto; }
.p-tabview-nav li { white-space: nowrap; }
.p-tabview-nav-link { display: flex; align-items: center; cursor: pointer; text-decoration: none; position: relative; overflow: hidden; }

.p-inputswitch { position: relative; display: inline-block; flex: none; }
.p-inputswitch-slider { position: absolute; cursor: pointer; inset: 0; }
.p-inputswitch-slider:before { position: absolute; content: ""; top: 50%; }
button.nsp-switch { padding: 0; border: 0; background: transparent; cursor: pointer; }

.p-selectbutton .p-button { flex: 1 1 auto; justify-content: center; }
.nsp-selectbutton { display: flex; flex-wrap: wrap; }
.p-fluid .nsp-selectbutton .p-button, .nsp-selectbutton .p-button { width: auto; flex: 1 1 0; white-space: nowrap; }

.p-toast { position: fixed; width: 25rem; max-width: calc(100vw - 2rem); }
.p-toast-message-content { display: flex; align-items: flex-start; }
.p-toast-message-text { flex: 1 1 auto; }
.nsp-toast-host { top: 20px; right: 20px; z-index: 1500; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
.nsp-toast-host .p-toast-message { margin: 0; pointer-events: auto; }
.nsp-toast-in { animation: nsp-in .2s ease-out; }
.nsp-toast-out { opacity: 0; transform: translateY(-6px); transition: all .3s; }
@keyframes nsp-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.p-badge { display: inline-block; text-align: center; padding: 0 .5rem; border-radius: 10px; }

.nsp-select { appearance: auto; min-height: 2.5rem; cursor: pointer; }
.p-inputtextarea { resize: vertical; }

/* ======================================================= 2. da fatture-passive */
.assi { display: flex; flex-direction: column; gap: 0.4rem; }
.pillar {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--surface-border); border-left: 3px solid var(--surface-400);
  border-radius: var(--border-radius); background: var(--surface-card);
}
.pillar .pico {
  width: 1.6rem; height: 1.6rem; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-hover); color: var(--text-color-secondary);
}
.pillar .pmid { flex: 1; min-width: 0; }
.pillar .plabel { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; color: var(--text-color-secondary); }
.pillar .pvalue { font-size: 0.85rem; }
.pillar.state-done  { border-left-color: var(--green-500); }
.pillar.state-done .pico { color: var(--green-500); }
.pillar.state-warn  { border-left-color: var(--yellow-500); }
.pillar.state-warn .pico { color: var(--yellow-600, var(--yellow-500)); }
.pillar.state-info  { border-left-color: var(--blue-500); }
.pillar.state-info .pico { color: var(--blue-500); }
.pillar.state-todo  { border-left-color: var(--surface-400); }
.pillar.state-block { border-left-color: var(--orange-500); }
.pillar.state-block .pico { color: var(--orange-500); }

.code-kind {
  padding: 0.1rem 0.35rem; margin-right: .35rem; border-radius: var(--border-radius);
  background: var(--primary-50); color: var(--primary-700); font-size: 0.65rem; font-weight: 700;
}

.nsp-avviso { display: flex; gap: .6rem; align-items: flex-start; font-size: 0.9rem; border-radius: 6px; padding: 0.6rem 0.8rem; }
.nsp-avviso > .pi { margin-top: .15rem; }
.nsp-avviso-warn { color: var(--orange-800); background: var(--orange-50); }
.nsp-avviso-error { color: var(--red-700); background: var(--red-50); }
.nsp-avviso-info { color: var(--blue-800); background: var(--blue-50); }
.nsp-avviso-ok { color: var(--green-800); background: var(--green-50); }
.nsp-avviso a { color: inherit; font-weight: 700; }

/* ======================================================= 3. prototipo */
/* header (p-menubar di app-header) */
.nsp-menubar { gap: 1rem; padding: .5rem 1rem; border-radius: 0; border-width: 0 0 1px 0; position: sticky; top: 0; z-index: 900; }
.nsp-brand { line-height: 1.15; margin-right: .5rem; }
.invert-mini-logo { filter: invert(0.3); }
.p-menubar .p-menuitem-link.nsp-active { background: var(--highlight-bg); border-radius: var(--border-radius); }
.p-menubar .p-menuitem-link.nsp-active .p-menuitem-text,
.p-menubar .p-menuitem-link.nsp-active .p-menuitem-icon { color: var(--primary-700); font-weight: 600; }
.nsp-role { display: flex; flex-direction: column; gap: 2px; }
.nsp-role-label { font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--text-color-secondary); }
.nsp-role .nsp-select { min-height: 2.25rem; padding-top: .35rem; padding-bottom: .35rem; max-width: 15rem; }

/* contenitore pagina come layout gv-fe: surface-0 p-4 shadow-2 border-round */
.nsp-main {
  margin: 1rem; padding: 1.25rem; background: var(--surface-0);
  border-radius: var(--border-radius);
  box-shadow: 0 3px 5px rgba(0, 0, 0, .02), 0 0 2px rgba(0, 0, 0, .05), 0 1px 4px rgba(0, 0, 0, .08);
}

.stat-card .p-card-body { padding: 1rem; }
.stat-card .p-card-content { padding: 0; }
.stat-icon { font-size: 1.25rem; color: var(--primary-color); background: var(--primary-50); width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; flex: none; }

.nsp-avatar {
  width: 2rem; height: 2rem; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--primary-100); color: var(--primary-800); font-size: .75rem; font-weight: 700;
}

.riga-esclusa td { opacity: .55; text-decoration: line-through; }
.riga-esclusa td:first-child, .riga-esclusa td:last-child { text-decoration: none; }

.alert-ico { font-size: 1rem; }
.alert-warn { color: var(--orange-600); }
.alert-danger { color: var(--red-600); }
.alert-info { color: var(--blue-600); }
.alert-list { list-style: none; margin: .35rem 0 0; padding: 0; font-size: .8rem; display: flex; flex-direction: column; gap: .15rem; }
.alert-list li { display: flex; gap: .35rem; align-items: baseline; }
.alert-list li.alert-warn { color: var(--orange-800); }
.alert-list li.alert-danger { color: var(--red-700); }
.alert-list li.alert-info { color: var(--blue-800); }

.nsp-check { cursor: pointer; min-height: 2.5rem; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--primary-color); cursor: pointer; }

.nsp-storico { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.nsp-storico li { padding-left: .75rem; border-left: 2px solid var(--surface-border); }

.nsp-scroll-x { overflow-x: auto; }
.nsp-selall td { background: var(--surface-50) !important; padding: .15rem .5rem !important; }

/* sidebar */
.nsp-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1100; animation: p-fadein .15s; }
.nsp-sidebar {
  top: 0; right: 0; height: 100%; max-width: 100vw; z-index: 1101;
  background: var(--surface-overlay); box-shadow: 0 3px 6px rgba(0, 0, 0, .16), 0 3px 6px rgba(0, 0, 0, .23);
  animation: nsp-slide .2s ease-out;
}
.nsp-sidebar .p-sidebar-header { padding: .75rem 1rem; border-bottom: 1px solid var(--surface-border); }
.nsp-sidebar .p-sidebar-content { padding: 1rem; }
.nsp-sidebar .p-sidebar-footer { padding: .75rem 1rem; border-top: 1px solid var(--surface-border); }
@keyframes nsp-slide { from { transform: translateX(40px); opacity: .5; } to { transform: none; opacity: 1; } }

/* card mobile */
.nsp-mcard {
  display: block; padding: .85rem; border: 1px solid var(--surface-border); border-radius: 6px;
  background: var(--surface-card); color: inherit; text-decoration: none;
}
a.nsp-mcard:active { background: var(--surface-hover); }
.nsp-ticon { width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary-700); flex: none; }

/* nuova spesa */
.tipi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.tipo-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; min-height: 4.25rem;
  padding: .5rem .25rem; border: 1px solid var(--surface-border); border-radius: var(--border-radius); background: var(--surface-card);
  color: var(--text-color); font: inherit; font-size: .8rem; text-align: center; cursor: pointer; line-height: 1.15;
}
.tipo-btn .pi { font-size: 1.15rem; color: var(--primary-color); }
.tipo-btn:hover { background: var(--surface-hover); }
.tipo-btn:focus-visible { outline: 2px solid var(--primary-200); outline-offset: 1px; }
.tipo-btn.tipo-on { border-color: var(--primary-color); background: var(--highlight-bg); color: var(--primary-800); font-weight: 700; }

.dropzone { border: 2px dashed var(--surface-300); border-radius: 6px; padding: 1.5rem 1rem; text-align: center; background: var(--surface-50); }
.nsp-filebtn { cursor: pointer; position: relative; }
.anteprima-img { width: 100%; max-height: 28rem; object-fit: contain; border-radius: 6px; background: var(--surface-100); }
.scontrino {
  max-width: 17rem; margin: 0 auto; padding: 1rem 1.1rem; background: #fffdf7; color: #333;
  font-family: "Courier New", Courier, monospace; font-size: .8rem; line-height: 1.45;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15); border-radius: 2px;
}
.scontrino hr { border: 0; border-top: 1px dashed #999; margin: .5rem 0; }
.scontrino .ocr-hit { background: rgba(33, 150, 243, .14); outline: 1px solid rgba(33, 150, 243, .5); border-radius: 2px; }
.calc-box { padding: .75rem 1rem; border-radius: 6px; background: var(--surface-50); border: 1px solid var(--surface-border); }

/* budget */
.budget-row { padding: .4rem 0; border-bottom: 1px solid var(--surface-border); }
.budget-row:last-child { border-bottom: 0; }
.budget-bar { display: flex; height: .5rem; border-radius: 4px; background: var(--surface-200); overflow: hidden; margin: .35rem 0; }
.budget-prima { background: var(--surface-400); }
.budget-ok { background: var(--green-500); }
.budget-warn { background: var(--yellow-500); }
.budget-over { background: var(--red-500); }

/* report */
.bar-row { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr 6.5rem; gap: .75rem; align-items: center; padding: .25rem 0; font-size: .9rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: .75rem; background: var(--surface-100); border-radius: 3px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--primary-color); border-radius: 3px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }

/* workflow editor */
.wf-step { display: flex; gap: .75rem; align-items: center; padding: .75rem; border: 1px solid var(--surface-border); border-left: 3px solid var(--blue-500); border-radius: var(--border-radius); margin-bottom: .5rem; background: var(--surface-card); }
.wf-step.wf-off { border-left-color: var(--surface-400); opacity: .6; }
.wf-step .field { margin-bottom: 0; }
.wf-num { width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary-700); font-weight: 700; flex: none; }

.int-ico { width: 2.5rem; height: 2.5rem; border-radius: 6px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary-700); font-size: 1.2rem; flex: none; }

.nsp-tabview .p-tabview-nav { border-width: 0 0 2px 0; }

/* barra di navigazione mobile */
.nsp-bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 950; display: flex;
  background: var(--surface-card); border-top: 1px solid var(--surface-border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nsp-tab {
  flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 3.6rem; color: var(--text-color-secondary); text-decoration: none; font-size: .72rem;
}
.nsp-tab .pi { font-size: 1.2rem; }
.nsp-tab-on { color: var(--primary-color); font-weight: 700; }
.nsp-tab-primary { color: var(--primary-color-text); background: var(--primary-color); margin: .35rem; border-radius: 6px; min-height: 3rem; font-weight: 600; }
.nsp-tab-badge { position: absolute; top: .3rem; left: 55%; font-size: .65rem; min-width: 1.1rem; height: 1.1rem; line-height: 1.1rem; padding: 0 .3rem; }

/* ---------- pagina di benvenuto ---------- */
.welcome h1 { font-size: 2rem; line-height: 1.2; margin: .25rem 0 .75rem; color: var(--text-color); }
.welcome h2 { font-size: 1.25rem; margin: 0; color: var(--text-color); }
.welcome-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.welcome-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.5rem; align-items: center;
  padding: 1.5rem; border-radius: 6px; background: var(--primary-50); border: 1px solid var(--primary-100); }
.welcome-hero p { font-size: 1.05rem; line-height: 1.55; margin: 0; max-width: 42rem; }
.welcome-kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--primary-700); }
.welcome-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.welcome-list li { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; line-height: 1.4; }
.welcome-list .pi { color: var(--primary-color); margin-top: .15rem; }

.fasi { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.5rem; }
.fase { position: relative; display: flex; }
.fase:not(:last-child)::after {
  content: "\e91b" / ""; font-family: primeicons; position: absolute; right: -1.2rem; top: 1.4rem;
  color: var(--surface-500); font-size: .9rem;
}
.fase-card { display: flex; flex-direction: column; width: 100%; padding: .9rem; border: 1px solid var(--surface-border); border-radius: 6px;
  background: var(--surface-card); color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.fase-card:hover { border-color: var(--primary-color); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.fase-card:focus-visible { outline: 2px solid var(--primary-200); outline-offset: 2px; }
.fase-num { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--primary-color); color: var(--primary-color-text); font-weight: 700; font-size: .8rem; }
.fase-ico { font-size: 1.2rem; color: var(--primary-color); }
.fase-link { margin-top: auto; padding-top: .75rem; font-size: .85rem; color: var(--primary-700); font-weight: 600; }

.stati { display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap; }
.stato { flex: 1 1 0; min-width: 9rem; padding: .75rem; border: 1px solid var(--surface-border); border-radius: 6px; background: var(--surface-card); }
.stato-sep { align-self: center; color: var(--surface-500); }
.int-item { display: flex; gap: .75rem; align-items: flex-start; padding: .9rem; border: 1px solid var(--surface-border); border-radius: 6px; height: 100%; }
.tut-card .p-card-content { display: flex; flex-direction: column; }

@media (max-width: 1199px) {
  .fasi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fase:nth-child(3)::after { display: none; }
}

/* ---------- tutorial guidati ---------- */
#tour-host { display: none; }
#tour-host.tour-attivo { display: block; }
.tour-mask { position: fixed; inset: 0; z-index: 1400; background: transparent; }
.tour-centrato .tour-mask { background: rgba(0, 0, 0, .45); }
.tour-spot {
  position: fixed; z-index: 1401; border-radius: 6px; pointer-events: none;
  box-shadow: 0 0 0 3px var(--primary-color), 0 0 0 9999px rgba(0, 0, 0, .45);
  transition: top .2s, left .2s, width .2s, height .2s;
}
.tour-pop {
  position: fixed; z-index: 1402; padding: 1rem 1.1rem; border-radius: 6px; background: var(--surface-overlay);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25); color: var(--text-color); outline: none; max-height: calc(100vh - 24px); overflow-y: auto;
}
.tour-loading .tour-pop { opacity: .55; pointer-events: none; }
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: -.35rem -.5rem 0 0; }
.tour-kicker { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; color: var(--primary-700); }
.tour-x { width: 2.25rem !important; height: 2.25rem; }
.tour-progress { height: 4px; border-radius: 2px; background: var(--surface-200); overflow: hidden; margin: .35rem 0 .75rem; }
.tour-progress span { display: block; height: 100%; background: var(--primary-color); transition: width .2s; }
.tour-titolo { font-weight: 700; font-size: 1.1rem; margin-bottom: .4rem; }
.tour-testo { font-size: .92rem; line-height: 1.5; }
.tour-testo p { margin: 0 0 .5rem; }
.tour-testo ol, .tour-testo ul { margin: .25rem 0 .5rem; padding-left: 1.25rem; }
.tour-hint { margin-top: .6rem; padding: .45rem .6rem; border-radius: 6px; background: var(--primary-50); color: var(--primary-800); font-size: .82rem; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .9rem; }

@media (max-width: 767px) {
  .welcome h1 { font-size: 1.5rem; }
  .welcome-hero { grid-template-columns: 1fr; padding: 1rem; }
  .fasi { grid-template-columns: 1fr; gap: .75rem; }
  .fase::after { display: none; }
  .stati { flex-direction: column; }
  .stato { width: 100%; }
  .stato-sep { display: none; }
  .tour-pop { max-height: 55vh; }
}

@media (max-width: 767px) {
  .nsp-menubar { padding: .4rem .75rem; gap: .5rem; }
  .nsp-menubar img { height: 32px; }
  .nsp-role-label { display: none; }
  .nsp-role .nsp-select { max-width: 9.5rem; font-size: .85rem; }
  .nsp-main { margin: 0; padding: .75rem .75rem 5.5rem; box-shadow: none; border-radius: 0; }
  .nsp-toolbar { padding: .5rem; }
  .nsp-toolbar .p-button { padding: .5rem .75rem; }
  .tipi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nsp-sidebar { width: 100vw !important; }
  .nsp-sidebar .p-sidebar-content { padding: .75rem; }
  .bar-row { grid-template-columns: 6.5rem 1fr 5.5rem; gap: .5rem; font-size: .8rem; }
  .wf-step { flex-wrap: wrap; }
  .nsp-toast-host { left: 1rem; right: 1rem; top: auto; bottom: 4.5rem; width: auto; }
  .stat-card .text-2xl { font-size: 1.25rem !important; }
}
