/* Senso portal: assistente do paciente (popup de conversa de fluxo fixo, botao redondo no canto) e o avatar do brotinho. Usa so as cores e medidas do portal.css. Sem estilo inline (CSP). */

/* ---------------------------------------------------------------- avatar */
.bot-av { display: block; flex: none; }
.bot-stem { stroke: var(--pri); stroke-width: 3; stroke-linecap: round; }
.bot-leaf { fill: var(--pri); }
.bot-leaf2 { fill: var(--pri-h); }
.bot-body { fill: var(--pri-soft); stroke: var(--pri); stroke-width: 2.5; }
.bot-cheek { fill: var(--m2); opacity: .4; }
.bot-eye { fill: var(--ink); }
.bot-line { stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- botao redondo (em todas as telas do paciente) */
.chat-fab { position: fixed; right: 1.1rem; bottom: calc(4.9rem + env(safe-area-inset-bottom)); z-index: 8; width: 62px; height: 62px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 2px solid var(--pri); background: var(--surface); box-shadow: var(--pop); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chat-fab:hover { background: var(--pri-soft); }
.chat-fab:focus-visible { outline: 3px solid var(--pri); outline-offset: 3px; }
.chat-fab[hidden] { display: none; }
/* ---------------------------------------------------------------- balao de fala ao lado do botao ("Precisa de ajuda?", dicas) */
.chat-tip { position: fixed; right: calc(1.1rem + 62px + .75rem); bottom: calc(4.9rem + env(safe-area-inset-bottom) + 6px); z-index: 8; display: flex; align-items: stretch; max-width: min(17rem, calc(100vw - 1.1rem - 62px - .75rem - 1rem)); background: var(--surface); color: var(--ink); border: 1.5px solid var(--pri); border-radius: var(--r-l); box-shadow: var(--pop); transform-origin: 100% 85%; animation: tip-in .22s ease-out; }
.chat-tip[hidden] { display: none; }
/* o rabinho aponta para o botao */
.chat-tip::after { content: ""; position: absolute; right: -8px; bottom: 16px; width: 12px; height: 12px; background: var(--surface); border-right: 1.5px solid var(--pri); border-top: 1.5px solid var(--pri); transform: rotate(45deg); border-radius: 0 3px 0 0; }
.chat-tip-msg { flex: 1 1 auto; min-width: 0; margin: 0; padding: .7rem .4rem .7rem .95rem; border: 0; background: none; color: inherit; font: inherit; font-size: .95rem; line-height: 1.35; font-weight: 600; text-align: left; cursor: pointer; border-radius: var(--r-l) 0 0 var(--r-l); -webkit-tap-highlight-color: transparent; }
.chat-tip-x { flex: none; align-self: flex-start; display: grid; place-items: center; width: 32px; height: 32px; margin: .25rem .25rem 0 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--mute); opacity: .7; cursor: pointer; }
.chat-tip-x:hover { opacity: 1; background: var(--pri-soft); }
.chat-tip-msg:focus-visible, .chat-tip-x:focus-visible { outline: 3px solid var(--pri); outline-offset: -2px; }
@keyframes tip-in { from { opacity: 0; transform: translateX(8px) scale(.94); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat-tip { animation: none; } }
/* o botao do diario ("Novo registro") fica logo acima, para os dois nao se sobreporem; e o fim da pagina ganha folga para nada ficar escondido */
.app[data-assist] .fab { bottom: calc(9.5rem + env(safe-area-inset-bottom)); }
.app[data-assist] .main { padding-bottom: 10rem; }
@media (min-width: 960px) {
  .chat-fab { right: 1.5rem; bottom: 1.5rem; }
  .chat-tip { right: calc(1.5rem + 62px + .75rem); bottom: calc(1.5rem + 6px); max-width: 20rem; }
  .app[data-assist] .main { padding-bottom: 6.5rem; }
}

/* ---------------------------------------------------------------- o painel: uma tela so */
/* No celular ocupa a tela toda; no computador e uma janela no canto. */
.chat { position: fixed; inset: 0; z-index: 28; display: flex; flex-direction: column; background: var(--surface); color: var(--ink); overflow: hidden; padding-top: env(safe-area-inset-top); animation: chat-in .16s ease-out; }
.chat[hidden] { display: none; }
.chat:focus, .chat:focus-visible { outline: none; }
html.chat-open, html.chat-open body { overflow: hidden; }
@keyframes chat-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .chat { animation: none; } }
@media (min-width: 641px) {
  .chat { inset: auto 1.25rem 1.25rem auto; width: 24rem; height: min(38rem, calc(100vh - 2.5rem)); padding-top: 0; border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--pop); }
  html.chat-open, html.chat-open body { overflow: visible; }
}

