/* ==================================================
   RESET & BOX MODEL
   ================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Classe utility per testo visibile solo agli screen reader */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==================================================
   BASE LAYOUT
   ================================================== */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
}

/* ==================================================
   HEADER
   ================================================== */
#headerBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid #ddd;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: bold;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #e0e0e0;
  color: #333;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.95rem;
}

.divider {
  width: 1px;
  height: 22px;
  background: #cfcfcf;
}

/* ==================================================
   VIEWPORT PIANTINA
   ================================================== */
#svgContainer {
  width: 100%;
  height: calc(100vh - 180px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  margin: 0;
  touch-action: none;
  user-select: none;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

@media (min-width: 1024px) {
  #svgContainer {
    height: calc(100vh - 140px);
  }
}

#svgContainer svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
}

/* Quando compare la barra fissa "Prenota" (bottom:0), lascia spazio scrollabile
   in fondo alla mappa così le ultime file non restano coperte dal pulsante. */
body.ha-selezione #svgContainer {
  padding-bottom: 76px;
  scroll-padding-bottom: 76px;
}

/* ==================================================
   CONTROLLI ZOOM
   ================================================== */
#zoomControls.zoom-compact {
  display: flex;
  align-items: center;
  gap: 6px;
}

#zoomControls.zoom-compact button {
  background: #c8cbd0;
  border: none;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  /* reset della regola button{} globale non più necessario
     perché quella regola è stata rimossa */
}

#zoomControls.zoom-compact button:hover {
  background: #bbb;
}

/* ==================================================
   STATI POSTI (SVG)
   ================================================== */
.posto {
  fill: #dddddd;
  cursor: pointer;
}

.posto:hover {
  fill: #3ccc15;
}

/* I fill SVG hanno specificità bassa: !important necessario
   per battere gli attributi fill inline dell'SVG */
.posto.selected {
  fill: #007bff !important;
}

.posto.occupied {
  fill: #dc3545 !important;
  cursor: not-allowed;
  pointer-events: none;
}

.posto.bloccato {
  fill: #ff8888 !important;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.6;
}

/* 🟠 Posto con ordine pending di un altro utente (checkout in corso):
   colore arancione, non cliccabile ma con eventi (per il toast esplicativo) */
.posto.pending-payment {
  fill: #fd7e14 !important;
  cursor: not-allowed;
}
.posto.pending-payment:hover {
  fill: #e8700f !important;
}

/* ==================================================
   BOTTONI — regola base minimale
   ================================================== */

/* Regola base: solo le proprietà comuni a TUTTI i button.
   Ogni componente specifica le proprie dimensioni e colori. */
button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.2;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

/* Pulsante principale (prenota) */
.prenota-button {
  display: block;
  background-color: #007bff;
  color: #fff;
  font-size: 1.3rem;
  padding: 14px 32px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
  margin: 0 auto;
}

.prenota-button:hover:enabled {
  background-color: #0056b3;
}

.prenota-button:disabled {
  background-color: #bdbdbd;
  color: #f7f7f7;
}

/* ==================================================
   GRUPPI DI BOTTONI NELLE MODALI
   ================================================== */
.button-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 1rem;
}

.button-group button {
  flex: 1;
  background-color: #2e7d32;
  color: #fff;
  border: 1px solid #2e7d32;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.button-group button:hover:enabled {
  background-color: #256628;
  border-color: #256628;
}

/* Disabilitato grigio: prefisso .modal per battere la regola di tema iniettata
   ".modal button.continua{background:#2e7d32}" (specificità 0,2,1, che altrimenti
   pareggia e vince per ordine, colorando di verde anche il pulsante disattivo). */
.modal .button-group button:disabled {
  background-color: #d8cfc0;
  border-color: #d8cfc0;
  color: #fff;
}

/* Variante annulla */
.button-group button.annulla,
button.annulla {
  background-color: transparent;
  color: #1a1614;
  border: 1px solid #e6dfd2;
}

.button-group button.annulla:hover:enabled,
button.annulla:hover:enabled {
  background-color: #f7f3ec;
  border-color: #8a8275;
}

