/* ═══════════ Assistente Crea — tema scuro (come l'app desktop) ═══════════ */
:root {
  --bg-app:     #0a0a16;
  --bg-topbar:  #08080f;
  --bg-panel:   #12122a;
  --bg-panel-2: #141428;
  --bg-input:   #1a1a34;
  --bordo:      #26264a;
  --testo:      #e8e8f2;
  --testo-dim:  #8a8aa8;
  --accent:     #4f7cff;
  --verde:      #22c55e;
  --verde-scuro:#1a4a2a;
  --rosso:      #ef4444;
  --giallo:     #eab308;
  --blu-badge:  #5070a0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-app);
  color: var(--testo);
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
}
.nascosto { display: none !important; }

/* ── viste ── */
body[data-view="caricamento"] section { display: none; }
body[data-view="login"]  #view-primo, body[data-view="login"]  #view-app   { display: none; }
body[data-view="primo"]  #view-login, body[data-view="primo"]  #view-app   { display: none; }
body[data-view="app"]    #view-login, body[data-view="app"]    #view-primo { display: none; }

.schermo-centrato {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

/* ── card / form ── */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--bordo);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-card { width: 420px; max-width: 100%; text-align: center; }
.logo-login { height: 84px; margin-bottom: 14px; }
.login-card h1 { font-size: 22px; margin-bottom: 2px; }
.sottotitolo { color: var(--testo-dim); margin-bottom: 22px; }
form { text-align: left; }
label { display: block; font-size: 12px; color: var(--testo-dim); margin-bottom: 12px; }
input, textarea, select {
  width: 100%; margin-top: 4px;
  background: var(--bg-input); color: var(--testo);
  border: 1px solid var(--bordo); border-radius: 8px;
  padding: 9px 12px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); }
.riga-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nota { color: var(--testo-dim); font-size: 12px; }
.errore {
  background: #3a1220; border: 1px solid #7f1d1d; color: #fca5a5;
  border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 13px;
}

