/* Assistente virtual do portal (templates/portal/_chat.html e chat.js). Usa as variáveis de cor e fonte do
   portal/base.html; os valores depois da vírgula valem só se a página não as tiver. */
.chat-ia { position: fixed; right: 20px; bottom: 20px; z-index: 55; font-family: var(--corpo, system-ui, sans-serif); color: var(--texto, #f1f2ed); }
.chat-ia[hidden], .chat-ia [hidden] { display: none !important; }
.chat-ia p { margin: 0; }
.chat-ia .chat-ia-oculto { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* balão que abre o chat: pulsa até a primeira abertura (classe chamando); o ponto pisca sempre */
.chat-ia-abrir { position: relative; display: grid; place-items: center; width: 62px; height: 62px; margin-left: auto; border: 0; border-radius: 50%; background: var(--destaque, #1fd6a4); color: var(--texto-botao, #03231a); cursor: pointer; box-shadow: 0 14px 34px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .08); transition: transform .15s, background .15s; }
.chat-ia-abrir:hover { background: var(--destaque-escuro, #17c093); transform: translateY(-2px); }
.chat-ia-abrir:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.chat-ia-abrir svg { width: 30px; height: 30px; }
.chat-ia-abrir .icone-fechar { display: none; }
.chat-ia.aberto .chat-ia-abrir .icone-chat, .chat-ia.aberto .chat-ia-ponto { display: none; }
.chat-ia.aberto .chat-ia-abrir .icone-fechar { display: block; width: 24px; height: 24px; }
.chat-ia-ponto { position: absolute; top: 5px; right: 5px; width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 3px solid var(--fundo, #020d16); animation: chat-ia-piscar 1.8s ease-in-out infinite; }
.chat-ia.chamando .chat-ia-abrir::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 50%; background: var(--destaque, #1fd6a4); animation: chat-ia-pulso 2.4s ease-out infinite; }
@keyframes chat-ia-pulso { 0% { transform: scale(1); opacity: .55; } 75%, 100% { transform: scale(1.7); opacity: 0; } }
@keyframes chat-ia-piscar { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

/* convite ao lado do balão (só antes da primeira abertura) */
.chat-ia-convite { position: absolute; right: 0; bottom: 76px; width: max-content; max-width: min(260px, calc(100vw - 40px)); background: var(--fundo-3, #0a1c2c); border: 1px solid var(--linha-forte, #2a4560); border-radius: 16px 16px 4px 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, .45); animation: chat-ia-entrar .3s ease-out; }
.chat-ia-convite-abrir { display: block; width: 100%; background: none; border: 0; color: inherit; text-align: left; padding: 12px 38px 12px 14px; font: 500 14px/1.45 var(--corpo, system-ui, sans-serif); cursor: pointer; }
.chat-ia-convite-abrir b { color: var(--destaque, #1fd6a4); }
.chat-ia-convite-fechar { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; color: var(--texto-suave, #9fb0bf); cursor: pointer; font-size: 18px; line-height: 1; }
.chat-ia-convite-fechar:hover { color: var(--texto, #f1f2ed); background: rgba(255, 255, 255, .06); }
@keyframes chat-ia-entrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* painel */
.chat-ia-painel { position: absolute; right: 0; bottom: 78px; display: flex; flex-direction: column; width: 390px; max-width: calc(100vw - 40px); height: min(620px, calc(100vh - 120px)); background: var(--fundo-2, #051421); border: 1px solid var(--linha-forte, #2a4560); border-radius: var(--raio-grande, 18px); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); overflow: hidden; animation: chat-ia-entrar .2s ease-out; }
.chat-ia-topo { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px; background: var(--fundo-3, #0a1c2c); border-bottom: 1px solid var(--linha, #16293a); }
.chat-ia-avatar { position: relative; flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(31, 214, 164, .14); color: var(--destaque, #1fd6a4); }
.chat-ia-avatar svg { width: 24px; height: 24px; }
.chat-ia-avatar::after { content: ''; position: absolute; right: 1px; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: var(--verde, #2fd28a); border: 2px solid var(--fundo-3, #0a1c2c); }
.chat-ia-quem { flex: 1; min-width: 0; line-height: 1.25; }
.chat-ia-titulo { font: 800 16px/1.2 var(--titulo, system-ui, sans-serif); letter-spacing: -0.01em; }
.chat-ia-quem small { display: block; color: var(--texto-suave, #9fb0bf); font-size: 12.5px; margin-top: 2px; }
.chat-ia-acao { flex: none; display: grid; place-items: center; width: 38px; height: 38px; background: none; border: 0; border-radius: 10px; color: var(--texto-suave, #9fb0bf); cursor: pointer; }
.chat-ia-acao:hover { color: var(--texto, #f1f2ed); background: rgba(255, 255, 255, .07); }
.chat-ia-acao:focus-visible, .chat-ia-sugestoes button:focus-visible, .chat-ia-enviar:focus-visible, .chat-ia-convite button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.chat-ia-acao svg { width: 20px; height: 20px; }

.chat-ia-mensagens { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.chat-ia-msg { max-width: 86%; padding: 10px 13px; border-radius: 15px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-ia-msg.assistente { align-self: flex-start; background: var(--fundo-3, #0a1c2c); border: 1px solid var(--linha, #16293a); border-bottom-left-radius: 4px; }
.chat-ia-msg.usuario { align-self: flex-end; background: var(--destaque, #1fd6a4); color: var(--texto-botao, #03231a); border-bottom-right-radius: 4px; }
.chat-ia-msg a { color: var(--destaque, #1fd6a4); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.chat-ia-erro { align-self: center; max-width: 92%; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.45; text-align: center; color: #ffb3b9; background: rgba(255, 92, 106, .1); border: 1px solid rgba(255, 92, 106, .4); }
.chat-ia-digitando { align-self: flex-start; display: inline-flex; gap: 5px; padding: 13px 14px; border-radius: 15px; border-bottom-left-radius: 4px; background: var(--fundo-3, #0a1c2c); border: 1px solid var(--linha, #16293a); }
.chat-ia-digitando span { width: 7px; height: 7px; border-radius: 50%; background: var(--texto-suave, #9fb0bf); animation: chat-ia-piscar 1.2s ease-in-out infinite; }
.chat-ia-digitando span:nth-child(2) { animation-delay: .2s; }
.chat-ia-digitando span:nth-child(3) { animation-delay: .4s; }

.chat-ia-sugestoes { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.chat-ia-sugestoes button { background: transparent; border: 1px solid var(--destaque, #1fd6a4); color: var(--destaque, #1fd6a4); border-radius: 999px; padding: 8px 14px; font: 500 14px/1.2 var(--corpo, system-ui, sans-serif); cursor: pointer; }
.chat-ia-sugestoes button:hover { background: rgba(31, 214, 164, .1); }

.chat-ia-escrever { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--linha, #16293a); }
.chat-ia-escrever textarea { flex: 1; min-width: 0; max-height: 120px; resize: none; background: var(--fundo, #020d16); color: var(--texto, #f1f2ed); border: 1px solid var(--linha-forte, #2a4560); border-radius: 12px; padding: 10px 12px; font: 16px/1.4 var(--corpo, system-ui, sans-serif); }
.chat-ia-escrever textarea::placeholder { color: var(--texto-fraco, #6c8193); }
.chat-ia-escrever textarea:focus { outline: none; border-color: var(--destaque, #1fd6a4); box-shadow: 0 0 0 3px rgba(31, 214, 164, .18); }
.chat-ia-enviar { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--destaque, #1fd6a4); color: var(--texto-botao, #03231a); cursor: pointer; }
.chat-ia-enviar:hover { background: var(--destaque-escuro, #17c093); }
.chat-ia-enviar[disabled] { opacity: .5; cursor: wait; }
.chat-ia-enviar svg { width: 20px; height: 20px; }
.chat-ia-aviso { padding: 0 14px 12px; color: var(--texto-fraco, #6c8193); font-size: 12px; line-height: 1.45; }
.chat-ia-aviso a { color: var(--texto-suave, #9fb0bf); }

/* celular: o painel ocupa a tela toda e a página atrás não rola */
@media (max-width: 600px) {
    .chat-ia { right: 16px; bottom: 16px; }
    .chat-ia.aberto .chat-ia-painel { position: fixed; inset: 0; width: auto; max-width: none; height: 100%; height: 100dvh; border: 0; border-radius: 0; }
    .chat-ia.aberto .chat-ia-abrir { display: none; }
    html.chat-ia-sem-rolagem, html.chat-ia-sem-rolagem body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .chat-ia *, .chat-ia *::before, .chat-ia *::after { animation: none !important; transition: none !important; }
}