.chat-head { flex: none; display: flex; align-items: center; gap: .6rem; padding: .65rem .6rem .65rem .9rem; border-bottom: 1px solid var(--line); }
.chat-av { flex: none; display: inline-grid; }
.chat-head .grow { min-width: 0; }
.chat-title { margin: 0; font-size: 1.05rem; line-height: 1.2; }
.chat-sub { margin: 0; font-size: .8rem; color: var(--mute); }
.chat-ibtn { flex: none; width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; }
.chat-ibtn:hover { background: var(--surface2); }
.chat-ibtn:focus-visible { outline: 3px solid var(--pri); outline-offset: -2px; }
.chat-ibtn.urgent { color: var(--bad); }
.chat-ibtn.urgent:hover { background: var(--bad-soft); }

/* a unica area que rola: as falas e, logo depois da ultima, as respostas rapidas */
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1rem; display: flex; flex-direction: column; gap: .8rem; }
.chat-log { display: flex; flex-direction: column; gap: .7rem; }

/* ---------------------------------------------------------------- balões */
.brow { display: flex; align-items: flex-end; gap: .5rem; min-width: 0; }
.brow.me { justify-content: flex-end; }
.bav { flex: none; display: inline-grid; }
.bubble { max-width: min(34rem, 86%); min-width: 0; padding: .65rem .85rem; border-radius: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.bot { background: var(--surface2); border: 1px solid var(--line); border-bottom-left-radius: 4px; color: var(--ink); }
.bubble.me { background: var(--pri); color: var(--pri-ink); border-bottom-right-radius: 4px; }
.bubble p { margin: 0 0 .45rem; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul.sum { margin: .2rem 0 .45rem; padding-left: 1.1rem; }
.bubble ul.sum li { margin: .15rem 0; }
.bubble .sos-grid { margin: .4rem 0; grid-template-columns: 1fr; }
.bubble .sos-call { grid-template-columns: auto 1fr; align-items: center; column-gap: .8rem; }
.bubble .sos-name, .bubble .sos-sub { grid-column: 2; }
.bubble .sos-num { grid-row: 1 / span 2; }
.typing { display: inline-flex; align-items: center; gap: 4px; padding: .8rem .9rem; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--mute); animation: chat-dot 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------------------------------------------------------------- respostas rapidas e campo de texto */
.chat-opts { display: flex; flex-wrap: wrap; gap: .5rem; }
.chat-opts:empty { display: none; }
.chip { margin: 0; display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; max-width: 100%; padding: .45rem .95rem; border-radius: 999px; border: 1.5px solid var(--pri); background: transparent; color: var(--pri-text); font: inherit; font-weight: 650; text-decoration: none; text-align: left; cursor: pointer; }
.chip:hover { background: var(--pri-soft); }
.chip:focus-visible { outline: 3px solid var(--pri); outline-offset: 2px; }
.chip.ghost { border-color: var(--line2); color: var(--ink); font-weight: 560; }
.chip.ghost:hover { background: var(--surface2); }
.chip.sos { border-color: var(--bad); color: var(--bad); }
.chip.sos:hover { background: var(--bad-soft); }
.chat-form { flex: none; display: flex; gap: .5rem; padding: .65rem .8rem calc(.65rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.chat-input { flex: 1; min-width: 0; min-height: 44px; padding: 0 1rem; border: 1.5px solid var(--line2); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; }
.chat-input:focus-visible { outline: 3px solid var(--pri); outline-offset: 1px; }
.chat-input[data-mode="note"] { border-color: var(--pri); }
.chat-send { flex: none; width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: var(--pri); color: var(--pri-ink); cursor: pointer; }
.chat-send:hover { background: var(--pri-h); }
.chat-send:focus-visible { outline: 3px solid var(--pri); outline-offset: 2px; }

@media (max-width: 640px) {
  .bubble { max-width: 90%; }
}