/* ── bottoni ── */
.btn {
  border: 1px solid var(--bordo); border-radius: 8px;
  background: var(--bg-panel-2); color: var(--testo);
  padding: 9px 18px; font: inherit; cursor: pointer;
}
.btn:hover { filter: brightness(1.25); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-verde    { background: var(--verde-scuro); border-color: #1e5a32; color: #86efac; }
.btn-rosso    { background: #3a1220; border-color: #7f1d1d; color: #fca5a5; }
.btn-secondario { background: transparent; }
.btn-largo   { width: 100%; margin-top: 6px; }
.btn-piccolo { padding: 6px 12px; font-size: 13px; }

/* ── topbar ── */
.topbar {
  height: 52px; background: var(--bg-topbar);
  border-bottom: 1px solid var(--bordo);
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-sx { display: flex; align-items: center; gap: 10px; }
.logo-topbar { height: 34px; }
.titolo-app { font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tab {
  background: transparent; border: none; color: var(--testo-dim);
  padding: 8px 16px; border-radius: 8px; font: inherit; cursor: pointer;
}
.tab:hover { color: var(--testo); background: var(--bg-panel-2); }
.tab.attivo { color: var(--testo); background: var(--bg-panel-2); font-weight: 600; }
.topbar-dx { display: flex; align-items: center; gap: 10px; }
.badge-utente {
  background: var(--bg-panel-2); color: var(--blu-badge);
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 600;
}

/* ── pannelli tab ── */
.tab-pannello { display: none; max-width: 1200px; margin: 0 auto; padding: 18px 16px 30px; }
.tab-pannello.attivo { display: block; }

/* Vista assistente: chat + FAQ/Manuali/Runbook affiancati (come il desktop) */
#tab-chat.attivo {
  display: flex; flex-direction: row; gap: 10px;
  max-width: none; height: calc(100vh - 52px);
  padding: 12px 12px 14px;
}
.chat-colonna { flex: 1; min-width: 380px; display: flex; flex-direction: column; }

.pannello-laterale {
  width: 262px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-panel); border: 1px solid var(--bordo);
  border-radius: 12px; padding: 10px; overflow: hidden;
}
.lat-testata {
  font-weight: 700; font-size: 13px; padding: 2px 4px 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.lat-conteggio { color: var(--blu-badge); font-size: 11.5px; }
.lat-cerca { margin: 0 0 8px; padding: 6px 10px; font-size: 12.5px; }
.lat-lista { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.lat-voce { border: 1px solid transparent; border-radius: 8px; }
.lat-domanda {
  padding: 6px 8px; font-size: 12px; cursor: pointer; border-radius: 8px;
  color: #c8c8dc;
}
.lat-domanda:hover { background: var(--bg-panel-2); color: var(--testo); }
.lat-risposta {
  padding: 4px 8px 8px; font-size: 11.5px; color: var(--testo-dim);
  white-space: pre-wrap; border-left: 2px solid var(--bordo); margin: 0 0 4px 8px;
}

.badge-mini {
  background: var(--bg-panel-2); color: var(--blu-badge);
  padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700;
  white-space: nowrap;
}

/* ── console FAQ: azioni, allegati, revisione, script ── */
.lat-strumenti { display: flex; align-items: center; gap: 8px; }
.btn-mini {
  background: var(--bg-panel-2); border: 1px solid var(--bordo);
  color: var(--testo-dim); border-radius: 6px; padding: 2px 8px;
  font-size: 12px; cursor: pointer;
}
.btn-mini:hover { color: var(--testo); filter: brightness(1.3); }
.voce-azioni { display: flex; gap: 5px; flex-wrap: wrap; padding: 6px 8px 8px; }
.voce-azioni .btn-mini { font-size: 11.5px; }
.all-griglia { display: flex; flex-direction: column; gap: 8px; }
.all-riga {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-panel-2); border: 1px solid var(--bordo);
  border-radius: 8px; padding: 8px 10px;
}
.all-thumb { max-width: 220px; max-height: 130px; border-radius: 6px; display: block; }
.tag-errore { background: #3a2410; color: #fdba74; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.tag-soluzione { background: #12321f; color: #86efac; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.rev-vecchio {
  background: #241318; border: 1px solid #4a2030; border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: #c0a0a8; white-space: pre-wrap;
  max-height: 110px; overflow-y: auto; margin: 4px 0 6px;
}
.script-editor {
  width: 100%; min-height: 320px; font-family: Consolas, monospace;
  font-size: 12.5px; white-space: pre; overflow-x: auto;
}
.file-richiesto {
  background: var(--bg-panel-2); border: 1px solid var(--bordo);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; margin-bottom: 6px;
}
.modale-card.larga { width: 860px; }

/* ── chat ── */
.chat-messaggi { flex: 1; overflow-y: auto; padding: 8px 4px; }
.msg { max-width: 78%; margin-bottom: 12px; }
.msg-tu { margin-left: auto; }
.msg-corpo {
  padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word;
  background: var(--bg-panel); border: 1px solid var(--bordo);
}
.msg-tu .msg-corpo { background: #1c2c54; border-color: #2c3c6a; }
.msg-errore .msg-corpo { background: #3a1220; border-color: #7f1d1d; color: #fca5a5; }
.msg-fonti { margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--bg-panel-2); color: var(--blu-badge);
  border-radius: 6px; padding: 3px 9px; font-size: 11.5px; font-weight: 600;
}
.msg-corpo code { background: #00000055; border-radius: 4px; padding: 1px 5px; font-size: 13px; }
.msg-corpo pre { background: #00000055; border-radius: 8px; padding: 10px; overflow-x: auto; margin: 6px 0; }
.msg-corpo h1, .msg-corpo h2, .msg-corpo h3 { margin: 8px 0 4px; font-size: 15px; }
.msg-corpo ul, .msg-corpo ol { margin: 4px 0 4px 20px; }
/* ── colonna COLLEGHI (a comparsa dal pulsante 👥) ── */
.pannello-colleghi {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-panel); border: 1px solid var(--bordo);
  border-radius: 12px; padding: 10px; overflow: hidden;
}
.pannello-colleghi.nuovo-messaggio {
  border-color: var(--accent);
  animation: pulsa-colonna 1.4s ease-in-out infinite;
}
@keyframes pulsa-colonna {
  0%, 100% { box-shadow: 0 0 0 2px rgba(79,124,255,.35), 0 0 22px rgba(79,124,255,.30); }
  50%      { box-shadow: 0 0 0 2px rgba(79,124,255,.65), 0 0 30px rgba(79,124,255,.55); }
}
.col-testata {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 4px 8px; font-weight: 700; font-size: 13px;
}
.mio-stato {
  display: flex; align-items: center; gap: 6px; background: var(--bg-input);
  border: 1px solid var(--bordo); border-radius: 8px; padding: 5px 8px;
  font-size: 11.5px; margin-bottom: 8px; cursor: pointer;
}
.mio-stato select {
  background: transparent; border: none; color: var(--testo);
  font-size: 11.5px; width: auto; margin: 0; padding: 0; cursor: pointer;
}
.utenti {
  display: flex; flex-direction: column; gap: 2px; max-height: 238px;
  overflow-y: auto; border-bottom: 1px solid var(--bordo);
  padding-bottom: 8px; margin-bottom: 8px;
}
.utente {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px;
  border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.utente:hover { background: var(--bg-panel-2); }
.utente.selezionato { background: #1c2c54; outline: 1px solid #2c3c6a; }
.utente.spento .nome { color: var(--testo-dim); }
.pallino { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.p-disponibile { background: #22c55e; }
.p-non_disponibile { background: #eab308; }
.p-in_call { background: #ef4444; }
.p-offline { background: #4b5563; }
.utente .nome { flex: 1; min-width: 0; }
.utente .sotto {
  display: block; color: var(--testo-dim); font-size: 10.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-non-letti {
  background: var(--accent); color: #fff; border-radius: 10px;
  padding: 1px 7px; font-size: 10.5px; font-weight: 700;
}
.conv-testata {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  font-weight: 600; padding: 2px 4px 8px;
}
.conv-msg {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 6px; padding: 2px; min-height: 0;
}
.bolla {
  max-width: 86%; padding: 6px 10px; border-radius: 10px;
  font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word;
}
.bolla .ora { display: block; color: var(--testo-dim); font-size: 10px; margin-top: 2px; }
.bolla .b-autore { color: #8fa8e8; font-size: 10.5px; font-weight: 700; display: block; }
.b-loro { background: var(--bg-panel-2); border: 1px solid var(--bordo); align-self: flex-start; }
.b-mio { background: #1c2c54; border: 1px solid #2c3c6a; align-self: flex-end; }
.conv-input { display: flex; gap: 6px; margin-top: 8px; }
.conv-input textarea {
  flex: 1; min-height: 52px; max-height: 110px; resize: vertical;
  font-size: 12.5px; margin-top: 0;
}
#btn-colleghi { position: relative; }
#colleghi-non-letti { margin-left: 4px; }

/* area chat mentre ci si trascina sopra un'immagine */
#tab-chat.drop-attivo .chat-colonna {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
  border-radius: 12px;
  background: rgba(79, 124, 255, .06);
}

.chat-composer { display: flex; gap: 10px; margin-top: 10px; }
.chat-composer textarea {
  flex: 1; resize: vertical;
  min-height: 104px; max-height: 300px;
  font-size: 14.5px;
}
.chat-composer .btn { align-self: flex-end; padding: 12px 26px; }

/* ── toolbar / tabelle ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=text] { width: 240px; margin-top: 0; }
.toolbar select { width: auto; margin-top: 0; }
.toolbar-titolo { font-size: 16px; }
.spaziatore { flex: 1; }
.tabella-contenitore {
  background: var(--bg-panel); border: 1px solid var(--bordo);
  border-radius: 12px; overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--bordo); }
th { color: var(--testo-dim); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: none; }
tbody tr.cliccabile { cursor: pointer; }
tbody tr.cliccabile:hover { background: var(--bg-panel-2); }

.badge-stato { padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.stato-open, .stato-new { background: #12321f; color: #86efac; }
.stato-pending { background: #33290e; color: #fde047; }
.stato-closed { background: #26264a; color: #a0a0c0; }

/* ── dettaglio ticket ── */
.dettaglio-testata { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dettaglio-griglia {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px; background: var(--bg-panel); border: 1px solid var(--bordo);
  border-radius: 12px; padding: 14px; margin-bottom: 14px;
}
.campo-eti { font-size: 11px; color: var(--testo-dim); }
.campo-val { font-size: 13.5px; font-weight: 600; }
.articolo { background: var(--bg-panel); border: 1px solid var(--bordo); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.articolo-testata { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.articolo-corpo { white-space: pre-wrap; font-size: 13.5px; }
.azioni-riga { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.pannello-inline {
  background: var(--bg-panel); border: 1px solid var(--bordo);
  border-radius: 12px; padding: 14px; margin-bottom: 14px;
}
.pannello-ai { border-color: #3b3b7a; }

/* ── FAQ ── */
.sottotabs { display: flex; gap: 4px; }
.sottotab {
  background: transparent; border: 1px solid var(--bordo); color: var(--testo-dim);
  padding: 6px 14px; border-radius: 8px; font: inherit; cursor: pointer;
}
.sottotab.attivo { background: var(--bg-panel-2); color: var(--testo); font-weight: 600; }
.faq-lista { display: flex; flex-direction: column; gap: 8px; }
.faq-voce { background: var(--bg-panel); border: 1px solid var(--bordo); border-radius: 10px; }
.faq-domanda {
  padding: 11px 14px; cursor: pointer; display: flex; gap: 10px; align-items: center;
  font-weight: 600; font-size: 13.5px;
}
.faq-domanda:hover { background: var(--bg-panel-2); }
.faq-risposta { padding: 0 14px 12px; white-space: pre-wrap; font-size: 13.5px; color: #c8c8dc; }
.faq-meta { padding: 0 14px 10px; }

/* ── modale ── */
.modale-sfondo {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modale-card { width: 560px; max-width: 94vw; max-height: 90vh; overflow-y: auto; }
.modale-card h2 { margin-bottom: 16px; font-size: 17px; }
.modale-azioni { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ── toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-panel-2); border: 1px solid var(--bordo);
  border-radius: 10px; padding: 11px 20px; z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 13.5px;
}
.toast.ok { border-color: #1e5a32; color: #86efac; }
.toast.errore-toast { border-color: #7f1d1d; color: #fca5a5; }

@media (max-width: 1220px) {
  .pannello-laterale[data-tipo="runbook"] { display: none; }
}
@media (max-width: 1000px) {
  .pannello-laterale { display: none; }   /* resta il tab 📚 FAQ */
  .badge-mini { display: none; }
}
@media (max-width: 760px) {
  .titolo-app { display: none; }
  .msg { max-width: 92%; }
  .riga-2 { grid-template-columns: 1fr; }
}
