/* =============================================================
   Portal institucional — assistente virtual (chat da página inicial)
   Marcação em Portal::site/_assistente, comportamento em assistente.js. Cores do tema (Aparência): o botão usa o
   destaque, a janela a primária. Camadas: botão abaixo do aviso de cookies (1040) e janela acima dele, abaixo das
   janelas do Bootstrap (1050+). --ps-rodape-fixo = altura do aviso de cookies enquanto ele aparece (assistente.js).
   ============================================================= */
.ps-assistente[hidden], .ps-assistente [hidden] { display: none !important; }
/* Aparência configurável (Portal::aparenciaAssistente(), no style da raiz): escala da foto e efeito pulsar */
.ps-assistente { --ps-assistente-escala: 1; --ps-assistente-raio: 50%; --ps-assistente-borda: 0px; --ps-assistente-borda-cor: #fff;
    --ps-assistente-pulso-duracao: 1.6s; --ps-assistente-pulso-alcance: 1.25; --ps-assistente-pulso-distancia: 4px; --ps-assistente-pulso-cor: var(--cs-destaque); }
/* A foto fica numa moldura com o formato do botão: ampliada, o excesso é cortado; reduzida, aparece o fundo */
.ps-assistente-moldura { display: block; overflow: hidden; border-radius: 50%; }
.ps-assistente-botao .ps-assistente-botao-foto { border-radius: inherit; }
.ps-assistente-moldura > img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scale(var(--ps-assistente-escala)); }

/* ---------- Botão flutuante ---------- */
.ps-assistente-botao { position: fixed; right: 12px; bottom: calc(var(--ps-rodape-fixo, 0px) + 20px); z-index: 1030; width: 60px; height: 60px;
    display: grid; place-items: center; padding: 0; border: var(--ps-assistente-borda) solid var(--ps-assistente-borda-cor); border-radius: var(--ps-assistente-raio);
    background: var(--cs-destaque); color: #fff;
    box-shadow: 0 6px 20px rgba(15, 30, 48, .28); cursor: pointer; overflow: visible; transition: transform .2s ease, bottom .2s ease; }