/* ==================================================
   MODALI
   ================================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 999;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  padding: 0;
  width: min(90vw, 480px);
  max-height: 92vh;
  overflow: hidden;
  flex-direction: column;
  font-family: "Helvetica Neue", sans-serif;
  animation: fadeIn 0.3s ease-out;
}

/* Modale completata: nascosta con classe .hidden (toglie hidden via JS) */
.modal.hidden {
  display: none !important;
}

/* ── Header modale con bordo inferiore ── */
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
  position: relative;
  flex-shrink: 0;
}

.modal-content {
  display: flex;
  flex-direction: column;
  position: relative;
  max-height: 92vh;
  overflow: hidden;
  padding: 0;
}

/* Titolo h2 dentro modal-content (senza modal-header) */
.modal-content > h2 {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
  color: #222;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

/* Intestazione dello spettacolo in cima alle finestrelle di prenotazione */
.modal-show-header {
  padding: 12px 24px 10px;
  background: #faf7f1;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.modal-show-header:empty { display: none; }
.modal-show-header .msh-titolo {
  font-size: 1.02rem;
  font-weight: 700;
  color: #2d2622;
  line-height: 1.25;
  text-transform: uppercase;
}
.modal-show-header .msh-data {
  font-size: 0.85rem;
  color: #777;
  margin-top: 2px;
}
.modal-show-header .msh-data .dm-rosso { color: var(--ev-gold, #b8901f); font-weight: 700; }

/* Numerino dei passaggi (1, 2, 3) nei titoli delle finestrelle */
.modal-content > h2 .step-num,
.modal h2 .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55em;
  height: 1.55em;
  border-radius: 8px;
  background: #2d2622;
  color: #fff;
  font-size: 0.78em;
  font-weight: 700;
  line-height: 1;
  margin-right: 9px;
  vertical-align: middle;
}

/* Titolo h2 dentro modal-header */
.modal-header h2,
.modal h2 {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
  color: #222;
}

/* Corpo scrollabile */
.modal-body {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 24px;
}

/* Form interno: scorre liberamente */
.modal-content form {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  padding: 20px 24px 0;
  min-height: 0;
}

/* Bottoni: sticky in fondo */
.modal-content .button-group {
  flex-shrink: 0;
  background: #fff;
  padding: 12px 24px 20px;
  border-top: 1px solid #eee;
  margin-top: 4px;
  gap: 10px;
}

/* Modale 1 (prenotatore): qui il gruppo pulsanti è DENTRO la <form> scrollabile
   (le modali 2/3 lo hanno già come footer fuori dallo scroll). Lo ancoriamo in
   fondo con position:sticky → il "Continua" è SEMPRE visibile; l'ombra superiore
   segnala che sopra ci sono altri campi da scorrere. */
.modal-content form .button-group {
  position: sticky;
  bottom: 0;
  box-shadow: 0 -12px 16px -10px rgba(0, 0, 0, 0.22);
}

/* Pulsante di chiusura (×) */
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid #ddd;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: bold;
  color: #777;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.modal-close:hover {
  background: #222;
  color: #fff;
  border-color: #222;
}

.modal-close:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* ── Etichetta step numero (es. "1️⃣") ── */
.modal h2 {
  padding-right: 36px; /* spazio per la X */
}

@media (min-width: 1024px) {
  .modal {
    width: min(75vw, 680px);
  }

  .modal-content > h2,
  .modal-header {
    padding: 24px 32px 18px;
  }

  .modal-content form {
    padding: 20px 32px 0;
  }

  .modal-content .button-group {
    padding: 14px 32px 24px;
  }

  .modal-body {
    padding: 20px 32px;
  }

  .modal-close {
    top: 20px;
    right: 24px;
  }
}

/* ==================================================
   FORM
   ================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.7rem;
}

.form-group label {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: #444;
}

/* Etichette dei campi (figlie dirette) come il titolo "PARTECIPANTI (2)" del
   riepilogo: maiuscoletto grigio spaziato. Solo le label dei campi, non i
   checkbox privacy (annidati in .privacy-row) né le intestazioni colonne.
   Prefisso .modal per battere la regola di tema iniettata da ui-layout.js
   (".modal label{color:var(--ev-ink-soft)}", stessa specificità ma iniettata dopo). */
.modal .form-group > label {
  font-size: 0.68rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 0.3rem;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: bold;
  font-family: inherit;
}

/* ==================================================
   VALIDAZIONE CAMPI
   ================================================== */
.field-error {
  margin-top: 4px;
  font-size: 0.85rem;
  color: #b91c1c;
  min-height: 1em;
}

.is-invalid {
  border-color: var(--ev-invalid, #ef4444) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.is-valid {
  border-color: var(--ev-valid, #22c55e) !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

/* ==================================================
   PRIVACY CHECKBOX
   ================================================== */
.privacy-row {
  margin-bottom: 16px;
}

.privacy-text {
  margin-bottom: 6px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #333;
}

.privacy-accept {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #222;
  cursor: pointer;
}

.privacy-accept input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #007bff;
  border-radius: 4px;
  display: inline-block;
  position: relative;
  cursor: pointer;
  background: #fff;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  margin: 0;
  flex-shrink: 0;
}

.privacy-accept input[type="checkbox"]:checked {
  background-color: #007bff;
  border-color: #007bff;
}

.privacy-accept input[type="checkbox"]:checked::after {
  content: "✔";
  color: #fff;
  font-size: 13px;
  position: absolute;
  top: -1px;
  left: 2px;
}

.privacy-accept input[type="checkbox"]:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Evidenziazione riga privacy quando manca il consenso */
.privacy-row {
  border: 2px solid transparent;   /* spazio riservato: evita il salto layout */
  border-radius: 8px;
  padding: 8px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.privacy-row.invalid {
  border-color: var(--ev-invalid, #ef4444);
  background-color: #fff5f5;
}

/* ==================================================
   RIEPILOGO
   ================================================== */
.riepilogo-info-spettacolo {
  margin-top: 4px;
}

.riepilogo-info-spettacolo h3 {
  font-weight: bold;
  color: #222;
  margin: 0 0 2px;
  font-size: 1.05rem;
}

.riepilogo-info-spettacolo p {
  color: #555;
  font-style: italic;
  margin: 0;
  font-size: 0.88rem;
}

.riepilogo-sezione {
  margin-bottom: 16px;
}

.riepilogo-label {
  font-size: 0.68rem;
  font-weight: bold;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 6px;
}

.riepilogo-prenotatore {
  font-size: 0.9rem;
  color: #333;
  line-height: 1.5;
}

.riepilogo-ospiti {
  background: #ffffff;
  border: 1px solid #e6dfd2;
  border-radius: 10px;
  padding: 0 14px;
}

/* Riga del riepilogo in stile "email": [posto] · nome · [tipo/prezzo] in orizzontale. */
.riepilogo-ospite {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #e6dfd2;
}

.riepilogo-ospite:last-child {
  border-bottom: none;
}

.riepilogo-ospite-nome {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1614;
}

.riepilogo-ospite-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1a1614;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.riepilogo-ospite-prezzo {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1rem;
  color: #1a1614;
  white-space: nowrap;
}


.riepilogo-totale-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 0 4px;
  border-top: 1px solid #eee;
  margin-top: 4px;
  gap: 12px;
}

.riepilogo-totale-label {
  font-size: 0.88rem;
  color: #555;
}

.riepilogo-totale-valore {
  font-size: 1.5rem;
  font-weight: bold;
  color: #111;
  white-space: nowrap;
}

.riepilogo-nota {
  font-size: 0.75rem;
  color: #999;
  margin-top: 3px;
}

/* ==================================================
   MODALE SPETTATORI — layout a due colonne
   ================================================== */

/* Riga intestazione colonne */
.spett-header-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 0 6px;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.spett-col-label {
  font-size: 0.8rem;
  font-weight: bold;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Riga singolo spettatore */
.spett-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}

.spett-index {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1a1614;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  margin-top: 4px;
  flex-shrink: 0;
}

.spett-field {
  display: flex;
  flex-direction: column;
}

.spett-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: bold;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.spett-field input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.15);
}

.spett-field .field-error {
  font-size: 0.75rem;
  min-height: 1em;
}

/* Con i tipi di prenotazione: layout "a scheda" su più righe (come la modale di
   riepilogo), così i campi non restano compressi su un'unica riga.
   Riga 1: numero · pill posto · tipo — Riga 2: Nome · Cognome affiancati.
   L'intestazione colonne è nascosta: i campi hanno già placeholder/label. */
.spett-header-row.has-tipo { display: none; }
/* Layout flex: riga 1 = posto (sinistra) + tipo (destra, larghezza naturale →
   i pulsanti restano sempre affiancati); riga 2 = Nome / Cognome uguali.
   Lo pseudo-elemento ::after (flex-basis 100%) forza l'a-capo tra le due righe. */
.spett-row.has-tipo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 8px;
  row-gap: 8px;
  border: 1px solid #e6dfd2;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.spett-row.has-tipo .zona-pill       { order: 1; align-self: center; }
.spett-row.has-tipo .spett-tipo-wrap { order: 2; margin-left: auto; align-self: center; }
.spett-row.has-tipo::after           { content: ""; order: 3; flex-basis: 100%; height: 0; }
.spett-row.has-tipo .spett-nome      { order: 4; flex: 1 1 0; min-width: 0; }
.spett-row.has-tipo .spett-cognome   { order: 5; flex: 1 1 0; min-width: 0; }
/* Il box "Codice sconto?" va IN FONDO, su riga propria (sotto Nome/Cognome).
   Senza order+basis finirebbe in cima (order 0 di default). */
.spett-row.has-tipo .spett-buono-wrap { order: 6; flex-basis: 100%; }
/* Il tipo (badge fisso o pulsanti) a larghezza naturale, allineato a destra. */
.spett-row.has-tipo .tp-badge,
.spett-row.has-tipo .spett-tipo-opts { width: auto; }
.spett-row.has-tipo .spett-tipo-opts { justify-content: flex-end; }

.spett-tipo-select {
  width: 100%;
  padding: 8px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: bold;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.spett-tipo-select:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.15);
}
.spett-tipo-select.is-invalid {
  border-color: #d33;
  box-shadow: 0 0 0 2px rgba(211,51,51,0.15);
}

/* Quando c'e un solo tipo: la tendina e nascosta e si mostra il prezzo fisso */
.spett-tipo-nascosto {
  display: none;
}
/* ── Badge TIPO/PREZZO a DUE righe (dicitura sopra, prezzo sotto) ─────────────
   Componente condiviso da: modale 2 (tipo unico), modale 3 (riepilogo) e la
   modale "Operazione riuscita". Stessa altezza del badge del posto (.zona-pill),
   così i due badge risultano allineati. Il beige/bordo è quello storico. */
.tp-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 44px;
  padding: 4px 13px;
  border: 1px solid #c9a86f;
  border-radius: 8px;
  background: #f7f3ec;
  color: #1a1614;
  line-height: 1.12;
  white-space: nowrap;
  flex-shrink: 0;
}
/* .tp-tipo / .tp-prezzo autonome: riusate dal badge (.tp-badge) e dai pulsanti
   di scelta tipo della modale 2 (.spett-tipo-opt), così hanno lo stesso aspetto. */
.tp-tipo {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.82;
}
.tp-prezzo {
  font-size: 0.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Scelta del tipo a PULSANTI (sostituisce il menù a tendina): il <select> resta
   nascosto come sorgente del valore, la UI sono questi bottoni. */
.spett-tipo-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
}
/* Pulsanti di scelta tipo: stesso aspetto a DUE righe del badge .tp-badge
   (dicitura sopra, prezzo sotto), ma selezionabili (bordo/hover/is-active). */
.spett-tipo-opt {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 44px;
  padding: 4px 13px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  color: #1a1614;
  line-height: 1.12;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.spett-tipo-opt:hover { border-color: #c9a86f; }
.spett-tipo-opt.is-active {
  background: #f7f3ec;
  border-color: #c9a86f;
  color: #1a1614;
  font-weight: 700;
}
.spett-tipo-opts.is-invalid .spett-tipo-opt {
  border-color: #d33;
  box-shadow: 0 0 0 2px rgba(211,51,51,0.10);
}

/* Badge del POSTO: rettangolo con angoli e altezza FISSI, colore per zona.
   Stesso identico stile in tutte le situazioni (modale 2/3, "Operazione riuscita",
   e — replicato inline — nell'email). Altezza 44px = altezza del badge tipo/prezzo. */
.zona-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 44px;
  padding: 0 15px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: #1a1614;
  white-space: nowrap;
  flex-shrink: 0;
}
.zona-pill.zc0 { background: #6b2c39; }
.zona-pill.zc1 { background: #1a1614; }
.zona-pill.zc2 { background: #8a5520; }
.zona-pill.zc3 { background: #3a5a6b; }
.zona-pill.zc4 { background: #5a4a6b; }
.zona-pill.zc5 { background: #6b5a2c; }
.spett-row.has-tipo .zona-pill { grid-area: zona; align-self: center; justify-self: start; margin-top: 0; }

/* Totale in fondo alla schermata partecipanti */
.spett-totale-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 10px;
  border-top: 1px solid #eee;
  margin-top: 12px;
  padding-top: 12px;
}
.spett-totale-label {
  color: #888;
  font-size: 0.9rem;
}
.spett-totale-valore {
  font-weight: 700;
  font-size: 1.25rem;
}

/* Il tipo/prezzo del riepilogo usa ora il componente condiviso .tp-badge
   (due righe), vedi sopra. */

@media (max-width: 600px) {
  .spett-header-row,
  .spett-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  /* Su mobile resta il layout flex (posto + tipo in alto, Nome/Cognome sotto):
     riduco solo lo spazio verticale. Il flex-wrap gestisce da solo il caso in
     cui il tipo non stia accanto al posto su schermi molto stretti. */
  .spett-header-row.has-tipo { display: none; }
  .spett-row.has-tipo { row-gap: 6px; }
}
#intestazioneSpettacolo .cal-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

#intestazioneSpettacolo .cal-icon {
  width: 48px;
  height: 48px;
  display: inline-block;
  vertical-align: middle;
}

#intestazioneSpettacolo .ora-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #efefef;
  font-size: 14px;
  line-height: 1.2;
  color: #333;
  vertical-align: middle;
}

/* ==================================================
   BARRA PRENOTAZIONE (fissa in basso)
   ================================================== */
#infoPrenotazione {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  z-index: 1000;
}

/* ==================================================
   OVERLAY CODA (blocca visivamente gli utenti in attesa)
   ================================================== */
#overlayBloccaCoda {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(200, 200, 200, 0.85);
  justify-content: center;
  align-items: center;
  text-align: center;
}

#overlayBloccaCoda h2 {
  color: #444;
}

#overlayBloccaCoda p {
  font-size: 18px;
}

/* ==================================================
   OVERLAY INTERAZIONI (sfondo scuro sotto le modali)
   ================================================== */
#overlayBloccaInterazioni {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 800;
}

