:root {
  --colore-primario: #2563eb;
  --colore-sfondo: #0f172a;
  --colore-testo: #f8fafc;
  --colore-pannello: #1e293b;
  --raggio: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--colore-sfondo);
  color: var(--colore-testo);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 2rem;
  background: var(--colore-pannello);
  border-bottom: 2px solid var(--colore-primario);
  flex-wrap: wrap;
}

header h1 { margin: 0; font-size: 1.3rem; }

#nav-conto {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

#nome-utente { font-size: 0.9rem; color: #94a3b8; margin: 0 0.5rem; }

main { flex: 1; padding: 1.5rem; max-width: 1100px; margin: 0 auto; width: 100%; }

.pannello {
  background: var(--colore-pannello);
  border-radius: var(--raggio);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.nascosto { display: none !important; }

label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }

input[type="password"], input[type="text"], input[type="file"], select {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--colore-testo);
}

button {
  background: var(--colore-primario);
  color: white;
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  margin: 0.5rem 0.5rem 0.5rem 0;
}

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

button.secondario { background: #334155; }
button.pericolo { background: #b91c1c; }
button.primario { background: var(--colore-primario); }
button.grande { font-size: 1.1rem; padding: 0.9rem 2rem; }
button.piccolo { font-size: 0.8rem; padding: 0.35rem 0.7rem; }

.nav-tab { background: transparent; border: 1px solid #475569; padding: 0.45rem 0.9rem; margin: 0; }
.nav-tab.attivo { background: var(--colore-primario); border-color: var(--colore-primario); }

a { color: #93c5fd; }

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0f172a;
  border-radius: 6px;
}
code { padding: 0.1rem 0.35rem; }

pre {
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  border: 1px solid #334155;
}

.hint { font-size: 0.9rem; color: #94a3b8; }

.errore { color: #fca5a5; font-weight: 600; margin-top: 0.75rem; }

/* Hero della landing */
.hero { text-align: center; padding: 3rem 2rem; }
.hero h2 { font-size: 1.9rem; line-height: 1.3; margin-top: 0; }
.sottotitolo { font-size: 1.05rem; color: #cbd5e1; max-width: 720px; margin: 1rem auto 2rem; }

.punti-forza {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
  text-align: left;
}
.punto {
  background: #0f172a;
  border-radius: var(--raggio);
  padding: 1.2rem;
  border: 1px solid #334155;
}
.punto h3 { margin-top: 0; color: var(--colore-primario); }

.cta { margin: 2rem 0 1rem; }

.scheda-stretta { max-width: 460px; margin: 2rem auto; }

/* Galleria */
.griglia { display: flex; gap: 1.2rem; flex-wrap: wrap; }

.card-persona {
  border: 2px solid #475569;
  border-radius: var(--raggio);
  padding: 1rem;
  width: 250px;
  transition: border-color 0.2s;
}
.card-persona:hover { border-color: var(--colore-primario); }
.card-persona.personale { border-color: #0d9488; }
.card-persona img {
  width: 100%;
  border-radius: 8px;
  aspect-ratio: 1;
  object-fit: cover;
  background: #0f172a;
}
.card-persona h3 { margin: 0.6rem 0 0.2rem; }
.card-persona .ruolo { margin: 0.15rem 0; font-weight: 600; color: #cbd5e1; }
.card-persona .desc { font-size: 0.85rem; color: #94a3b8; min-height: 2.5em; }
.card-persona video { width: 100%; border-radius: 8px; background: #000; margin: 0.5rem 0; aspect-ratio: 1; object-fit: cover; }
.card-persona.mini { width: 160px; cursor: pointer; }
.card-persona.mini img { aspect-ratio: 1; }
.volto-attesa {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border-radius: 8px;
  color: #64748b;
  font-size: 0.85rem;
}

/* Sala di registrazione */
#sala-registrazione video {
  width: 100%;
  max-width: 640px;
  border-radius: var(--raggio);
  background: #000;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  margin: 1rem 0;
}

#timer-registrazione {
  font-size: 1.2rem;
  font-weight: 700;
  color: #f87171;
}

.stato-box {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  font-size: 0.95rem;
}
.stato-box.ok { border-color: #059669; color: #6ee7b7; }
.stato-box.errore { border-color: #b91c1c; color: #fca5a5; font-weight: 400; }
.stato-box.avviso { border-color: #d97706; color: #fcd34d; }

/* Conversa: il palcoscenico è una videochiamata — persona a tutto campo,
   webcam in miniatura nell'angolo, come nelle app di meeting. */
#palcoscenico {
  position: relative;
  margin-bottom: 1rem;
  border-radius: var(--raggio);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  max-height: 62vh;
}

#palcoscenico video#avatar-idle,
#palcoscenico video#avatar-risposta {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Fra uno spezzone e il successivo il video risposta si svuota per un
   istante: sfondo trasparente, così sotto si vede l'idle VIVO (mai nero). */
#palcoscenico video#avatar-risposta { background: transparent; }

#avatar-risposta {
  opacity: 0;
  transition: opacity 0.35s ease;
}

#avatar-risposta.visibile { opacity: 1; }

#webcam-box {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  width: 26%;
  max-width: 220px;
  aspect-ratio: 4/3;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: #0f172a;
}

#webcam-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#webcam-spenta {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.3;
}

#vu-meter {
  position: absolute;
  left: 0.8rem;
  bottom: 0.8rem;
  width: 120px;
  height: 8px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

#vu-meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--colore-primario);
  transition: width 0.08s linear;
}

#vu-meter.parole span { background: #22c55e; }

#sottotitoli {
  background: #0f172a;
  border-radius: var(--raggio);
  padding: 1rem;
  margin-bottom: 1rem;
  min-height: 4rem;
}

/* API */
#chiave-appena-creata {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.8rem 0;
  padding: 0.8rem;
  background: #0f172a;
  border: 1px solid #059669;
  border-radius: 8px;
  flex-wrap: wrap;
}
#chiave-valore { word-break: break-all; color: #6ee7b7; }

table { border-collapse: collapse; width: 100%; margin-top: 1rem; }
th, td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid #334155; font-size: 0.9rem; }
th { color: #94a3b8; }

.tab-esempi { margin-bottom: 0.8rem; }
.tab-esempio {
  background: transparent;
  border: 1px solid #475569;
  padding: 0.4rem 0.9rem;
  margin: 0 0.3rem 0.3rem 0;
}
.tab-esempio.attivo { background: var(--colore-primario); border-color: var(--colore-primario); }

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.tenant-nome { font-weight: 700; }

@media (max-width: 720px) {
  #webcam-box { width: 34%; }
  header { padding: 0.8rem 1rem; }
  main { padding: 1rem; }
}