.ps-assistente-botao:hover { transform: translateY(-2px); }
.ps-assistente-botao:focus-visible { outline: 3px solid var(--cs-primaria); outline-offset: 3px; }
.ps-assistente-botao-foto { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ps-assistente-botao .ps-assistente-sem-foto { display: grid; place-items: center; font-size: 1.55rem; }
/* Efeito pulsar: dois anéis defasados de meio pulso. Contínuo por padrão; "algumas" = 4 pulsos ao abrir a página.
   Com "reduzir movimento" ligado no sistema, não pulsa (abaixo). */
.ps-assistente-botao::before, .ps-assistente-botao::after { content: ''; position: absolute; border: 2px solid var(--ps-assistente-pulso-cor);
    inset: calc(-1 * (var(--ps-assistente-pulso-distancia) + var(--ps-assistente-borda))); border-radius: var(--ps-assistente-raio); opacity: 0; pointer-events: none; animation: ps-assistente-pulso var(--ps-assistente-pulso-duracao) ease-out infinite; }
.ps-assistente-botao::after { animation-delay: calc(var(--ps-assistente-pulso-duracao) / 2); }
.ps-assistente[data-pulso="algumas"] .ps-assistente-botao::before, .ps-assistente[data-pulso="algumas"] .ps-assistente-botao::after { animation-iteration-count: 4; }
.ps-assistente[data-pulso="desligado"] .ps-assistente-botao::before, .ps-assistente[data-pulso="desligado"] .ps-assistente-botao::after { content: none; }
@keyframes ps-assistente-pulso { 0% { transform: scale(.7); opacity: 0; } 40% { opacity: 1; } 100% { transform: scale(var(--ps-assistente-pulso-alcance)); opacity: 0; } }

/* Chamada ("Posso ajudar?"): ao passar o mouse, com o foco e uma vez sozinha por sessão */
.ps-assistente-chamada { position: absolute; right: -2px; bottom: calc(100% + 14px); width: max-content; max-width: min(260px, calc(100vw - 40px));
    padding: .55rem .85rem; border-radius: 12px; background: var(--c1-dkk); color: #fff; font-size: .88rem; font-weight: 600; line-height: 1.35;
    text-align: left; box-shadow: 0 6px 18px rgba(15, 30, 48, .25); opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease, visibility .25s; pointer-events: none; }
.ps-assistente-chamada::after { content: ''; position: absolute; right: 24px; top: 100%; border: 8px solid transparent; border-top-color: var(--c1-dkk); }
.ps-assistente-botao:hover .ps-assistente-chamada, .ps-assistente-botao:focus-visible .ps-assistente-chamada,
.ps-assistente-chamando .ps-assistente-chamada { opacity: 1; visibility: visible; transform: none; }
.ps-assistente-novidade { position: absolute; top: -3px; right: -3px; width: 18px; height: 18px; border: 3px solid #fff; border-radius: 50%; background: var(--cs-alerta); }

/* "Voltar ao topo" sobe para cima do assistente */
body.ps-com-assistente #btnTopo { bottom: calc(var(--ps-rodape-fixo, 0px) + 94px); }

/* ---------- Janela ---------- */
.ps-assistente-janela { position: fixed; right: 12px; bottom: 20px; z-index: 1045; display: flex; flex-direction: column; overflow: hidden;
    width: min(390px, calc(100vw - 24px)); height: min(620px, calc(100vh - 40px)); height: min(620px, calc(100dvh - 40px));
    background: #fff; border-radius: 18px; box-shadow: 0 18px 50px rgba(15, 30, 48, .32); animation: ps-assistente-entrar .22s ease-out; }
.ps-assistente-janela.ps-assistente-saindo { animation: ps-assistente-sair .18s ease-in forwards; }
@keyframes ps-assistente-entrar { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ps-assistente-sair { to { opacity: 0; transform: translateY(16px) scale(.98); } }

.ps-assistente-topo { display: flex; align-items: center; gap: .7rem; padding: .75rem .6rem .75rem 1rem; color: #fff;
    background: linear-gradient(135deg, var(--cs-primaria), var(--cs-secundaria)); }
.ps-assistente-topo-foto { flex: none; width: 44px; height: 44px; border: 2px solid rgba(255, 255, 255, .75); border-radius: 50%; object-fit: cover; background: var(--cs-destaque); }
.ps-assistente-botao-foto.ps-assistente-moldura { background: var(--cs-destaque); }
.ps-assistente-topo .ps-assistente-sem-foto { display: grid; place-items: center; font-size: 1.15rem; }
.ps-assistente-identidade { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ps-assistente-titulo { margin: 0; color: #fff; font-family: var(--cs-fonte-titulos); font-size: 1.05rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-assistente-identidade > span { font-size: .78rem; opacity: .85; }
.ps-assistente-acao { flex: none; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 1.05rem; }
.ps-assistente-acao:hover { background: rgba(255, 255, 255, .16); }
.ps-assistente-acao:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.ps-assistente-canais { display: flex; flex-wrap: wrap; gap: .4rem; padding: .55rem .8rem; background: var(--c1-xlt); border-bottom: 1px solid #e3e9ef; }
.ps-assistente-canais a { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .75rem; border: 1px solid #d3dee9; border-radius: 999px;
    background: #fff; color: var(--c1-dkk); font-size: .8rem; font-weight: 700; text-decoration: none; }
.ps-assistente-canais a:hover { border-color: var(--cs-primaria); color: var(--cs-primaria); }
.ps-assistente-canais a i { color: #1c9e4b; font-size: .95rem; }

/* ---------- Conversa ---------- */
.ps-assistente-conversa { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .6rem; padding: 1rem .9rem; overflow-y: auto;
    overscroll-behavior: contain; background: #f3f6f9; }
.ps-assistente-conversa:focus-visible { outline: 2px solid var(--cs-primaria); outline-offset: -2px; }

.ps-assistente-msg { max-width: 88%; padding: .6rem .85rem .4rem; border-radius: 16px; font-size: .92rem; line-height: 1.5; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(15, 30, 48, .06); }
.ps-assistente-msg-bot { align-self: flex-start; background: #fff; color: #23303d; border: 1px solid #e1e8ef; border-top-left-radius: 4px; }
.ps-assistente-msg-eu { align-self: flex-end; background: var(--cs-primaria); color: #fff; border-top-right-radius: 4px; }
.ps-assistente-msg p, .ps-assistente-msg ul, .ps-assistente-msg ol, .ps-assistente-msg pre, .ps-assistente-msg blockquote, .ps-assistente-tabela { margin: 0 0 .45rem; }
.ps-assistente-msg ul, .ps-assistente-msg ol { padding-left: 1.2rem; }
.ps-assistente-msg li + li { margin-top: .15rem; }
.ps-assistente-msg a { color: var(--cs-primaria); font-weight: 600; text-decoration: underline; }
.ps-assistente-msg a.ps-assistente-link-externo { text-decoration-style: dotted; }
.ps-assistente-dominio { margin-left: .15rem; padding: 0 .3rem; border-radius: 4px; background: #fff4d6; color: #6b4500; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.ps-assistente-subtitulo { color: var(--c1-dkk); font-weight: 800; }
.ps-assistente-msg code { padding: .05rem .3rem; border-radius: 4px; background: #eef2f6; color: #8a1c46; font-size: .85em; }
.ps-assistente-msg pre { padding: .5rem .6rem; border-radius: 8px; background: #eef2f6; font-size: .8rem; white-space: pre-wrap; }
.ps-assistente-msg pre code { padding: 0; background: none; color: inherit; }
.ps-assistente-msg blockquote { padding-left: .6rem; border-left: 3px solid var(--c1-lt); color: #56626e; }
.ps-assistente-msg hr { margin: .5rem 0; }
.ps-assistente-tabela { overflow-x: auto; }
.ps-assistente-tabela table { border-collapse: collapse; font-size: .82rem; }
.ps-assistente-tabela th, .ps-assistente-tabela td { padding: .25rem .45rem; border: 1px solid #dfe6ee; text-align: left; vertical-align: top; }
.ps-assistente-tabela th { background: #f1f5f9; }
.ps-assistente-hora { display: block; margin-top: .05rem; font-size: .68rem; opacity: .7; text-align: right; }
.ps-assistente-msg-bot .ps-assistente-hora { text-align: left; }
.ps-assistente-msg audio { display: block; width: 230px; max-width: 100%; height: 36px; margin: .1rem 0 .3rem; }
.ps-assistente-audio i { margin-right: .15rem; }

/* Aviso fixo no rodapé da janela, abaixo do campo: não rola com a conversa */
.ps-assistente-nota { flex: none; margin: 0; padding: .1rem .9rem .6rem; background: #fff; color: #5b6774; font-size: .72rem; line-height: 1.4; text-align: center; }
.ps-assistente-nota a { color: inherit; text-decoration: underline; }
.ps-assistente-aviso { align-self: center; max-width: 92%; margin: 0; padding: .45rem .75rem; border: 1px solid #ecd391; border-radius: 10px;
    background: #fff4d6; color: #6b4500; font-size: .8rem; text-align: center; }

.ps-assistente-digitando { align-self: flex-start; display: inline-flex; align-items: center; gap: .22rem; padding: .45rem .8rem; border: 1px solid #e1e8ef;
    border-radius: 14px; background: #fff; color: #56626e; font-size: .8rem; font-weight: 600; }
.ps-assistente-digitando span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: ps-assistente-pontos 1.2s ease-in-out infinite; }
.ps-assistente-digitando span:first-of-type { margin-left: .2rem; }
.ps-assistente-digitando span:nth-of-type(2) { animation-delay: .15s; }
.ps-assistente-digitando span:nth-of-type(3) { animation-delay: .3s; }
@keyframes ps-assistente-pontos { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }

/* ---------- Campo e botões ---------- */
.ps-assistente-rodape { display: flex; align-items: flex-end; gap: .45rem; padding: .65rem .7rem; background: #fff; border-top: 1px solid #e3e9ef; }
.ps-assistente-campo { flex: 1; min-width: 0; max-height: 120px; padding: .55rem .9rem; border: 1px solid #cfd9e3; border-radius: 20px; background: #f8fafc;
    color: #1f2b37; font-size: .92rem; line-height: 1.35; resize: none; overflow-y: hidden; }
.ps-assistente-campo:focus { outline: none; border-color: var(--cs-primaria); background: #fff; box-shadow: 0 0 0 3px color-mix(in srgb, var(--cs-primaria) 22%, transparent); }
.ps-assistente-microfone, .ps-assistente-enviar { flex: none; width: 42px; height: 42px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
    font-size: 1rem; transition: background-color .15s ease, opacity .15s ease; }
.ps-assistente-enviar { background: var(--cs-primaria); color: #fff; }
.ps-assistente-enviar:hover:not(:disabled) { background: var(--c1-dk); }
.ps-assistente-microfone { background: var(--c1-xlt); color: var(--cs-primaria); }
.ps-assistente-microfone:hover:not(:disabled) { background: color-mix(in srgb, var(--cs-primaria) 22%, #fff); }
.ps-assistente-microfone.gravando { background: var(--cs-destaque); color: #fff; animation: ps-assistente-gravar 1.4s ease-in-out infinite; }
.ps-assistente-microfone:focus-visible, .ps-assistente-enviar:focus-visible { outline: 3px solid color-mix(in srgb, var(--cs-primaria) 45%, transparent); outline-offset: 2px; }
.ps-assistente-microfone:disabled, .ps-assistente-enviar:disabled { opacity: .45; cursor: not-allowed; }
@keyframes ps-assistente-gravar { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cs-destaque) 60%, transparent); } 50% { box-shadow: 0 0 0 9px transparent; } }
.ps-assistente-gravando { flex: 1; min-width: 0; min-height: 42px; display: flex; align-items: center; gap: .4rem; padding: 0 .3rem 0 .9rem; border-radius: 20px;
    background: color-mix(in srgb, var(--cs-destaque) 10%, #fff); color: var(--c2-dk); font-size: .88rem; font-weight: 700; }
.ps-assistente-gravando > i { font-size: .55rem; animation: ps-assistente-piscar 1s steps(2, start) infinite; }
@keyframes ps-assistente-piscar { to { visibility: hidden; } }
.ps-assistente-cancelar { margin-left: auto; padding: .3rem .55rem; border: 0; border-radius: 8px; background: none; color: #4d5966; font-size: .8rem; font-weight: 700; text-decoration: underline; }
.ps-assistente-cancelar:focus-visible { outline: 2px solid var(--cs-primaria); }

/* ---------- Telas ---------- */
/* Com o VLibras à direita, a janela abre ao lado do botão dele em vez de por baixo */
@media (min-width: 576px) { .ps-assistente[data-vlibras="R"] .ps-assistente-janela { right: 64px; } }
/* Pouca altura (celular deitado): a janela usa a altura toda */
@media (min-width: 576px) and (max-height: 540px) { .ps-assistente-janela { top: 10px; bottom: 10px; height: auto; } }
/* Celular: tela cheia; o fundo não rola e o botão do VLibras sai da frente enquanto o chat está aberto */
@media (max-width: 575.98px) {
    .ps-assistente-botao { right: 12px; bottom: calc(var(--ps-rodape-fixo, 0px) + 16px); width: 56px; height: 56px; }
    .ps-assistente-janela { inset: 0; width: auto; height: auto; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
    .ps-assistente-msg { max-width: 92%; }
    .ps-assistente-campo { font-size: 16px; } /* 16px evita o zoom automático do iOS ao focar */
    body.ps-assistente-aberto { overflow: hidden; }
    body.ps-assistente-aberto #vlibras-access-wrapper, body.ps-assistente-aberto #btnTopo { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .ps-assistente-botao::before, .ps-assistente-botao::after, .ps-assistente-janela, .ps-assistente-janela.ps-assistente-saindo,
    .ps-assistente-digitando span, .ps-assistente-microfone.gravando, .ps-assistente-gravando > i { animation: none; }
    .ps-assistente-botao, .ps-assistente-chamada { transition: none; }
}

/* ---------- Alto contraste ---------- */
html.a11y-contraste .ps-assistente-janela, html.a11y-contraste .ps-assistente-topo, html.a11y-contraste .ps-assistente-conversa,
html.a11y-contraste .ps-assistente-canais, html.a11y-contraste .ps-assistente-canais a, html.a11y-contraste .ps-assistente-msg,
html.a11y-contraste .ps-assistente-rodape, html.a11y-contraste .ps-assistente-campo, html.a11y-contraste .ps-assistente-aviso,
html.a11y-contraste .ps-assistente-digitando, html.a11y-contraste .ps-assistente-chamada, html.a11y-contraste .ps-assistente-gravando,
html.a11y-contraste .ps-assistente-nota, html.a11y-contraste .ps-assistente-subtitulo { background: #000 !important; color: #fff !important; border-color: #fff !important; }
html.a11y-contraste .ps-assistente-janela, html.a11y-contraste .ps-assistente-msg { border: 1px solid #fff !important; }
html.a11y-contraste .ps-assistente-msg a, html.a11y-contraste .ps-assistente-nota a, html.a11y-contraste .ps-assistente-canais a { color: #ff0 !important; }
html.a11y-contraste .ps-assistente-botao, html.a11y-contraste .ps-assistente-enviar, html.a11y-contraste .ps-assistente-microfone,
html.a11y-contraste .ps-assistente-acao { background: #000 !important; color: #ff0 !important; border: 2px solid #ff0 !important; }

@media print { .ps-assistente { display: none !important; } }