/* ==================================================
   BARRA DI AVANZAMENTO
   ================================================== */
/* Overlay scuro dedicato alla barra attesa */
#barraAttesaOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
}
#barraAttesaOverlay.attivo { display: block; }

#barraAttesa {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 460px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  font-family: "Helvetica Neue", sans-serif;
  animation: fadeIn 0.3s ease-out;
}
#barraAttesa.attiva { display: block; }

/* Header barra con bordo inferiore */
#barraAttesaHeader {
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
  text-align: center;
}

#barraMessaggio {
  font-size: 1rem;
  font-weight: bold;
  color: #1a1614;
  line-height: 1.4;
  margin: 0;
  text-align: center;
}

/* Corpo con progress bar */
#barraAttesaBody {
  padding: 20px 24px 24px;
}

.barra-track {
  width: 100%;
  background-color: #e6dfd2;
  border-radius: 8px;
  overflow: hidden;
}

#barraInterna {
  width: 0%;
  height: 16px;
  background-color: #4a7c3a;
  border-radius: 8px;
  transition: width 1s ease-in-out;
}

/* ==================================================
   TOAST (notifiche centrate) — stile modale
   ================================================== */
.toast-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  width: min(90vw, 520px);
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: none;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(26, 22, 20, 0.22);
  font-family: 'Manrope', system-ui, sans-serif;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.97);
  /* posizionamento assoluto come le modali */
  position: fixed;
  left: 50%;
  top: 50%;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast.hide {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.97);
}

