/* La chat del sito con la mascotte (14/11/2026). Tutto sotto .cs: non tocca il resto della pagina.
   Colori del marchio: Notte #0E0E10, corallo #FF6F4C (su chiaro, come testo, #B8432A), oro #E8A93C. */
.cs { --cs-su: 0px; --cs-notte: #0E0E10; --cs-notte-2: #16161a; --cs-corallo: #FF6F4C; --cs-corallo-scuro: #B8432A; --cs-oro: #E8A93C; --cs-testo: #2a2a2f; --cs-linea: #e4dfd7;
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--cs-su)); z-index: 70;
  --cs-font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif; font-family: var(--cs-font); transition: bottom .25s; }
.cs *, .cs *::before, .cs *::after { box-sizing: border-box; }
.cs-nascosto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- il tasto con la mascotte ---------- */
.cs-lancia { position: relative; display: block; width: 84px; height: 84px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #26262d, var(--cs-notte) 70%); box-shadow: 0 0 0 3px var(--cs-corallo), 0 14px 34px rgba(14, 14, 16, .45); animation: cs-anello 2.8s ease-out 4s 3; }
.cs-lancia:hover { transform: translateY(-2px); }
.cs-lancia:focus-visible { outline: 3px solid var(--cs-oro); outline-offset: 4px; }
.cs-lancia-robot { position: absolute; inset: -6px 2px 6px; }
.cs-lancia .cs-robot { width: 100%; height: 100%; overflow: visible; }
.cs-chip-ai { position: absolute; left: -4px; top: -4px; padding: 2px 7px; border-radius: 999px; background: var(--cs-oro); color: var(--cs-notte); font: 800 .72rem/1.3 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.cs-badge { position: absolute; right: -2px; top: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--cs-corallo); color: var(--cs-notte); font: 800 .8rem/22px system-ui, sans-serif; }
.cs-badge[hidden] { display: none; }
.cs-aperta .cs-lancia { display: none; }
.cs-compatto .cs-lancia { width: 60px; height: 60px; }
.cs-compatto .cs-chip-ai { font-size: .62rem; padding: 1px 5px; }

/* ---------- il fumetto ---------- */
.cs-fumetto { position: absolute; right: 0; bottom: 100px; width: max-content; max-width: min(300px, calc(100vw - 32px)); display: flex; align-items: flex-start; gap: 4px;
  padding: 12px 8px 12px 16px; border-radius: 18px 18px 4px 18px; background: #fff; color: var(--cs-notte); border: 2px solid var(--cs-notte);
  box-shadow: 0 14px 34px rgba(14, 14, 16, .22); animation: cs-entra .35s cubic-bezier(.2, .9, .3, 1.3); }
.cs-fumetto[hidden] { display: none; }
.cs-fumetto::after { content: ""; position: absolute; right: 30px; bottom: -10px; width: 16px; height: 16px; background: #fff; border-right: 2px solid var(--cs-notte); border-bottom: 2px solid var(--cs-notte); transform: rotate(45deg); }
.cs-fumetto-testo { border: 0; background: none; padding: 0; text-align: left; font: 700 1rem/1.35 var(--cs-font); color: inherit; cursor: pointer; }
.cs-fumetto-chiudi { flex: none; width: 32px; height: 32px; margin: -6px -2px 0 0; border: 0; border-radius: 50%; background: none; color: #55555b; cursor: pointer; display: grid; place-items: center; }
.cs-fumetto-chiudi svg, .cs-chiudi svg { width: 18px; height: 18px; }
.cs-fumetto-chiudi:hover { background: #f1ede7; }
.cs button:focus-visible, .cs a:focus-visible, .cs textarea:focus-visible, .cs input:focus-visible { outline: 3px solid var(--cs-corallo); outline-offset: 2px; }

/* ---------- il pannello ---------- */
.cs-pannello { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--cs-su)); width: 400px; max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 120px)); height: min(640px, calc(100dvh - 40px - var(--cs-su))); display: flex; flex-direction: column; background: #FAF8F4; color: var(--cs-testo);
  border-radius: 20px; overflow: hidden; box-shadow: 0 24px 70px rgba(14, 14, 16, .35), 0 0 0 1px rgba(14, 14, 16, .08); animation: cs-entra .25s ease-out; }
