/* Stile vicino a WhatsApp Web. Ale è daltonico: gli stati non usano mai solo il colore
   (le spunte hanno anche il testo nel suggerimento, lo stato del numero ha la scritta). */
:root {
  --sfondo: #eae6df;
  --pannello: #ffffff;
  --testata: #f0f2f5;
  --bordo: #e9edef;
  --testo: #111b21;
  --testo-2: #667781;
  --accento: #00a884;
  --accento-scuro: #008069;
  --mio: #d9fdd3;
  --altrui: #ffffff;
  --sfondo-chat: #efeae2;
  --letto: #027eb5;
  --attivo: #f0f2f5;
  --ombra: 0 1px 0.5px rgba(11, 20, 26, .13);
  --avviso: #b35c00;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sfondo: #0c1317; --pannello: #111b21; --testata: #202c33; --bordo: #222d34; --testo: #e9edef; --testo-2: #8696a0;
    --mio: #005c4b; --altrui: #202c33; --sfondo-chat: #0b141a; --letto: #53bdeb; --attivo: #2a3942; --avviso: #ffb35c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--sfondo); color: var(--testo); font-size: 14.5px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: minmax(300px, 30%) 1fr; height: 100vh; height: 100dvh; max-width: 1700px; margin: 0 auto; background: var(--pannello); box-shadow: 0 6px 18px rgba(11,20,26,.05); }
@media (min-width: 1440px) { body { padding: 19px 0; } .app { height: calc(100dvh - 38px); } }

.tasto-icona { background: none; border: 0; width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 18px; color: var(--testo-2); text-decoration: none; flex: none; }
.tasto-icona:hover { background: rgba(0,0,0,.06); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #dfe5e7; flex: none; }
.avatar.lettere { display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 16px; }

/* --- colonna sinistra --- */
.colonna-sinistra { display: flex; flex-direction: column; border-right: 1px solid var(--bordo); min-width: 0; min-height: 0; }
.testata-sinistra { display: flex; align-items: center; gap: 6px; background: var(--testata); padding: 8px 10px; min-height: 59px; }
.numeri { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.numero { display: flex; align-items: center; gap: 5px; border: 1px solid var(--bordo); background: var(--pannello); border-radius: 16px; padding: 2px 8px 2px 2px; white-space: nowrap; font-size: 12.5px; line-height: 1.15; text-align: left; }
.numero img, .numero .avatar { width: 26px; height: 26px; font-size: 11px; }
.numero.attivo { border-color: var(--accento); box-shadow: inset 0 0 0 1px var(--accento); font-weight: 600; }
.numero .stato { font-size: 11px; color: var(--testo-2); font-weight: 400; }
.numero .stato.spento { color: var(--avviso); }
.numero .contatore { background: var(--accento); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; font-weight: 600; }
.azioni-testata { display: flex; }
.avviso-numero { background: #fff3c4; color: #5b4300; padding: 10px 14px; font-size: 13px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.avviso-numero button { background: var(--accento-scuro); color: #fff; border: 0; border-radius: 16px; padding: 5px 12px; }
@media (prefers-color-scheme: dark) { .avviso-numero { background: #3b3000; color: #ffe9a6; } }
.cerca { padding: 7px 12px; border-bottom: 1px solid var(--bordo); }
.cerca input { width: 100%; border: 0; background: var(--testata); border-radius: 8px; padding: 8px 12px; outline: none; }
.filtri { display: flex; gap: 6px; padding: 7px 12px; }
.filtro { border: 0; background: var(--testata); color: var(--testo-2); border-radius: 16px; padding: 5px 12px; font-size: 13.5px; }
.filtro.attivo { background: #d8fdd2; color: #0a5c4a; font-weight: 600; }
@media (prefers-color-scheme: dark) { .filtro.attivo { background: #0a332c; color: #71eb85; } }
.elenco-chat { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.voce-chat { display: flex; gap: 12px; align-items: center; padding: 0 0 0 13px; cursor: pointer; }
.voce-chat:hover { background: var(--attivo); }
.voce-chat.aperta { background: var(--attivo); }
.voce-chat .avatar { width: 49px; height: 49px; font-size: 19px; }
.voce-chat .corpo { flex: 1; min-width: 0; border-bottom: 1px solid var(--bordo); padding: 12px 15px 12px 0; }
.voce-chat .riga { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.voce-chat .nome { font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voce-chat .ora { font-size: 12px; color: var(--testo-2); flex: none; }
.voce-chat.non-letta .ora { color: var(--accento); font-weight: 600; }
.voce-chat .anteprima { color: var(--testo-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voce-chat .badge { background: var(--accento); color: #fff; border-radius: 12px; min-width: 20px; height: 20px; font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; padding: 0 6px; flex: none; }
.vuoto-elenco { padding: 30px; text-align: center; color: var(--testo-2); }

/* --- colonna destra --- */
.colonna-destra { position: relative; display: flex; min-width: 0; min-height: 0; background: var(--sfondo-chat); }
.schermata-vuota { margin: auto; text-align: center; color: var(--testo-2); padding: 30px; }
.schermata-vuota h2 { color: var(--testo); font-weight: 300; font-size: 30px; }
.nota { color: var(--testo-2); font-size: 13px; }
.conversazione { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.testata-chat { display: flex; align-items: center; gap: 12px; background: var(--testata); padding: 8px 14px; min-height: 59px; border-left: 1px solid var(--bordo); }
.testata-chat .indietro { display: none; }
.chat-titolo { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.chat-titolo strong { font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-titolo span { font-size: 13px; color: var(--testo-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-cerca-chat { display: flex; gap: 8px; align-items: center; padding: 6px 14px; background: var(--testata); border-top: 1px solid var(--bordo); }
.barra-cerca-chat input { flex: 1; border: 0; border-radius: 8px; padding: 6px 10px; background: var(--pannello); }
.messaggi { flex: 1; overflow-y: auto; padding: 14px 6% 8px; display: flex; flex-direction: column; gap: 2px; min-height: 0;
  background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 18px 18px; }
.carica-altri { align-self: center; margin: 8px; color: var(--testo-2); font-size: 13px; }
.giorno { align-self: center; background: var(--pannello); color: var(--testo-2); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--ombra); margin: 10px 0 6px; text-transform: uppercase; }
.msg { max-width: min(65%, 560px); align-self: flex-start; background: var(--altrui); border-radius: 7.5px; padding: 6px 7px 8px 9px; box-shadow: var(--ombra); position: relative; margin-top: 2px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.mio { align-self: flex-end; background: var(--mio); }
.msg.primo { margin-top: 10px; }
.msg.primo:not(.mio)::before { content: ""; position: absolute; left: -8px; top: 0; border: 8px solid transparent; border-top-color: var(--altrui); border-right-color: var(--altrui); border-width: 0 8px 13px 0; }
.msg.primo.mio::before { content: ""; position: absolute; right: -8px; top: 0; border-style: solid; border-color: var(--mio) transparent transparent var(--mio); border-width: 0 0 13px 8px; }
.msg .autore { font-size: 12.8px; font-weight: 600; margin-bottom: 2px; }
.msg .numero-autore { font-weight: 400; color: var(--testo-2); font-size: 12px; }
.msg .testo { white-space: pre-wrap; line-height: 19px; }
.msg .testo a { color: #027eb5; }
.msg .piede { float: right; margin: 6px 0 -5px 10px; font-size: 11px; color: var(--testo-2); display: inline-flex; gap: 3px; align-items: center; position: relative; top: 4px; }
.msg .spunte { font-size: 13px; letter-spacing: -4px; padding-right: 4px; }
.msg .spunte.letto { color: var(--letto); font-weight: 700; }
.msg .spunte.errore { color: var(--avviso); letter-spacing: 0; }
.msg .modificato, .msg .inoltrato { font-size: 11.5px; color: var(--testo-2); font-style: italic; }
.msg.eliminato .testo { color: var(--testo-2); font-style: italic; }
.msg .citazione { background: rgba(0,0,0,.05); border-left: 4px solid var(--accento); border-radius: 6px; padding: 5px 8px; margin-bottom: 5px; font-size: 13px; color: var(--testo-2); cursor: pointer; max-height: 70px; overflow: hidden; }
.msg .citazione strong { display: block; color: var(--accento-scuro); font-size: 12.5px; }
.msg .immagine, .msg video.video { display: block; max-width: 100%; width: 330px; max-height: 340px; object-fit: cover; border-radius: 6px; cursor: pointer; background: rgba(0,0,0,.08); min-height: 120px; }
.msg .sticker { width: 160px; height: 160px; object-fit: contain; background: none; }
.msg.solo-sticker { background: none; box-shadow: none; }
.msg.solo-sticker::before { display: none; }
.msg audio { width: 290px; max-width: 100%; display: block; height: 40px; }
.msg .vocale { display: flex; align-items: center; gap: 6px; }
.msg .vocale .durata { font-size: 11.5px; color: var(--testo-2); }
.msg .documento { display: flex; gap: 10px; align-items: center; background: rgba(0,0,0,.05); border-radius: 6px; padding: 10px; text-decoration: none; color: inherit; min-width: 240px; }
.msg .documento .icona { font-size: 28px; }
.msg .documento small { display: block; color: var(--testo-2); }
.msg .posizione a, .msg .link a { color: #027eb5; }
.msg .link { background: rgba(0,0,0,.05); border-radius: 6px; padding: 6px 8px; margin-bottom: 4px; font-size: 13px; }
.msg .reazioni { position: absolute; bottom: -14px; left: 8px; background: var(--pannello); border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.2); padding: 1px 6px; font-size: 14px; cursor: default; }
.msg.mio .reazioni { left: auto; right: 8px; }
.msg.con-reazioni { margin-bottom: 14px; }
.msg .menu-msg { position: absolute; top: 2px; right: 2px; opacity: 0; background: inherit; border: 0; border-radius: 50%; width: 26px; height: 26px; font-size: 14px; color: var(--testo-2); }
.msg:hover .menu-msg, .msg:focus-within .menu-msg { opacity: 1; }
.msg.evidenziato { animation: lampo 1.6s; }
.msg.trovato { outline: 2px solid #f5b400; }
@keyframes lampo { 0%, 60% { box-shadow: 0 0 0 4px rgba(0, 168, 132, .5); } }
.msg.in-invio { opacity: .7; }
.msg .sistema { color: var(--testo-2); font-style: italic; }
.tendina { position: fixed; z-index: 40; background: var(--pannello); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.22); padding: 6px 0; min-width: 190px; }
.tendina button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 18px; }
.tendina button:hover { background: var(--attivo); }
.tendina .emoji-veloci { display: flex; gap: 2px; padding: 2px 8px 6px; border-bottom: 1px solid var(--bordo); }
.tendina .emoji-veloci button { width: 34px; padding: 4px; text-align: center; font-size: 20px; border-radius: 50%; }

.vai-giu { position: absolute; right: 22px; bottom: 76px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--pannello); box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 18px; color: var(--testo-2); }
.vai-giu span:not(:empty) { position: absolute; top: -6px; right: -4px; background: var(--accento); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 5px; }
.risposta-a { display: flex; align-items: center; gap: 10px; background: var(--testata); padding: 8px 14px 0; }
.risposta-a > div { flex: 1; background: rgba(0,0,0,.05); border-left: 4px solid var(--accento); border-radius: 6px; padding: 6px 10px; font-size: 13px; color: var(--testo-2); max-height: 64px; overflow: hidden; }
.risposta-a strong { display: block; color: var(--accento-scuro); }
.file-pronti { display: flex; gap: 10px; flex-wrap: wrap; background: var(--testata); padding: 10px 14px 0; }
.file-pronto { position: relative; background: var(--pannello); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; align-items: center; width: 120px; font-size: 12px; text-align: center; }
.file-pronto img, .file-pronto video { width: 106px; height: 80px; object-fit: cover; border-radius: 6px; }
.file-pronto .icona { font-size: 34px; height: 80px; display: grid; place-items: center; }
.file-pronto span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.file-pronto button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #54656f; color: #fff; font-size: 12px; }
.scrivi { display: flex; align-items: flex-end; gap: 6px; background: var(--testata); padding: 8px 12px; }
.scrivi textarea { flex: 1; resize: none; border: 0; border-radius: 8px; padding: 10px 12px; background: var(--pannello); max-height: 150px; outline: none; line-height: 20px; }
.tasto-invia, .tasto-registra { color: var(--testo-2); }
.tasto-invia { color: var(--accento-scuro); }
.registrazione { display: flex; align-items: center; gap: 10px; background: var(--testata); padding: 8px 14px; justify-content: flex-end; }
.punto-rec { width: 11px; height: 11px; border-radius: 50%; background: #e03c31; animation: pulsa 1s infinite; }
@keyframes pulsa { 50% { opacity: .3; } }
.trascina { position: absolute; inset: 0; background: rgba(0, 168, 132, .12); border: 3px dashed var(--accento); z-index: 30; display: grid; place-items: center; font-size: 22px; color: var(--accento-scuro); pointer-events: none; }

.dettagli { width: 360px; max-width: 100%; background: var(--pannello); border-left: 1px solid var(--bordo); display: flex; flex-direction: column; overflow-y: auto; }
.dettagli header { display: flex; align-items: center; gap: 14px; background: var(--testata); padding: 10px 14px; min-height: 59px; }
#dettagli-corpo { padding: 20px; }
#dettagli-corpo .grande { width: 160px; height: 160px; border-radius: 50%; display: block; margin: 0 auto 14px; object-fit: cover; font-size: 50px; }
#dettagli-corpo h3 { text-align: center; margin: 4px 0; font-weight: 400; font-size: 22px; }
#dettagli-corpo .sotto { text-align: center; color: var(--testo-2); }
#dettagli-corpo ul { list-style: none; padding: 0; }
#dettagli-corpo li { padding: 8px 0; border-bottom: 1px solid var(--bordo); display: flex; justify-content: space-between; gap: 8px; }
#dettagli-corpo li small { color: var(--testo-2); }

.visore { position: fixed; inset: 0; background: rgba(11, 20, 26, .94); z-index: 50; display: grid; place-items: center; }
.visore .tasto-icona { position: absolute; top: 12px; color: #fff; }
#chiudi-visore { right: 12px; }
#scarica-visore { right: 60px; }
#visore-corpo img, #visore-corpo video { max-width: 92vw; max-height: 88vh; }

.dialogo { border: 0; border-radius: 10px; padding: 22px 24px; background: var(--pannello); color: var(--testo); box-shadow: 0 10px 40px rgba(0,0,0,.3); max-width: 420px; }
.dialogo::backdrop { background: rgba(0,0,0,.35); }
.dialogo h3 { margin-top: 0; font-weight: 500; }
.dialogo input { width: 100%; padding: 9px 10px; border: 1px solid var(--bordo); border-radius: 6px; background: var(--testata); margin-top: 6px; }
.dialogo menu { display: flex; justify-content: flex-end; gap: 10px; padding: 0; margin: 18px 0 0; }
.dialogo menu button { border: 0; border-radius: 18px; padding: 8px 18px; background: var(--testata); }
.dialogo menu button[value="ok"] { background: var(--accento-scuro); color: #fff; }
.qr { display: grid; place-items: center; min-height: 260px; }
.qr img { width: 260px; height: 260px; background: #fff; padding: 8px; border-radius: 6px; }
.errore { color: var(--avviso); min-height: 1em; }

.pagina-entra { display: grid; place-items: center; min-height: 100vh; background: var(--sfondo); }
.scheda-entra { background: var(--pannello); padding: 36px 40px; border-radius: 12px; box-shadow: 0 6px 30px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 8px; width: min(380px, 92vw); text-align: center; }
.scheda-entra img { margin: 0 auto; }
.scheda-entra h1 { font-weight: 400; margin: 6px 0 0; }
.scheda-entra p { color: var(--testo-2); margin: 0 0 12px; }
.scheda-entra label { text-align: left; font-size: 13px; color: var(--testo-2); }
.scheda-entra input { padding: 10px 12px; border: 1px solid var(--bordo); border-radius: 8px; background: var(--testata); }
.scheda-entra button { margin-top: 8px; padding: 10px; border: 0; border-radius: 22px; background: var(--accento-scuro); color: #fff; font-weight: 600; }

.notifica-errore { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #3b4a54; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: 90vw; }

/* telefono: una colonna alla volta */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.chat-aperta .colonna-sinistra { display: none; }
  .app:not(.chat-aperta) .colonna-destra { display: none; }
  .testata-chat .indietro { display: inline-grid; }
  .messaggi { padding: 10px 3%; }
  .msg { max-width: 85%; }
  .dettagli { position: absolute; inset: 0; width: 100%; z-index: 20; }
}
@media (min-width: 761px) and (max-width: 1100px) { .dettagli { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; } }
