/* Eva: base styles. Tokens first; dark mode redefines them (07, section 9). */
:root {
  --fundo: #f6f7f9;
  --superficie: #ffffff;
  --texto: #1b1f24;
  --texto-suave: #4b5563;
  --borda: #c9ced6;
  --primaria: #1f5fbf;
  --primaria-texto: #ffffff;
  --primaria-hover: #194f9f;
  --foco: #f5b400;
  --erro: #b42318;
  --erro-fundo: #fdecea;
  --demora-fundo: #fff7e0;
  --balao-entrada: #ffffff;
  --balao-saida: #e3edfb;
  --destaque-fundo: #eef3fb;
  --esqueleto: #e4e7ec;
  --raio: 10px;
  --duracao: 200ms;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #111418;
    --superficie: #1b2027;
    --texto: #eef1f5;
    --texto-suave: #b4bcc8;
    --borda: #3b4452;
    --primaria: #7fb0ff;
    --primaria-texto: #0b1424;
    --primaria-hover: #a3c6ff;
    --erro: #ff9b8f;
    --erro-fundo: #3a1a17;
    --demora-fundo: #3a3016;
    --balao-entrada: #1b2027;
    --balao-saida: #1d2f4a;
    --destaque-fundo: #1a2433;
    --esqueleto: #2a313b;
  }
}

* { box-sizing: border-box; }

/* `hidden` hides only through the browser's display:none, which any class with its own
   display (flex, inline-block) silently beats. Found in the F2 screenshots (19/11). */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--fundo);
  color: var(--texto);
}

main { padding: 24px 16px; outline: none; }

.pular {
  position: absolute;
  left: -9999px;
}
.pular:focus {
  left: 16px; top: 8px; z-index: 10;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  background: var(--superficie);
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.cartao {
  max-width: 420px;
  margin: 8vh auto 0;
  padding: 28px 24px;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
}
.cartao.largo { max-width: 720px; margin-top: 32px; }

.marca { font-weight: 700; letter-spacing: 0.04em; color: var(--primaria); margin: 0 0 8px; }

h1 { font-size: 1.5rem; margin: 0 0 8px; line-height: 1.25; outline: none; }

.apoio { color: var(--texto-suave); margin: 0 0 20px; }

.campo { margin-bottom: 16px; }

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="email"], input[type="password"], input[type="text"], input[type="search"], textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--texto);
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 8px;
}
input.codigo { font-size: 1.5rem; letter-spacing: 0.4em; font-variant-numeric: tabular-nums; }

input[aria-invalid="true"] { border: 2px solid var(--erro); }

:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }

.com-acao { display: flex; gap: 8px; }
.com-acao input { flex: 1; }

.erro-campo, .aviso-erro {
  color: var(--erro);
  margin: 6px 0 0;
}
/* Never color alone: an icon and the word carry the state too. */
.erro-campo::before, .aviso-erro > p::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.25em;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 0.8em;
  font-weight: 700;
  vertical-align: 0.1em;
}

.aviso {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 16px;
}
.aviso p { margin: 0 0 6px; }
.aviso-erro { background: var(--erro-fundo); }
.aviso-demora { background: var(--demora-fundo); margin-top: 16px; }

.botao, .botao-texto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.botao {
  width: 100%;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  background: var(--primaria);
  color: var(--primaria-texto);
  transition: background-color var(--duracao) ease;
}
.botao:hover { background: var(--primaria-hover); }
.botao-texto {
  padding: 8px 10px;
  border: 0;
  background: none;
  color: var(--primaria);
  text-decoration: underline;
}
[aria-disabled="true"] { cursor: not-allowed; opacity: 0.75; }

.acoes-secundarias { display: flex; flex-wrap: wrap; justify-content: space-between; margin-top: 12px; }

.status { min-height: 1.5em; margin: 8px 0 0; color: var(--texto-suave); }

.opcoes { border: 0; padding: 0; margin: 0 0 12px; }
.opcao {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-weight: 400;
  cursor: pointer;
}
.opcao input { width: 20px; height: 20px; }
.opcao span { display: flex; flex-direction: column; }
.opcao small { color: var(--texto-suave); }
.opcao:has(input:checked) { border: 2px solid var(--primaria); }

.giro {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: girar 800ms linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.topo {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
}
.topo .quem { margin-left: auto; color: var(--texto-suave); }

.rodape { margin-top: 20px; font-size: 0.875rem; color: var(--texto-suave); }

/* Reduced motion: the spinner stops (the button text already says "Entrando…"). */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .giro { border-right-color: currentColor; opacity: 0.5; }
}

/* ---- F2: inbox and conversation ------------------------------------------------ */