.cs-pannello[hidden] { display: none; }
.cs-testa { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; background: var(--cs-notte); color: #fff; }
.cs-avatar { flex: none; width: 52px; height: 52px; border-radius: 50%; background: #202026; box-shadow: 0 0 0 2px var(--cs-corallo); display: grid; place-items: center; overflow: hidden; }
.cs-avatar .cs-robot { width: 48px; height: 48px; margin-top: 4px; }
.cs-chi { flex: 1; min-width: 0; }
.cs-chi h2 { margin: 0; font: 800 1.15rem/1.2 var(--cs-font); color: #fff; }
.cs-chi h2:focus { outline: none; }
.cs-chi p { margin: 2px 0 0; font-size: .875rem; font-weight: 600; color: #d9d9de; display: flex; align-items: center; gap: 6px; }
.cs-punto { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, .25); }
.cs-chiudi { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; display: grid; place-items: center; }
.cs-chiudi:hover { background: rgba(255, 255, 255, .16); }
.cs-avviso-ai { margin: 0; padding: 8px 14px; font-size: .78rem; line-height: 1.4; background: #fff4dc; color: #5b4310; border-bottom: 1px solid #f0dfb5; }
.cs-corpo { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 6px; }
.cs-messaggi { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cs-m { max-width: 88%; }
.cs-m p { margin: 0; padding: 10px 13px; border-radius: 16px; font-size: .95rem; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.cs-m-assistente p { background: #fff; border: 1px solid var(--cs-linea); border-top-left-radius: 4px; }
.cs-m-marco p { background: #fff4dc; border: 1px solid #ecd39a; border-top-left-radius: 4px; }
.cs-m-utente { align-self: flex-end; }
.cs-m-utente p { background: var(--cs-notte); color: #fff; border-top-right-radius: 4px; }
.cs-m a { color: var(--cs-corallo-scuro); font-weight: 700; text-underline-offset: 2px; }
.cs-m-utente a { color: #ffc2b2; }
.cs-chi-m { display: block; margin: 0 0 3px 4px; font: 700 .7rem/1.2 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; color: #6B6B70; }
.cs-m-marco .cs-chi-m { color: #8a5d00; }
.cs-scrive { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: .85rem; color: #55555b; }
.cs-scrive[hidden] { display: none; }
.cs-puntini { display: inline-flex; gap: 4px; padding: 10px 12px; background: #fff; border: 1px solid var(--cs-linea); border-radius: 14px; }
.cs-puntini i { width: 7px; height: 7px; border-radius: 50%; background: var(--cs-corallo-scuro); animation: cs-punto 1.1s infinite ease-in-out; }
.cs-puntini i:nth-child(2) { animation-delay: .15s; }
.cs-puntini i:nth-child(3) { animation-delay: .3s; }
.cs-pronte { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.cs-pronte-riga { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.cs-pronta { flex: none; border: 1.5px solid var(--cs-notte); background: #fff; color: var(--cs-notte); border-radius: 999px; padding: 8px 13px; font: 600 .875rem/1.25 var(--cs-font); cursor: pointer; text-align: left; max-width: 100%; }
.cs-pronte-riga .cs-pronta { white-space: nowrap; }
.cs-pronta:hover { background: var(--cs-notte); color: #fff; }
.cs-email { margin: 10px 0 6px; padding: 12px; background: #fff; border: 1.5px solid var(--cs-oro); border-radius: 14px; }
.cs-email[hidden] { display: none; }
.cs-email label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; color: var(--cs-notte); }
.cs-riga { display: flex; gap: 8px; }
.cs-email input { flex: 1; min-width: 0; font: 500 16px/1.3 var(--cs-font); padding: 10px 12px; border: 1.5px solid #8d8d93; border-radius: 10px; background: #fff; color: var(--cs-notte); }
.cs-bottone { flex: none; border: 0; border-radius: 10px; background: var(--cs-corallo); color: var(--cs-notte); font: 800 .95rem/1 var(--cs-font); padding: 0 16px; min-height: 44px; cursor: pointer; }
.cs-nota { margin: 6px 0 0; font-size: .78rem; color: #55555b; }
.cs-nota a { color: var(--cs-corallo-scuro); }
.cs-esito { margin: 6px 0 0; font-size: .85rem; color: #a3261a; }
.cs-esito:empty { display: none; }
.cs-scrivi { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--cs-linea); background: #fff; }
.cs-scrivi textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; font: 500 16px/1.4 var(--cs-font); padding: 10px 12px; border: 1.5px solid #8d8d93; border-radius: 14px; background: #fff; color: var(--cs-notte); }
.cs-scrivi textarea::placeholder { color: #6B6B70; }
.cs-invia { flex: none; width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--cs-corallo); color: var(--cs-notte); cursor: pointer; display: grid; place-items: center; }
.cs-invia svg { width: 22px; height: 22px; }
.cs-invia:disabled { opacity: .55; cursor: wait; }
.cs-piede { margin: 0; padding: 0 12px 10px; background: #fff; text-align: center; }
.cs-link { border: 0; background: none; padding: 6px 4px; font: 600 .82rem/1.3 var(--cs-font); color: var(--cs-corallo-scuro); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* sul telefono: la chat a tutto schermo, la pagina sotto ferma */
@media (max-width: 640px) {
  .cs-lancia { width: 66px; height: 66px; }
  .cs-compatto .cs-lancia { width: 56px; height: 56px; }
  .cs-fumetto { bottom: 80px; }
  .cs-pannello { inset: 0; width: 100%; max-width: none; height: 100%; height: 100dvh; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
  html.cs-blocca, html.cs-blocca body { overflow: hidden; }
}
/* telefoni piccoli (18/11/2026): la mascotte più piccola e più in basso, accanto al banner dei cookie (che le lascia spazio) */
@media (max-width: 480px) {
  .cs { right: max(10px, env(safe-area-inset-right)); bottom: calc(max(8px, env(safe-area-inset-bottom)) + var(--cs-su)); }
  .cs-lancia, .cs-compatto .cs-lancia { width: 50px; height: 50px; box-shadow: 0 0 0 2px var(--cs-corallo), 0 8px 20px rgba(14, 14, 16, .4); }
  .cs-lancia-robot { inset: -4px 1px 4px; }
  .cs-chip-ai { font-size: .58rem; padding: 0 4px; left: -6px; top: -6px; }
  .cs-badge { min-width: 18px; height: 18px; font-size: .7rem; line-height: 18px; right: -4px; top: -4px; }
  .cs-fumetto { bottom: 62px; }
}

/* ---------- la mascotte animata ---------- */
.cs-robot .cs-r-tutto { animation: cs-galleggia 3.2s ease-in-out infinite alternate; transform-box: view-box; }
.cs-robot .cs-r-occhio { transform-box: fill-box; transform-origin: center; animation: cs-sbatte 4.6s infinite; }
.cs-robot .cs-r-luce { transform-box: fill-box; transform-origin: center; animation: cs-luce 2.4s ease-in-out infinite; }
.cs-robot .cs-r-braccio-d { transform-box: view-box; transform-origin: 84px 96px; }
.cs-robot.saluta .cs-r-braccio-d { animation: cs-saluta .45s ease-in-out 4 alternate; }
.cs-robot.pensa .cs-r-occhi { animation: cs-guarda 1.2s ease-in-out infinite alternate; }
.cs-robot.pensa .cs-r-luce { animation-duration: .5s; }
.cs-robot.pensa .cs-r-bocca { d: path("M54 70 L66 70"); }
@keyframes cs-galleggia { from { transform: translateY(1px); } to { transform: translateY(-4px); } }
@keyframes cs-sbatte { 0%, 90%, 100% { transform: scaleY(1); } 93% { transform: scaleY(.1); } 96% { transform: scaleY(1); } }
@keyframes cs-luce { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .55; transform: scale(.8); } }
@keyframes cs-saluta { from { transform: rotate(-18deg); } to { transform: rotate(16deg); } }
@keyframes cs-guarda { from { transform: translateX(-5px); } to { transform: translateX(5px); } }
@keyframes cs-entra { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cs-punto { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes cs-anello { 0% { box-shadow: 0 0 0 3px var(--cs-corallo), 0 0 0 3px rgba(255, 111, 76, .6), 0 14px 34px rgba(14, 14, 16, .45); } 100% { box-shadow: 0 0 0 3px var(--cs-corallo), 0 0 0 22px rgba(255, 111, 76, 0), 0 14px 34px rgba(14, 14, 16, .45); } }

@media (prefers-reduced-motion: reduce) {
  .cs *, .cs *::before, .cs *::after, .cs-lancia { animation: none !important; transition: none !important; }
  .cs { transition: none; }
}

/* ---------- il pannello di Marco (/admin/chat-sito) ---------- */
.csa-lista { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.csa-conv details { background: #fff; border: 1px solid #e4dfd7; border-radius: 14px; padding: 12px 14px; }
.csa-conv summary { cursor: pointer; line-height: 1.5; }
.csa-conv summary small { color: #6B6B70; margin-left: 6px; }
.csa-umano { background: #ffe1d8; }
.csa-presente { background: #d8f5e4; }
.csa-messaggi { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.csa-m p { margin: 2px 0 0; white-space: pre-line; }
.csa-m small { color: #6B6B70; }
.csa-utente { padding-left: 10px; border-left: 3px solid #0E0E10; }
.csa-assistente { padding-left: 10px; border-left: 3px solid #e4dfd7; }
.csa-marco { padding-left: 10px; border-left: 3px solid #E8A93C; }
.csa-rispondi textarea { width: 100%; font: inherit; padding: 10px; border: 1.5px solid #8d8d93; border-radius: 10px; }
