/* =========================================================
   Portale Manutenzioni – stile
   Inchiostro petrolio (acqua trattata), carta fredda, segnali chiari.
   Tipografia: IBM Plex Sans per il testo, Plex Sans Condensed per titoli e numeri.
   ========================================================= */
@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Plex Cond"; src: url("vendor/fonts/plex-cond-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Cond"; src: url("vendor/fonts/plex-cond-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Cond"; src: url("vendor/fonts/plex-cond-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --inchiostro: #123a40;      /* barra laterale, titoli */
  --inchiostro-2: #1d4f57;
  --azione: #0f6b73;          /* pulsanti principali */
  --carta: #eef2f1;           /* sfondo */
  --pannello: #ffffff;
  --linea: #d3dddb;
  --testo: #1c2b2d;
  --tenue: #5d6f71;
  --ok: #2f8f5b;
  --attenzione: #c98a00;
  --allarme: #c2392b;
  --raggio: 12px;
  --raggio-s: 8px;

  --bs-body-font-family: "Plex", system-ui, sans-serif;
  --bs-body-color: var(--testo);
  --bs-body-bg: var(--carta);
  --bs-border-color: var(--linea);
  --bs-link-color: var(--azione);
  --bs-link-color-rgb: 15,107,115;
  --bs-link-hover-color: var(--inchiostro);
  --bs-success: var(--ok); --bs-success-rgb: 47,143,91;
  --bs-danger: var(--allarme); --bs-danger-rgb: 194,57,43;
  --bs-warning: #e0a100; --bs-warning-rgb: 224,161,0;
  --bs-primary: var(--azione); --bs-primary-rgb: 15,107,115;
  --bs-border-radius: var(--raggio-s);
  --bs-focus-ring-color: rgba(15,107,115,.3);
}
body { font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .titolo-cond { font-family: "Plex Cond", "Plex", sans-serif; letter-spacing: -.005em; color: var(--inchiostro); }
:focus-visible { outline: 3px solid rgba(15,107,115,.45); outline-offset: 2px; }
a { text-underline-offset: 2px; }

/* ---------- Pulsanti ---------- */
.btn { font-weight: 500; border-radius: var(--raggio-s); }
.btn-primary { --bs-btn-bg: var(--azione); --bs-btn-border-color: var(--azione); --bs-btn-hover-bg: var(--inchiostro); --bs-btn-hover-border-color: var(--inchiostro);
  --bs-btn-active-bg: var(--inchiostro); --bs-btn-disabled-bg: var(--azione); --bs-btn-disabled-border-color: var(--azione); }
.btn-outline-primary { --bs-btn-color: var(--azione); --bs-btn-border-color: var(--azione); --bs-btn-hover-bg: var(--azione); --bs-btn-hover-border-color: var(--azione); --bs-btn-active-bg: var(--azione); }
.btn-outline-secondary { --bs-btn-color: var(--testo); --bs-btn-border-color: var(--linea); --bs-btn-hover-bg: #e4ebea; --bs-btn-hover-color: var(--testo); --bs-btn-hover-border-color: #bfcccb; }
.btn-az { background: var(--az, var(--azione)); border-color: var(--az, var(--azione)); color: #fff; }
.btn-az:hover, .btn-az:focus { filter: brightness(.9); color: #fff; background: var(--az, var(--azione)); }
.btn-icona { font-size: 1.5rem; line-height: 1; padding: .25rem .5rem; color: var(--inchiostro); }

/* ---------- Struttura: barra laterale + contenuto ---------- */
.app { min-height: 100vh; }
.barra {
  --bs-offcanvas-width: 264px; --bs-offcanvas-bg: var(--inchiostro);
  background-color: var(--inchiostro) !important; color: #d7e6e4; display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .barra { position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 1030; }
  .app-corpo { margin-left: 248px; }
}
.barra-testa { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.1rem .9rem; }
.marchio { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-family: "Plex Cond"; font-weight: 600; font-size: 1.15rem; line-height: 1.1; }
.marchio svg { color: #7fd0c8; flex: none; }
.barra-menu { flex: 1; overflow-y: auto; padding: .25rem .6rem; }
.barra-gruppo { color: #8fb1ae; font-size: .8rem; margin: 1.1rem .65rem .35rem; }
.voce { display: flex; align-items: center; gap: .7rem; padding: .55rem .65rem; border-radius: var(--raggio-s); color: #d7e6e4; text-decoration: none; font-weight: 500; }
.voce i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: #8fb1ae; }
.voce:hover { background: rgba(255,255,255,.07); color: #fff; }
.voce.attiva { background: #f1f6f5; color: var(--inchiostro); }
.voce.attiva i { color: var(--azione); }
.voce-az i { color: var(--az) !important; font-size: .6rem; }
.voce-badge { margin-left: auto; background: var(--allarme); color: #fff; border-radius: 4px; font-size: .75rem; padding: 0 .4rem; font-weight: 600; }
.barra-piede { padding: .8rem; border-top: 1px solid rgba(255,255,255,.08); }
.offline-box { background: rgba(255,255,255,.05); border-radius: var(--raggio-s); padding: .65rem .7rem; margin-bottom: .7rem; font-size: .88rem; }
.btn-barra { background: rgba(255,255,255,.1); color: #fff; border: 0; }
.btn-barra:hover { background: rgba(255,255,255,.18); color: #fff; }
.stato-rete, .pallino-rete { width: .6rem; height: .6rem; border-radius: 50%; background: #5fd08f; display: inline-block; flex: none; }
.offline .stato-rete, .offline .pallino-rete { background: #f0a43a; }
.utente { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.utente-nome { color: #fff; text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utente-esci { color: #8fb1ae; font-size: 1.2rem; }
.utente-esci:hover { color: #fff; }

.barra-alta { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: rgba(238,242,241,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--linea); }
.marchio-mini { font-family: "Plex Cond"; font-weight: 600; color: var(--inchiostro); text-decoration: none; white-space: nowrap; }
.cerca { position: relative; flex: 1; max-width: 520px; }
.cerca i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--tenue); }
.cerca input { width: 100%; border: 1px solid var(--linea); background: #fff; border-radius: 999px; padding: .45rem .9rem .45rem 2.2rem; }
.cerca input:focus { outline: none; border-color: var(--azione); box-shadow: 0 0 0 3px rgba(15,107,115,.15); }
@media (max-width: 575px) { .cerca { display: none; } }
.pallino-rete { margin-left: auto; }
.contenuto { padding: 1.4rem 1.25rem 3rem; max-width: 1360px; }
@media (min-width: 1200px) { .contenuto { padding: 1.8rem 2.2rem 3rem; } }
.rete-avviso { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 2000; background: var(--inchiostro); color: #fff; padding: .6rem 1rem; border-radius: var(--raggio-s); box-shadow: 0 6px 24px rgba(18,58,64,.3); font-size: .92rem; max-width: 92vw; }

/* ---------- Titoli di pagina ---------- */
.titolo-pagina { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.titolo-pagina h1 { margin: 0; font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.titolo-pagina h1 .bi { font-size: 1.4rem; color: var(--azione); vertical-align: .1em; }
.breadcrumb { margin-bottom: .3rem; font-size: .88rem; color: var(--tenue); }
.breadcrumb a { color: var(--tenue); }
.sezione-titolo { font-size: .95rem; font-weight: 600; color: var(--tenue); margin-bottom: .6rem; }

/* ---------- Pannelli ---------- */
.card { border: 1px solid var(--linea); border-radius: var(--raggio); box-shadow: none !important; overflow: hidden; }
.card > .list-group:last-child > .list-group-item:last-child { border-bottom: 0; }
.card-header { background: #fff !important; border-bottom: 1px solid var(--linea); padding: .8rem 1rem; }
.card-header:first-child { border-radius: var(--raggio) var(--raggio) 0 0; }
.card-footer { background: #f7faf9 !important; border-top: 1px solid var(--linea); }
.card-az { border-left: 4px solid var(--az, var(--azione)); }
.testo-az { color: var(--az, var(--inchiostro)) !important; }
.pallino { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--az, var(--azione)); }
.list-group-item { border-color: var(--linea); }
.list-group-item-action:hover { background: #f5f9f8; }
.shadow, .shadow-sm { box-shadow: none !important; }

/* Contatori della home: una riga per azienda, numeri in condensato */
.contatori { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 0; border-top: 1px solid var(--linea); }
.contatore { padding: .8rem .9rem; text-decoration: none; color: var(--testo); border-right: 1px solid var(--linea); }
.contatore:last-child { border-right: 0; }
.contatore:hover { background: #f5f9f8; }
.contatore b { display: block; font-family: "Plex Cond"; font-size: 2rem; font-weight: 600; line-height: 1; }
.contatore span { font-size: .85rem; color: var(--tenue); }
.contatore.rosso b { color: var(--allarme); }
.contatore.giallo b { color: var(--attenzione); }
.contatore.zero b { color: #a9b8b7; }

/* ---------- Tabelle e moduli ---------- */
.table { --bs-table-border-color: var(--linea); }
.table thead th { font-weight: 600; font-size: .85rem; color: var(--tenue); background: #f7faf9 !important; border-bottom-width: 1px; }
.table td, .table th { vertical-align: middle; }
.form-label { font-weight: 500; font-size: .92rem; margin-bottom: .3rem; }
.form-control, .form-select { border-color: #c6d3d1; border-radius: var(--raggio-s); }
.form-control:focus, .form-select:focus { border-color: var(--azione); box-shadow: 0 0 0 3px rgba(15,107,115,.15); }
.form-check-input:checked { background-color: var(--azione); border-color: var(--azione); }
.badge { border-radius: 4px; font-weight: 600; letter-spacing: 0; }
.text-bg-warning { background-color: #f6d97a !important; color: #4a3600 !important; }
.nav-pills .nav-link { color: var(--testo); border-radius: var(--raggio-s); }
.nav-pills .nav-link.active { background: var(--inchiostro); color: #fff; }
.alert { border-radius: var(--raggio-s); }
.accordion-button:not(.collapsed) { background: #eef5f4; color: var(--inchiostro); box-shadow: none; }
.accordion-button:focus { box-shadow: 0 0 0 3px rgba(15,107,115,.15); }
.cerca-lista { max-width: 320px; }
a.num-rapp { text-decoration: none; }
.num-rapp { font-family: "Plex Cond"; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }

/* Firme */
.firma-box { border: 2px dashed #b4c4c2; border-radius: var(--raggio-s); background: #fff; position: relative; touch-action: none; }
.firma-box canvas { width: 100%; height: 190px; display: block; }
.firma-box .segnaposto { position: absolute; inset: 0; display: grid; place-items: center; color: #b4c4c2; pointer-events: none; font-size: .92rem; }

/* Rapportino: righe controlli */
.riga-ctrl.inclusa { background: #eef8f2; }
.riga-ctrl.non-regolare { background: #fcefed; }
.riga-ctrl .incluso { width: 1.4em; height: 1.4em; }
.foto-mini { width: 110px; height: 110px; object-fit: cover; border-radius: var(--raggio-s); border: 1px solid var(--linea); }
.barra-azioni { position: sticky; bottom: 0; z-index: 10; background: rgba(255,255,255,.96); backdrop-filter: blur(4px); border: 1px solid var(--linea); border-radius: var(--raggio); padding: .65rem; display: flex; gap: .5rem; }

/* Fattura */
.fattura-si { color: var(--ok); font-weight: 500; white-space: nowrap; }
.fattura-no { color: var(--tenue); white-space: nowrap; }

/* Calendario */
#calendario { background: #fff; padding: .75rem; border-radius: var(--raggio); border: 1px solid var(--linea); }
.fc { --fc-border-color: var(--linea); --fc-today-bg-color: #e6f2f0; --fc-button-bg-color: var(--inchiostro); --fc-button-border-color: var(--inchiostro);
  --fc-button-hover-bg-color: var(--azione); --fc-button-active-bg-color: var(--azione); --fc-button-active-border-color: var(--azione); }
.fc .fc-toolbar-title { font-family: "Plex Cond"; font-size: 1.4rem; text-transform: capitalize; color: var(--inchiostro); }
.fc a { text-decoration: none; color: inherit; }
.fc .fc-col-header-cell-cushion { text-transform: capitalize; font-weight: 500; }
.fc-event { cursor: pointer; }
.fc-event.eseguita { opacity: .55; }
.fc-event.eseguita .fc-event-title { text-decoration: line-through; }

/* ---------- Pagina di accesso ---------- */
.accesso { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--carta); }
@media (min-width: 992px) { .accesso { grid-template-columns: minmax(420px, 1.1fr) 1fr; } }
.accesso-lato { position: relative; overflow: hidden; background: var(--inchiostro); color: #d7e6e4; padding: 2rem; display: flex; flex-direction: column; justify-content: space-between; min-height: 220px; }
.accesso-lato .flussi { position: absolute; inset: 0; width: 100%; height: 100%; }
.accesso-lato > *:not(.flussi) { position: relative; }
.accesso-lato h1 { color: #fff; font-size: clamp(2rem, 3.2vw, 3rem); font-weight: 600; line-height: 1.05; max-width: 14ch; margin: 0; }
.accesso-aziende { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; font-size: .95rem; }
.accesso-aziende span { display: inline-flex; align-items: center; gap: .45rem; }
.accesso-aziende i { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; }
.accesso-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.accesso-form form { width: 100%; max-width: 380px; }
.accesso-form h2 { font-size: 1.7rem; font-weight: 600; margin-bottom: .25rem; }
.accesso-form .form-control { padding: .75rem .9rem; font-size: 1.05rem; }
.accesso-form .btn { padding: .75rem; font-size: 1.05rem; }
@media (max-width: 991px) { .accesso-lato h1 { font-size: 1.8rem; } .accesso-lato { padding: 1.5rem 1.25rem; } }
@media (prefers-reduced-motion: no-preference) {
  .flussi path { stroke-dasharray: 6 14; animation: scorre 18s linear infinite; }
  .flussi path:nth-child(2n) { animation-duration: 26s; }
}
@keyframes scorre { to { stroke-dashoffset: -400; } }

/* ---------- Stampa rapportino ---------- */
.foglio { background: #fff; max-width: 210mm; margin: 0 auto; padding: 12mm; border: 1px solid var(--linea); border-radius: 4px; }
.foglio h2 { font-family: "Plex", sans-serif; font-size: 1rem; font-weight: 600; color: var(--testo); padding: .3rem 0 .3rem .6rem; margin: 1.1rem 0 .5rem; border-left: 4px solid var(--az, var(--azione)); background: #f3f7f6; }
.foglio table { font-size: .85rem; }
.foglio .num-grande { font-family: "Plex Cond"; font-size: 1.6rem; font-weight: 600; color: var(--inchiostro); }
.firma-img { max-height: 90px; max-width: 100%; }

@media print {
  @page { size: A4; margin: 10mm; }
  body, .app { background: #fff !important; }
  .app-corpo { margin: 0 !important; }
  .contenuto { padding: 0 !important; max-width: none; }
  .foglio { border: 0; padding: 0; max-width: none; }
  .foglio h2 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { border: 1px solid #999; color: #000 !important; background: transparent !important; }
  a { text-decoration: none; color: inherit; }
  .tab-content > .tab-pane { display: block !important; opacity: 1 !important; }
}

/* ---------- Promemoria scadenze (all'apertura del portale) ---------- */
.promemoria { background: #fff8e1; border: 1px solid #f0d58a; border-left: 4px solid #e0a100; border-radius: var(--raggio); padding: .7rem .9rem; margin-bottom: 1.1rem; }
.promemoria-testa { color: #6b4d00; margin-bottom: .4rem; }
.promemoria-testa i { color: #e0a100; }
.promemoria-riga { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; padding: .35rem 0; border-top: 1px solid #f3e3b0; }
.promemoria-riga a { color: var(--testo); text-decoration: none; flex: 1 1 260px; }
.promemoria-riga a:hover { text-decoration: underline; }
.promemoria-quando { color: #6b4d00; font-size: .9rem; }
.promemoria-riga.oggi .promemoria-quando { color: var(--allarme); font-weight: 600; }

/* ---------- Faustino, operatore virtuale ---------- */
.faustino-pulsante { position: fixed; right: 18px; bottom: 18px; z-index: 1040; display: flex; align-items: center; gap: .6rem;
  border: 0; border-radius: 999px; padding: 4px 18px 4px 4px; background: var(--inchiostro); color: #fff; font-weight: 600;
  box-shadow: 0 8px 24px rgba(18,58,64,.28); }
.faustino-pulsante img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid #7fd0c8; background: #fff; }
.faustino-pulsante:hover { background: var(--inchiostro-2); }
@media (max-width: 575px) { .faustino-pulsante { padding: 4px; } .faustino-pulsante span { display: none; } }
.faustino-pannello { position: fixed; right: 18px; bottom: 18px; z-index: 1050; width: min(430px, calc(100vw - 24px)); height: min(680px, calc(100vh - 36px));
  display: flex; flex-direction: column; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 18px 50px rgba(18,58,64,.32); border: 1px solid var(--linea); }
.faustino-pannello[hidden] { display: none; }
@media (max-width: 575px) { .faustino-pannello { inset: 0; width: 100vw; height: 100dvh; border-radius: 0; } }
.faustino-testa { display: flex; align-items: center; gap: .65rem; padding: .7rem .8rem; background: var(--inchiostro); color: #fff; }
.faustino-testa img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid #7fd0c8; background: #fff; }
.faustino-testa small { display: block; color: #a9cdc9; font-size: .78rem; }
.faustino-messaggi { flex: 1; overflow-y: auto; padding: 1rem .9rem; background: var(--carta); display: flex; flex-direction: column; gap: .7rem; }
.f-msg { max-width: 92%; padding: .6rem .8rem; border-radius: 12px; line-height: 1.45; font-size: .95rem; overflow-wrap: anywhere; }
.f-msg.utente { align-self: flex-end; background: var(--azione); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.f-msg.faustino { align-self: flex-start; background: #fff; border: 1px solid var(--linea); border-bottom-left-radius: 4px; }
.f-msg.faustino p { margin: 0 0 .5rem; } .f-msg.faustino p:last-child { margin-bottom: 0; }
.f-msg.faustino ul, .f-msg.faustino ol { margin: .2rem 0 .5rem; padding-left: 1.2rem; }
.f-msg.faustino h4 { font-size: 1rem; margin: .4rem 0 .3rem; }
.f-msg.faustino code { background: #eef3f2; padding: 0 .25rem; border-radius: 4px; color: var(--inchiostro); }
.f-msg.faustino table { font-size: .85rem; border-collapse: collapse; margin: .3rem 0; }
.f-msg.faustino td, .f-msg.faustino th { border: 1px solid var(--linea); padding: .2rem .4rem; }
.f-voto { display: flex; gap: .3rem; margin-top: .4rem; align-items: center; }
.f-voto button { border: 0; background: transparent; color: var(--tenue); padding: 0 .2rem; font-size: .95rem; }
.f-voto button.scelto { color: var(--azione); }
.f-voto input { font-size: .82rem; padding: .2rem .4rem; border: 1px solid var(--linea); border-radius: 6px; flex: 1; }
.f-attesa { align-self: flex-start; color: var(--tenue); font-size: .9rem; display: flex; gap: .5rem; align-items: center; }
.f-attesa i { width: 8px; height: 8px; border-radius: 50%; background: var(--azione); display: inline-block; animation: f-pulse 1s infinite ease-in-out; }
.f-attesa i:nth-child(2) { animation-delay: .15s; } .f-attesa i:nth-child(3) { animation-delay: .3s; }
@keyframes f-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.f-benvenuto { display: flex; gap: .7rem; align-items: flex-start; }
.f-benvenuto img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.f-suggerimenti { display: flex; flex-wrap: wrap; gap: .4rem; }
.f-suggerimenti button { border: 1px solid var(--linea); background: #fff; border-radius: 999px; padding: .3rem .7rem; font-size: .85rem; color: var(--inchiostro); }
.f-suggerimenti button:hover { border-color: var(--azione); }
.faustino-scrivi { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--linea); background: #fff; }
.faustino-scrivi textarea { flex: 1; resize: none; border: 1px solid #c6d3d1; border-radius: 10px; padding: .5rem .7rem; max-height: 140px; font: inherit; }
.faustino-scrivi textarea:focus { outline: none; border-color: var(--azione); box-shadow: 0 0 0 3px rgba(15,107,115,.15); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