/* Header del toast: fascia colorata con icona + titolo (come home.html) */
.toast-header {
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  text-align: center;
}
.toast-header .toast-ico { display: inline-flex; }

/* Variante con grafica in testa (es. fuochi d'artificio nell'"Operazione riuscita"):
   la fascia diventa una colonna — grafica grande e centrata, poi icona + titolo. */
.toast-header.has-graphic {
  flex-direction: column;
  gap: 8px;
  padding-top: 20px;
}
.toast-graphic { display: flex; justify-content: center; }
.toast-graphic svg { width: 140px; height: 140px; color: #fff; opacity: 0.96; }
.toast-header.has-graphic .toast-header-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

/* Corpo del toast */
.toast-body {
  background: #fff;
  padding: 16px 20px;
  font-size: 0.95rem;
  color: #2d2622;
  line-height: 1.5;
  text-align: center;
}

.toast-body a {
  color: #8a5520;
  text-decoration: underline;
}

/* Bottone Chiudi — compatto e centrato, come home.html */
.toast-footer {
  background: #fff;
  padding: 0 20px 16px;
  display: flex;
  justify-content: center;
}

.toast button {
  padding: 9px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  background-color: transparent;
  color: #1a1614;
  border: 1px solid #e6dfd2;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.toast button:hover { background-color: #f7f3ec; border-color: #8a8275; }

/* Colore della fascia in base al tipo */
.toast.is-success .toast-header { background: #4a7c3a; }
.toast.is-error   .toast-header { background: #b14a3a; }
.toast.is-warning .toast-header { background: #b8732a; }
.toast.is-info    .toast-header { background: #2d2622; }

/* Sezione PDF links */
.toast-pdf-section {
  padding: 12px 0 4px;
  border-top: 1px solid #e6dfd2;
  margin-top: 10px;
}

.toast-pdf-title {
  font-size: 0.85rem;
  font-weight: bold;
  color: #8a8275;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}

.toast-pdf-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Riga prenotazione in "Operazione riuscita": stessa impaginazione dell'email
   (icona biglietto · posto · nome · tipo/prezzo), cliccabile con hover leggero. */
.toast-pdf-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 8px;
  border-bottom: 1px solid #e6dfd2;
  color: #1a1614 !important;
  border-radius: 8px;
  text-decoration: none !important;
  transition: background-color 0.12s ease;
}

.toast-pdf-link:last-child { border-bottom: none; }
.toast-pdf-link:hover { background: #f7f3ec; }

.toast-pdf-nome {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  text-align: left;
}

/* Icona biglietto (stessa del backend, in ambra): segnala il link al biglietto. */
.tico {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #b0741f;
}

.toast-pdf-nota {
  font-size: 0.75rem;
  color: #888;
  margin-top: 8px;
  line-height: 1.4;
}

/* Overlay di sfondo per i toast */
.toast-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 22, 20, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 99998;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.toast-overlay.show { opacity: 1; }
.toast-overlay.hide { opacity: 0; }

/* ==================================================
   RECUPERO PDF (input email in header)
   ================================================== */
.pdf-recover {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e6dfd2;
  border-radius: 10px;
  padding: 3px 6px;
}

.pdf-recover input {
  width: 220px;
  max-width: 34vw;
  border: none;
  outline: none;
  font-size: 0.92rem;
  padding: 6px 8px;
  font-family: inherit;
}

.pdf-recover button {
  margin: 0;
  padding: 6px 10px;
  font-size: 0.95rem;
  color: #fff;
  background: #1a1614;
  border-radius: 8px;
}

.pdf-recover button:hover {
  background: #2d2622;
}

/* ==================================================
   MODALE RECUPERO PDF (lista prenotazioni)
   ================================================== */
.pdf-access-hint {
  margin: 10px 0 0;
  font-size: 0.92rem;
  line-height: 1.35;
  color: #8a8275;
}

.pdf-access-welcome {
  margin: 6px 0 10px;
  font-size: 0.95rem;
  color: #2d2622;
}

.pdf-access-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 0 6px;
}

.pdf-access-card {
  border: 1px solid #e6dfd2;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f7f3ec;
}

.pdf-access-card h4 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: #1a1614;
}

.pdf-access-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

a.pdf-access-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  background: #fff;
  border: 1px solid #e6dfd2;
  border-radius: 10px;
  padding: 10px 12px;
  color: #1a1614;
}

a.pdf-access-link:hover {
  border-color: #8a8275;
  background: #f7f3ec;
}

.pdf-access-link .meta {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: #2d2622;
}

/* Pillola posto colorata per zona (stesso stile dell'elenco prenotazioni in home) */
.pa-seat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 3px 9px;
  border-radius: 6px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
  background: #1a1614;
}
.pa-seat.z0 { background: #6b2c39; }
.pa-seat.z1 { background: #1a1614; }
.pa-seat.z2 { background: #8a5520; }
.pa-seat.z3 { background: #3a5a6b; }
.pa-seat.z4 { background: #5a4a6b; }
.pa-seat.z5 { background: #6b5a2c; }
.pa-nome {
  color: #2d2622;
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pa-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #8a8275;
  flex-shrink: 0;
}

.pdf-access-link .icon {
  color: #b8732a;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.pdf-access-link .icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Intestazione spettacolo nella lista biglietti personali */
.pdf-access-show-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e6dfd2;
}

.pdf-access-show-header h4 {
  margin: 0;
  font-size: 1rem;
  color: #1a1614;
  font-weight: 700;
}

.pdf-access-show-date {
  font-size: 0.82rem;
  color: #8a8275;
  font-weight: 400;
}

/* Biglietto senza PDF ancora disponibile */
.pdf-access-no-pdf {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

/* ── Accordion biglietti per spettacolo ── */
.pdf-accordion-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  text-align: left;
}
.pdf-accordion-trigger:hover .pdf-accordion-title {
  text-decoration: underline;
}
.pdf-accordion-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.pdf-accordion-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1614;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-accordion-date {
  font-size: 0.82rem;
  color: #8a8275;
}
.pdf-accordion-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pdf-accordion-count {
  font-size: 0.78rem;
  color: #8a8275;
  white-space: nowrap;
}
.pdf-accordion-arrow {
  font-size: 0.7rem;
  color: #8a8275;
}
.pdf-accordion-body {
  margin-top: 10px;
}

/* ==================================================
   POPUP ISTRUZIONI (PNG scorrevoli)
   ================================================== */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 16px;
}

/* La modale ABBRACCIA l'immagine (niente più box fisso enorme con l'immagine
   persa al centro): così i controlli possono ancorarsi ai bordi dell'IMMAGINE.
   overflow visibile → frecce/X possono stare "a cavallo" del bordo. */
.tutorial-modal {
  position: relative;
  max-width: min(980px, 96vw);
  background: transparent;
  border-radius: 16px;
  overflow: visible;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

/* X — DENTRO l'immagine, in alto a destra */
.tutorial-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  z-index: 3;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tutorial-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.tutorial-close:focus-visible,
.tutorial-arrow:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 3px;
}

/* Lo stage ABBRACCIA l'immagine: è il contesto di posizionamento per X e frecce,
   così questi si ancorano ai bordi REALI dell'immagine. */
.tutorial-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  /* lascia sempre ~75px per lato: le frecce stanno FUORI dall'immagine */
  max-width: min(880px, calc(100vw - 150px));
}

.tutorial-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(880px, calc(100vw - 150px));
  max-height: min(78vh, 620px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 12px;
}

/* Frecce — a cavallo dei bordi SINISTRO / DESTRO dell'immagine */
.tutorial-arrow {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  z-index: 3;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.tutorial-arrow:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Frecce FUORI dall'immagine (interamente oltre i bordi, con un piccolo stacco) */
.tutorial-arrow--prev { left: 0;  transform: translate(calc(-100% - 12px), -50%); }
.tutorial-arrow--next { right: 0; transform: translate(calc(100% + 12px), -50%); }

/* Pallini — subito SOTTO l'immagine, nel flusso della colonna della modale */
.tutorial-dots {
  position: static;
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 2;
  pointer-events: none;
}

.tutorial-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.tutorial-dot.is-active {
  background: rgba(255, 255, 255, 0.95);
}

/* ==================================================
   ANIMAZIONE FADE-IN MODALI
   ================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ==================================================
   RESPONSIVE — MOBILE (≤ 600px)
   ================================================== */
@media (max-width: 600px) {
  #headerBar {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  #intestazioneSpettacolo,
  .header-title {
    width: 100%;
    justify-content: center;
    font-size: 1.4rem;
  }

  #headerBar .toolbar {
    display: inline-flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 auto;
  }

  .toolbar > * {
    display: flex;
    align-items: center;
  }

  .divider {
    display: inline-block;
    align-self: center;
    width: 1px;
    height: 24px;
    background: #cfcfcf;
  }

  .badge {
    font-size: 0.9rem;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
  }

  #zoomControls.zoom-compact button {
    padding: 4px 8px;
    font-size: 14px;
  }

  #svgContainer {
    height: calc(100vh - 260px);
  }

  .modal {
    width: 92vw;
    padding: 0;                 /* gestito da modal-content */
    border-radius: 14px;
    max-height: 90vh;
    z-index: 1100;              /* sopra #infoPrenotazione (z-index: 1000) */
  }

  .modal-content {
    padding: 1.25rem;
    max-height: 90vh;
  }

  .pdf-recover {
    width: 100%;
    justify-content: center;
  }

  .pdf-recover input {
    width: min(320px, 70vw);
    max-width: 70vw;
  }

  .tutorial-img {
    max-height: min(72vh, 560px);
  }
  .tutorial-arrow { width: 38px; height: 38px; font-size: 24px; }
  .tutorial-close { width: 36px; height: 36px; font-size: 22px; }

}

/* ── Riga biglietto con pulsante condivisione ── */
.pdf-access-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-access-row .pdf-access-link {
  flex: 1;
  min-width: 0;
}

.pdf-share-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid #e6dfd2;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 1rem;
  color: #8a8275;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}

.pdf-share-btn:hover {
  background: #f7f3ec;
  border-color: #8a8275;
}

/* ==================================================
   CODICE SCONTO — tab con icona regalo (collassabile)
   Collassato: si vede solo l'icona del regalo (+ testo breve).
   Cliccando si apre il pannello con input + Applica.
   ================================================== */
.buono-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px dashed #c9b892;
  border-radius: 8px;
  background: #faf7f0;
  color: #6b4a2c;
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.buono-toggle:hover { background: #f3ecdd; border-color: #b89b6a; }
.buono-toggle svg { width: 18px; height: 18px; flex: 0 0 auto; }
.buono-toggle[aria-expanded="true"] { border-style: solid; background: #f3ecdd; }
.buono-panel { margin-top: 8px; }
.buono-panel[hidden] { display: none; }

/* Variante piccola per il codice PER-POSTO nella modale partecipanti */
.buono-toggle-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.buono-toggle-sm svg { width: 15px; height: 15px; }

/* Codice PER-POSTO: dentro il box prenotazione, su tutta la larghezza. Toggle e
   input+Applica sulla STESSA riga (il pannello si apre in orizzontale, non sotto). */
.spett-row .spett-buono-wrap { grid-column: 1 / -1; margin-top: 2px; }
.buono-inline { display: none; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 140px; }
.buono-inline.is-open { display: flex; }