/* Chat flottante "Chiedi al Brain" (public/assist.js). Variabili in theme.css / brand.css. */
.assist-fab { position: fixed; right: 20px; bottom: 20px; z-index: 45; display: inline-flex; align-items: center; gap: 8px; height: 42px;
  padding: 0 16px 0 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 13.5px; box-shadow: var(--shadow-lg); cursor: pointer; }
.assist-fab:hover { background: var(--hover); }
.assist-fab.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.assist-fab svg, .assist-icon svg, .assist-send svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#workspace[hidden] ~ .assist-fab, #workspace[hidden] ~ .assist-panel { display: none; }

.assist-panel { position: fixed; right: 20px; bottom: 72px; z-index: 46; width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100dvh - 110px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.assist-panel[hidden] { display: none; }
/* Con il pannello della task aperto (520px a destra) la chat si sposta alla sua sinistra. */
body:has(#crm-panel:not([hidden])) .assist-fab,
body:has(#crm-panel:not([hidden])) .assist-panel { right: calc(min(520px, 100vw) + 16px); }

.assist-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.assist-ctx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.assist-ctx-kind { font-size: 11px; color: var(--ink-3); font-weight: 550; }
.assist-ctx-label { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assist-icon { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); padding: 0; }
.assist-icon:hover { background: var(--hover); color: var(--ink); }

.assist-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: 13.5px; line-height: 1.55; }
.assist-msg { overflow-wrap: anywhere; }
.assist-msg.user { align-self: flex-end; max-width: 85%; background: var(--hover); padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; }
.assist-msg.assistant p { margin: 0 0 8px; }
.assist-msg.assistant ul { margin: 0 0 8px; padding-left: 18px; }
.assist-msg.error, .assist-error { color: var(--red-ink, var(--danger)); background: var(--red, transparent); padding: 8px 12px; border-radius: 10px; margin: 0; }
.assist-empty, .assist-wait { color: var(--ink-3); margin: 0; }
.assist-wait { animation: assistPulse 1.2s ease-in-out infinite alternate; }
@keyframes assistPulse { from { opacity: .45; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .assist-wait { animation: none; } }

@media (max-width: 860px) {
  .assist-fab { right: 14px; bottom: calc(72px + env(safe-area-inset-bottom)); height: 44px; padding: 0 13px; }
  .assist-fab-text { display: none; }
  .assist-panel, body:has(#crm-panel:not([hidden])) .assist-panel { inset: 0; width: auto; height: auto; border-radius: 0; right: 0; }
  body:has(#crm-panel:not([hidden])) .assist-fab { right: 14px; }
}
/* Composer a capsula (spunto: 21st.dev "Ai chat input" di jahed): campo che cresce, un solo pulsante tondo
   a destra che cambia ruolo: microfono (campo vuoto), invia (testo), stop (registrazione). */
.assist-form { display: flex; align-items: flex-end; gap: 6px; margin: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line-strong);
  border-radius: 22px; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.06);
  transition: border-radius .25s cubic-bezier(.175,.885,.32,1.275), border-color .15s; }
.assist-form:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
.assist-form.multi { border-radius: 16px; }
.assist-form textarea { flex: 1; min-width: 0; border: 0; outline: 0; box-shadow: none; resize: none; background: transparent; padding: 7px 0;
  font-size: 14px; line-height: 1.45; max-height: 140px; overflow-y: hidden; }
.assist-form textarea:focus { box-shadow: none; }
.assist-rec { align-self: center; font-size: 12px; font-weight: 600; color: var(--red-ink, var(--danger)); font-variant-numeric: tabular-nums; }
.assist-rec:empty { display: none; }
.assist-mic-engine { display: none !important; }
.assist-send { flex: none; width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: var(--ink); color: var(--bg); cursor: pointer; transition: transform .2s cubic-bezier(.175,.885,.32,1.275), background .15s; }
.assist-send:hover { transform: scale(1.06); }
.assist-send:active { transform: scale(.94); }
.assist-send:disabled { opacity: .35; cursor: default; transform: none; }
.assist-send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.assist-send[data-mode="stop"] { background: var(--red-ink, var(--danger)); animation: mic-pulse 1.4s ease-in-out infinite; }
.assist-send[data-mode="stop"] svg { fill: currentColor; stroke: none; }
@media (prefers-reduced-motion: reduce) { .assist-form, .assist-send { transition: none; } .assist-send[data-mode="stop"] { animation: none; } }