.topo nav a, .link-topo { color: var(--primaria); min-height: 44px; display: inline-flex; align-items: center; }
.link-topo[aria-current="page"] { font-weight: 700; text-decoration-thickness: 2px; }
.aviso-topo { margin: 8px 16px 0; }

.pagina-larga { max-width: 860px; margin: 0 auto; }
.apoio-curto { color: var(--texto-suave); margin: 4px 0 0; font-size: 0.9375rem; }
textarea { resize: vertical; line-height: 1.5; }

.busca { margin: 12px 0 16px; }

.abas { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; border-bottom: 1px solid var(--borda); }
.abas a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px;
  color: var(--texto-suave); text-decoration: none; border-bottom: 3px solid transparent;
}
.abas a[aria-current="page"] { color: var(--texto); font-weight: 700; border-bottom-color: var(--primaria); }

.lista-conversas, .lista-simples, .mensagens { list-style: none; margin: 0; padding: 0; }
.lista-simples li { margin: 4px 0; }
.lista-simples a { display: inline-flex; min-height: 44px; align-items: center; color: var(--primaria); }

.item-conversa {
  display: flex; flex-direction: column; gap: 4px; padding: 12px; min-height: 64px;
  color: var(--texto); text-decoration: none; border-bottom: 1px solid var(--borda);
  background: var(--superficie);
}
.item-conversa:hover { background: var(--destaque-fundo); }
.item-conversa.tem-novidade .nome { font-weight: 800; }
.item-linha { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hora { color: var(--texto-suave); font-size: 0.875rem; white-space: nowrap; }
.trecho {
  color: var(--texto-suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.nao-lidas {
  flex: none; padding: 2px 8px; border-radius: 999px; font-size: 0.8125rem; font-weight: 700;
  background: var(--primaria); color: var(--primaria-texto);
}
.selos { display: flex; flex-wrap: wrap; gap: 6px; }
.selo {
  display: inline-block; padding: 1px 8px; border: 1px solid var(--borda); border-radius: 999px;
  font-size: 0.8125rem; color: var(--texto-suave);
}
.selo[data-estado="aberta"] { border-color: var(--primaria); color: var(--texto); font-weight: 600; }

.vazio { padding: 24px 12px; color: var(--texto-suave); }
.botao-secundario { background: var(--superficie); color: var(--primaria); border: 1px solid var(--primaria); margin-top: 12px; }
.botao-secundario:hover { background: var(--destaque-fundo); }

/* Skeleton: same shape as the real row, so nothing jumps when data arrives. */
.esqueleto { display: flex; flex-direction: column; gap: 10px; padding: 16px 12px; min-height: 64px; border-bottom: 1px solid var(--borda); }
.barra { display: block; height: 12px; border-radius: 6px; background: var(--esqueleto); animation: pulsar 1.2s ease-in-out infinite; }
.barra-curta { width: 40%; }
@keyframes pulsar { 50% { opacity: 0.45; } }

.voltar { display: inline-flex; align-items: center; min-height: 44px; color: var(--primaria); }
.cabeca-conversa { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 8px 0 12px; }
.cabeca-conversa h1 { margin: 0; }
.acoes { margin-left: auto; display: flex; gap: 4px; }

.regiao-mensagens { padding: 8px 0 16px; }
.mensagens { display: flex; flex-direction: column; gap: 8px; }
.mensagem {
  max-width: min(80%, 560px); padding: 8px 12px; border-radius: 12px; border: 1px solid var(--borda);
  background: var(--balao-entrada);
}
.mensagem-saida { align-self: flex-end; background: var(--balao-saida); }
.mensagem .texto { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.mensagem .meta { margin: 4px 0 0; font-size: 0.8125rem; color: var(--texto-suave); }
.mensagem .autor { font-weight: 600; }
.status-msg[data-status="falhou"], .status-msg[data-status="incerta"] { color: var(--erro); font-weight: 600; }
.status-msg[data-status="falhou"]::before, .status-msg[data-status="incerta"]::before { content: "! "; }
.conferir { margin-top: 8px; border-top: 1px solid var(--borda); padding-top: 6px; }
.conferir p { margin: 0 0 4px; }
.esqueleto-mensagem { border: 0; max-width: 60%; }

.botao-novas {
  position: sticky; bottom: 12px; margin: 0 auto; display: flex;
  background: var(--superficie); border: 1px solid var(--primaria); border-radius: 999px;
}

.compositor {
  position: sticky; bottom: 0; background: var(--fundo); padding: 12px 0 8px;
  border-top: 1px solid var(--borda);
}
.compositor textarea { min-height: 88px; }
.compositor-rodape { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.botao-enviar { width: auto; min-width: 120px; }

@media (prefers-reduced-motion: reduce) {
  .barra { animation: none; opacity: 0.7; }
}
