/* Atendente NDR Educação — balão "Dúvidas?". Mesmo balão do site da NDR, com as cores e a fonte da NDR Educação
 * (variáveis do tema em globals.css, com valores de reserva). */
.atd {
  --atd-navy: var(--color-marinho, #0b1f44);
  --atd-blue: var(--color-azul, #0a6cd6);
  --atd-teal: var(--color-agua-claro, #2fbfa7);
  --atd-ink: var(--color-tinta, #1d2738);
  --atd-text: var(--color-texto, #556074);
  --atd-line: var(--color-linha, #e3e9f2);
  --atd-soft: var(--color-suave, #f4f8fc);
  --atd-fonte: var(--font-jakarta), "Segoe UI", Roboto, Arial, sans-serif;
  --atd-base: calc(16px + env(safe-area-inset-bottom, 0px));
  font: 400 0.97rem/1.55 var(--atd-fonte);
  color: var(--atd-text);
}
.atd *, .atd *::before, .atd *::after { box-sizing: border-box; }
.atd svg { display: block; }
.atd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Botão flutuante no canto inferior direito */
.atd-botao {
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: var(--atd-base); z-index: 21;
  display: inline-flex; align-items: center; gap: 0.5rem; height: 54px; min-width: 54px; padding: 0 1.15rem 0 0.95rem;
  border: 0; border-radius: 27px; background: var(--atd-navy); color: #FFFFFF; cursor: pointer;
  font: 800 0.95rem/1 var(--atd-fonte); box-shadow: 0 14px 30px rgba(11, 31, 68, 0.32);
  transition: transform .15s ease, box-shadow .15s ease;
}
.atd-botao svg { width: 26px; height: 26px; flex: none; }
.atd-botao:hover { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(11, 31, 68, 0.38); }
.atd-botao:focus-visible, .atd button:focus-visible, .atd a:focus-visible, .atd textarea:focus-visible, .atd-msgs:focus-visible { outline: 3px solid var(--atd-teal); outline-offset: 3px; }
.atd-aberto .atd-botao { visibility: hidden; }

/* Painel */
.atd-painel {
  position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: var(--atd-base); z-index: 2147483600;
  width: 384px; height: min(640px, calc(100vh - 32px)); height: min(640px, calc(100dvh - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #FFFFFF; border: 1px solid var(--atd-line); border-radius: 20px;
  box-shadow: 0 24px 60px rgba(6, 26, 44, 0.28);
  isolation: isolate; opacity: 1;
  animation: atd-entra .18s ease-out;
}
.atd-painel[hidden] { display: none; }
@keyframes atd-entra { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.atd-topo { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 0.9rem 0.9rem 1rem; background: linear-gradient(120deg, var(--color-marinho, #0b1f44), var(--color-marinho-2, #12306a)); color: #FFFFFF; }
.atd-marca { width: 40px; height: 40px; border-radius: 12px; background: rgba(47, 191, 167, 0.18); color: var(--atd-teal); display: grid; place-items: center; flex: none; }
.atd-marca svg { width: 24px; height: 24px; }
.atd-titulos { flex: 1; min-width: 0; }
.atd-titulos h2 { margin: 0; font: 900 1.05rem/1.2 var(--atd-fonte); color: #FFFFFF; }
.atd-titulos p { margin: 0.15rem 0 0; font-size: 0.8rem; color: rgba(255, 255, 255, 0.78); }
.atd-demo .atd-titulos p::after { content: " · demonstração"; color: #FFD27A; font-weight: 800; }
.atd-fechar { width: 40px; height: 40px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.1); color: #FFFFFF; cursor: pointer; display: grid; place-items: center; flex: none; }
.atd-fechar:hover { background: rgba(255, 255, 255, 0.2); }
/* "Nova conversa": logo acima do campo de pergunta */
.atd-acoes { display: flex; justify-content: flex-end; padding: 0.35rem 0.75rem 0; border-top: 1px solid var(--atd-line); background: #FFFFFF; }
.atd-nova { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 32px; padding: 0.3rem 0.6rem; border: 0; border-radius: 10px; background: transparent; color: var(--atd-navy); cursor: pointer; font: 800 0.82rem/1 var(--atd-fonte); }
.atd-nova svg { width: 16px; height: 16px; }
.atd-nova:hover { background: var(--atd-soft); }
.atd-nova:disabled { opacity: .45; cursor: wait; }
.atd-fechar svg { width: 20px; height: 20px; }

.atd-aviso { margin: 0; padding: 0.55rem 1rem; font-size: 0.78rem; line-height: 1.4; background: var(--atd-soft); border-bottom: 1px solid var(--atd-line); color: var(--atd-text); }
.atd-aviso a { color: var(--atd-navy); font-weight: 800; }

.atd-msgs { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; overscroll-behavior: contain; background: #FFFFFF; }
.atd-m { max-width: 88%; padding: 0.6rem 0.85rem; border-radius: 16px; word-wrap: break-word; overflow-wrap: anywhere; }
.atd-atendente { align-self: flex-start; background: var(--atd-soft); color: var(--atd-ink); border: 1px solid var(--atd-line); border-bottom-left-radius: 6px; }
.atd-visitante { align-self: flex-end; background: var(--atd-navy); color: #FFFFFF; border-bottom-right-radius: 6px; }
.atd-m a { color: var(--atd-blue); font-weight: 800; }
.atd-m strong { color: var(--atd-ink); font-weight: 800; }

.atd-pontos { display: inline-flex; gap: 4px; padding: 0.2rem 0; }
.atd-pontos i { width: 7px; height: 7px; border-radius: 50%; background: var(--atd-blue); opacity: .35; animation: atd-ponto 1s infinite ease-in-out; }
.atd-pontos i:nth-child(2) { animation-delay: .15s; }
.atd-pontos i:nth-child(3) { animation-delay: .3s; }
@keyframes atd-ponto { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

.atd-sugs { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 1rem 0.75rem; }
.atd-sugs[hidden] { display: none; }
.atd-sug { border: 1.5px solid var(--atd-line); background: #FFFFFF; color: var(--atd-navy); border-radius: 999px; padding: 0.45rem 0.8rem; font: 700 0.84rem/1.2 var(--atd-fonte); cursor: pointer; text-align: left; }
.atd-sug:hover { border-color: var(--atd-navy); }

.atd-form { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.4rem 0.75rem 0.75rem; background: #FFFFFF; }
.atd-form textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 0.65rem 0.8rem; border: 1.5px solid var(--atd-line); border-radius: 14px; font: 400 1rem/1.4 var(--atd-fonte); color: var(--atd-ink); background: #FFFFFF; }
.atd-form textarea:focus { border-color: var(--atd-blue); outline: none; }
.atd-enviar { width: 44px; height: 44px; flex: none; border: 0; border-radius: 14px; background: var(--atd-navy); color: #FFFFFF; cursor: pointer; display: grid; place-items: center; }
.atd-enviar svg { width: 20px; height: 20px; }
.atd-enviar:disabled { opacity: .5; cursor: wait; }

.atd-turnstile { display: flex; justify-content: center; padding: 0 0.75rem 0.6rem; background: #FFFFFF; }
.atd-turnstile:empty { display: none; }

/* Celular: o painel ocupa a tela toda e o botão vira só o ícone */
@media (max-width: 560px) {
  .atd-botao { padding: 0; width: 56px; height: 56px; justify-content: center; border-radius: 50%; }
  .atd-botao-rotulo { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  /* tela cheia, fundo opaco, acima do cabeçalho do site e de qualquer outro elemento */
  .atd-painel {
    position: fixed; inset: 0; width: auto; height: auto; max-height: none;
    z-index: 2147483600; background: #FFFFFF; border-radius: 0; border: 0; box-shadow: none;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: none; /* sem transparência na abertura: o painel cobre a página de uma vez */
  }
  .atd-topo { background: var(--color-marinho, #0b1f44); }
  html.atd-aberto-pagina, html.atd-aberto-pagina body { overflow: hidden; }
  /* enquanto o painel está aberto, o botão do atendente some */
  html.atd-aberto-pagina .atd-botao { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .atd-painel, .atd-pontos i { animation: none; }
  .atd-botao, .atd-botao:hover { transition: none; transform: none; }
}

@media print { .atd { display: none; } }

/* Painel e área do professor: o balão não aparece (BalaoAtendente.tsx marca a página) */
html[data-atendente="oculto"] .atd { display: none; }
