/* Comunicazioni: notifiche recenti (campanella), messaggi, «Chiedi info», posta di info@. Caricato per ultimo. */

/* ---------- notifiche: menu della campanella (6 visibili, le altre scorrendo) e pagina per argomenti ---------- */
.nr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; align-content: start; }
.nr { position: relative; border-radius: 12px; overflow: hidden; transition: height .25s ease, margin .25s ease, opacity .25s ease; }
.nr.chiusa { height: 0 !important; margin-top: -8px; opacity: 0; }
.nr.evidenza .nr-card { animation: evidenzia 2.4s ease-out; }
@keyframes evidenzia { 0%, 35% { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214, 173, 82, .55); } 100% { box-shadow: none; } }
.nr-sotto { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 18px; gap: 8px; border-radius: 12px;
  background: linear-gradient(90deg, #8f2a20, rgba(143, 42, 32, .35)); color: #fff; font-weight: 800; opacity: 0;
  transition: opacity .15s, background .15s; }
.nr.pronta .nr-sotto { background: #c0392b; }
.nr-card { position: relative; height: 100%; display: flex; gap: 10px; align-items: flex-start; padding: 10px 44px 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; touch-action: pan-y; user-select: none;
  transition: transform .22s ease, opacity .22s ease; }
.nr.trascina .nr-card { transition: none; cursor: grabbing; }
.nr-card.nuova { border-color: var(--gold); background: var(--surface-2); }
.nr-card.errore { border-left: 4px solid #e05a4f; }
.nr-icona { font-size: 1.15rem; line-height: 1.3; }
.nr-main { display: grid; gap: 2px; min-width: 0; }
.nr-testo { font-weight: 700; font-size: .93rem; line-height: 1.3; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.nr-link::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }   /* tutta la notifica è cliccabile */
.nr-card:has(.nr-link) { cursor: pointer; padding-right: 64px; }
.nr-card:has(.nr-link):hover { border-color: var(--gold); }
.nr-card:has(.nr-link)::before { content: "→"; position: absolute; right: 14px; bottom: 10px; color: var(--gold); font-size: 1.1rem; }
.nr-card:has(.nr-link):hover .nr-testo { color: var(--gold); }
.nr-det { color: var(--muted); font-size: .84rem; white-space: pre-line; overflow-wrap: anywhere; }
.nr-quando { color: var(--muted); font-size: .78rem; }
.nr-x-form { position: absolute; right: 6px; top: 6px; margin: 0; z-index: 2; }
.nr-x { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; font-size: .85rem; line-height: 1; }
.nr-x:hover, .nr-x:focus-visible { color: #fff; border-color: #c0392b; background: #c0392b; }
@media (prefers-reduced-motion: reduce) { .nr, .nr-card, .nr-sotto { transition: none; } }
/* nel menu: altezza fissa, testo che non entra = puntini */
.nr-menu { height: 72px; flex: none; }
.nr-menu .nr-card { padding: 8px 40px 8px 10px; gap: 8px; }
.nr-menu .nr-card:has(.nr-link) { padding-right: 40px; }
.nr-menu .nr-card:has(.nr-link)::before { content: none; }
.nr-menu .nr-testo, .nr-menu .nr-det { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nr-menu .nr-testo { font-size: .88rem; }
.nr-menu .nr-det { font-size: .8rem; }
.nr-menu .nr-x { width: 26px; height: 26px; }
.notif-menu { position: absolute; top: calc(100% + 6px); right: 10px; z-index: 40; width: min(380px, calc(100vw - 20px));
  display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--gold); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .65); overflow: hidden; animation: scendi-menu .18s ease-out; }
.notif-menu[hidden] { display: none; }
@keyframes scendi-menu { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.nm-testa { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px 8px; }
.nm-lista { padding: 4px 8px 8px; max-height: calc(6 * 72px + 5 * 8px + 12px); overflow-y: auto; overscroll-behavior: contain; }
.nm-vuoto { margin: 0; padding: 8px 14px 14px; }
.nm-tutte { display: block; padding: 13px; text-align: center; font-weight: 800; color: var(--gold); text-decoration: underline;
  text-underline-offset: 4px; border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.nm-tutte:hover { background: var(--surface-2); }
.notif-gruppo .count-badge { margin-left: 0; }
.notif-gruppo > summary .muted { margin-left: 6px; }

/* ---------- messaggi: elenco delle conversazioni e riquadro a chat ---------- */
.conv-lista { display: grid; gap: 8px; }
.conv { position: relative; display: grid; gap: 3px; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.conv:hover { border-color: var(--gold); }
.conv.nuova { border-color: var(--gold); border-left: 4px solid var(--gold); background: var(--surface-2); padding-right: 44px; }
.conv.a-tutti:not(.nuova) { border-left: 4px solid #6fa3d8; }
.conv.chiusa { opacity: .6; }
.conv-riga { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.conv-ogg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conv-quando { flex: none; color: var(--muted); font-size: .78rem; }
.conv-chi { color: var(--muted); font-size: .84rem; }
.conv-ultimo { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.nuova .conv-ultimo { color: var(--ink); }
.conv-badge { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); margin: 0; }
.chat { width: min(640px, calc(100vw - 20px)); height: min(720px, calc(100dvh - 40px)); padding: 0; border: 1px solid var(--gold);
  border-radius: 20px; background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); overflow: hidden; }
.chat[open] { display: flex; flex-direction: column; animation: ingrandisci .2s ease-out; }
.chat::backdrop { background: rgba(5, 12, 9, .75); backdrop-filter: blur(3px); }
@keyframes ingrandisci { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chat-testa { flex: none; display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-titoli { display: grid; gap: 2px; min-width: 0; flex: 1; }
.chat-titoli h2 { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.chat-x { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none; }
.chat-x:hover { color: var(--ink); border-color: var(--gold); }
.chat-corpo { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.bolla { max-width: 82%; display: grid; gap: 4px; padding: 9px 13px; border-radius: 18px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.bolla.sua { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bolla.mia { align-self: flex-end; background: linear-gradient(140deg, #e3c271, var(--gold)); color: var(--gold-ink); border-bottom-right-radius: 5px; }
.bolla-testo { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.45; }
.bolla-ora { font-size: .7rem; opacity: .7; justify-self: end; }
.chat-chiusa { align-self: center; margin: 6px 0 0; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: .82rem; text-align: center; }
.chat-scrivi { flex: none; display: grid; gap: 8px; padding: 10px 12px 12px; background: var(--surface); border-top: 1px solid var(--line); }
.chat-scrivi textarea { resize: none; min-height: 48px; max-height: 140px; }
.chat-azioni { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat .btn.danger { color: #fff; background: #c0392b; border-color: #c0392b; }
/* urgenza: rossa urgente, gialla media (a tutti: azzurro) */
.invia-riga { gap: 10px; }
.urgenza-scelta select { width: auto; padding: 9px 12px; border-radius: 999px; font-weight: 700; }
.urgenza-scelta.media select { border-color: #e2b13c; background: rgba(226, 177, 60, .14); }
.urgenza-scelta.urgente select { border-color: #e0533f; background: rgba(224, 83, 63, .16); }
.urgenza-scelta select:disabled { opacity: .45; }
.urg-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.urg-tag.media { background: #e2b13c; color: #1a1305; }
.urg-tag.urgente { background: #e0533f; color: #fff; }
.conv.urg-media { border-color: #e2b13c; border-left: 4px solid #e2b13c; background: linear-gradient(90deg, rgba(226, 177, 60, .14), var(--surface) 70%); }
.conv.urg-urgente { border-color: #e0533f; border-left: 4px solid #e0533f; background: linear-gradient(90deg, rgba(224, 83, 63, .18), var(--surface) 70%); }
.chat.a-tutti { border-color: #6fa3d8; }
.chat.a-tutti .chat-testa { background: linear-gradient(180deg, rgba(111, 163, 216, .2), var(--surface)); }
.chat.urg-media { border: 2px solid #e2b13c; }
.chat.urg-media .chat-testa { background: linear-gradient(180deg, rgba(226, 177, 60, .28), var(--surface)); border-bottom-color: #e2b13c; }
.chat.urg-urgente { border: 2px solid #e0533f; }
.chat.urg-urgente .chat-testa { background: linear-gradient(180deg, rgba(224, 83, 63, .3), var(--surface)); border-bottom-color: #e0533f; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.msg-tutti { justify-self: start; margin: 0; padding: 2px 9px; border-radius: 999px; background: #6fa3d8; color: #08121d;
  font-size: .7rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.msg-scrivi { max-width: 640px; }
.scegli { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
.scegli legend { font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.scegli-lista { display: grid; gap: 4px; align-content: start; padding: 4px; border: 1px solid var(--line); border-radius: 12px;
  max-height: calc(4 * 42px + 3 * 4px + 10px); overflow-y: auto; overscroll-behavior: contain; }   /* 4 voci, le altre scorrendo */
.form .scegli-voce:not([hidden]) { display: flex; }
.scegli-voce { align-items: center; gap: 10px; height: 42px; box-sizing: border-box; padding: 0 10px; overflow: hidden; white-space: nowrap; border-radius: 8px; cursor: pointer; }
.scegli-voce input { width: auto; accent-color: var(--gold); }
.scegli-voce:has(input:checked) { background: var(--surface-2); outline: 1px solid var(--gold); }
.scegli-voce.tutti { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; margin-bottom: 2px; }
.destinatario { background: var(--bg); }
.dest-scelto { margin-left: auto; color: var(--gold); font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.destinatario > summary::after { margin-left: 8px; }

/* ---------- posta di info: nuove in evidenza, lette sbiadite ---------- */
.mail-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.mail { display: grid; gap: 3px; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.mail:hover { border-color: var(--gold); opacity: 1; }
.mail.nuova { border-color: var(--gold); border-left: 4px solid var(--gold); background: var(--surface-2); }
.mail.nuova .mail-da, .mail.nuova .mail-ogg { font-weight: 800; }
.mail.letta { opacity: .55; }
.mail-riga { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.mail-da { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-quando { flex: none; color: var(--muted); font-size: .8rem; }
.mail-ogg { overflow-wrap: anywhere; }
.mail-tag { justify-self: start; font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #3fae7a; }
.mail-tag.nuova { color: var(--gold-ink); background: var(--gold); border-radius: 999px; padding: 1px 8px; }
.mail-aperta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; min-width: 0; }
.mail-testata { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.mail-titolo { font-size: clamp(1.35rem, 5vw, 1.9rem); margin: 0 0 8px; overflow-wrap: anywhere; }
.mail-chi { margin: 0 0 2px; overflow-wrap: anywhere; }
.mail-testata .small { margin: 0; }
.mail-corpo { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.mail-allegati { margin: 14px 0 0; }
.mail-risposta .form { margin: 0; }
.chat-titoli .urg-tag, .chat-titoli .msg-tutti { justify-self: start; }
