/* ─── VermilionAI: animação do chat (#reforma da home) ────────────────
   Só a home usa. Cores e medidas copiadas do VermilionAIChat.vue do RCERP
   (cabeçalho em dois blocos diagonais, bolhas rose-700 e orange-100, selo
   roxo da ferramenta, rodapé gray-50). O HTML traz a conversa completa; o
   script põe .is-anim no <figure> e reproduz passo a passo. */

.vai-col {
  min-width: 0;
}
.vai-col h3 {
  margin-bottom: 8px;
}
.vai-col > p {
  margin: 0;
  color: var(--ink-2);
  font-size: var(--fs-md);
  line-height: 1.55;
}
.vai-col > p strong {
  color: var(--ink);
  font-weight: 500;
}
.vai-demo {
  margin: 20px 0 0;
  width: 100%;
  min-width: 0;
  max-width: 620px;
}
/* Nada aqui dentro pode alargar a página: a caixa corta o eixo X (o clip-margin
   deixa a sombra aparecer) e no celular a altura é fixa, sem aspect-ratio
   (ver o @media de 640px). */
.vai-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  min-height: 440px;
  overflow: hidden;
  overflow: clip;
  overflow-clip-margin: 32px;
  font-family: 'Segoe UI', Inter, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: #111827;
}
.vai-win,
.vai-mail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* Cabeçalho */
.vai-head {
  flex: none;
  display: flex;
  align-items: center;
  background: rgb(191, 25, 61);
  padding: 0.25rem 0.5rem 0.25rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
.vai-slab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: calc(2.5rem - 2px);
  margin: -5px 0;
  padding: 0 1.5rem 0 1rem;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.875rem;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 100%, 0 100%);
  user-select: none;
}
.vai-slab--1 {
  z-index: 2;
  background: rgb(101, 13, 32);
}
.vai-slab--2 {
  z-index: 1;
  margin-left: -14px;
  padding-left: 1.25rem;
  background: rgb(146, 19, 47);
}
.vai-icons {
  margin-left: auto;
  display: flex;
  gap: 12px;
  padding-right: 6px;
}
.vai-icons span {
  display: block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 3px;
}
.vai-icons span:last-child {
  border-radius: 50%;
}

/* Mensagens: a janela tem altura fixa e só o miolo rola. */
.vai-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: none;
}
.vai-body::-webkit-scrollbar {
  display: none;
}
.vai-msg {
  flex: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}
.vai-msg--user {
  align-items: flex-end;
}
.vai-msg--ai {
  align-items: flex-start;
}
.vai-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 0.75rem;
  overflow-wrap: anywhere;
}
.vai-msg--user .vai-bubble {
  background: #be123c;
  color: #ffffff;
  border-bottom-right-radius: 0.25rem;
}
.vai-msg--ai .vai-bubble {
  background: #ffedd5;
  color: #7c2d12;
  border: 1px solid #fdba74;
  border-bottom-left-radius: 0.25rem;
}
.vai-bubble p {
  margin: 0;
}
.vai-bubble p + p,
.vai-bubble p + table,
.vai-bubble p + .vai-prog {
  margin-top: 6px;
}
.vai-bubble b {
  font-weight: 600;
}
.vai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  background: #ffffff;
  color: #111827;
}
.vai-table th,
.vai-table td {
  border: 1px solid #d1d5db;
  padding: 3px 6px;
  text-align: left;
}
.vai-table th {
  background: #f3f4f6;
  font-weight: 600;
}
.vai-table td:nth-child(n + 2),
.vai-table th:nth-child(n + 2) {
  white-space: nowrap;
}
.vai-table td:last-child,
.vai-table th:last-child {
  text-align: right;
}
.vai-table .vai-mais td {
  color: #6b7280;
  text-align: left;
}
.vai-link {
  color: #be123c;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.vai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11px;
  line-height: 1.2;
  background: #faf5ff;
  color: #7e22ce;
  border: 1px solid #e9d5ff;
}
.vai-badge svg {
  width: 8px;
  height: 11px;
  fill: currentColor;
}
.vai-prog {
  width: 200px;
  max-width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #fed7aa;
  overflow: hidden;
}
.vai-prog span {
  display: block;
  width: 100%;
  height: 100%;
  background: #c2410c;
}
.vai-pct {
  font-variant-numeric: tabular-nums;
}
.vai-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  width: min(240px, 85%);
}
.vai-choice {
  display: block;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 0.625rem;
  padding: 10px 14px;
  font-size: 14px;
  color: #374151;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease,
    opacity 0.3s ease;
}
.vai-choice.is-click {
  background: #fff1f2;
  border-color: #fb7185;
}
.vai-choice.is-press {
  transform: scale(0.97);
}
.vai-choices.is-done .vai-choice:not(.is-click) {
  opacity: 0.45;
}

/* Três pontinhos: só existem durante a animação. */
.vai-typing {
  display: none;
}
.vai-typing .vai-bubble {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}
.vai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c2410c;
  animation: vai-dot 1s ease-in-out infinite;
}
.vai-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.vai-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

/* Rodapé com o campo de pergunta */
.vai-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}
.vai-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  color: #9ca3af;
  white-space: nowrap;
  overflow: hidden;
}
.vai-input.has-text {
  color: #111827;
}
.vai-caret {
  display: none;
  width: 1px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -2px;
  background: #111827;
  animation: vai-blink 1s steps(1) infinite;
}
.vai-send {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.vai-send.is-press {
  transform: scale(0.9);
}
.vai-send svg {
  width: 16px;
  height: 16px;
  fill: #ffffff;
}

/* Janela de E-mail (passo 4). Os blocos diagonais do cabeçalho do chat têm
   z-index 1 e 2; sem o isolamento abaixo eles pintavam POR CIMA da janela de
   E-mail e o 2º bloco mostrava "E-mail" com o fim de "VermilionAI" ("E-mail nAI").
   Cada janela vira um contexto de empilhamento próprio e a de E-mail fica acima. */
.vai-win {
  z-index: 0;
  isolation: isolate;
}
/* Com a janela de E-mail já aberta (fim do fade), o chat por baixo some. */
.vai-demo.is-mail .vai-win {
  visibility: hidden;
  transition: visibility 0s linear 0.35s;
}
.vai-mail {
  z-index: 3;
  isolation: isolate;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.98);
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    visibility 0s linear 0.35s;
}
.vai-mail.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease;
}
.vai-mail-list {
  flex: 1;
  overflow: hidden;
}
.vai-mail-row {
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  border-left: 3px solid transparent;
}
.vai-mail-row--new {
  gap: 2px;
  background: #fff1f2;
  border-left-color: #be123c;
}
.vai-mail-from,
.vai-mail-subj {
  font-weight: 700;
  color: #111827;
}
.vai-mail-subj {
  font-weight: 600;
}
.vai-mail-snip {
  color: #4b5563;
  font-size: 14px;
}
.vai-skel {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: #e5e7eb;
}
.vai-mail.is-open .vai-mail-row--new {
  animation: vai-in 0.45s ease-out 0.4s both;
}

/* Estados da animação (só com JS e sem "reduzir movimento") */
.vai-demo.is-anim .vai-msg.is-hidden {
  display: none;
}
.vai-demo.is-anim .vai-msg.is-in {
  animation: vai-in 0.3s ease-out;
}
.vai-demo.is-anim .vai-typing.is-on {
  display: flex;
}
.vai-demo.is-anim .vai-caret.is-on {
  display: inline-block;
}
.vai-demo.is-anim .vai-body {
  overflow-y: hidden;
}

.vai-cap {
  margin-top: 12px;
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: 1.5;
}

@keyframes vai-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes vai-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}
@keyframes vai-blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  /* aspect-ratio + min-height transfere o mínimo de altura para a largura
     (440 × 4/3 = 587px): era isso que dava rolagem lateral em 320px. */
  .vai-stage {
    aspect-ratio: auto;
    height: 460px;
    min-height: 0;
    font-size: 14px;
  }
  .vai-bubble {
    max-width: 92%;
  }
  .vai-table th,
  .vai-table td {
    padding: 3px 4px;
  }
}
/* Telas estreitas: some a coluna Vencimento (todas são de hoje, e a bolha já
   diz "Hoje vencem"); o nome do fornecedor quebra só entre palavras. A bolha da
   tabela ganha largura própria: com largura "do conteúdo" ela encolhia até o
   mínimo da tabela e as palavras partiam no meio ("CEREALIS TA"). */
@media (max-width: 480px) {
  .vai-bubble--tabela {
    width: 100%;
  }
  .vai-table {
    /* auto, não fixed: no fixed o Chrome reserva a largura da coluna escondida (Vencimento) */
    table-layout: auto;
    font-size: 0.76em;
  }
  .vai-table th,
  .vai-table td {
    overflow-wrap: break-word;
    word-break: normal;
  }
  .vai-table th:nth-child(2),
  .vai-table td:nth-child(2) {
    display: none;
  }
  .vai-table th:last-child,
  .vai-table td:last-child {
    width: 34%;
    white-space: nowrap;
  }
  .vai-head {
    min-width: 0;
    overflow: hidden;
  }
  .vai-slab {
    padding: 0 1.1rem 0 0.75rem;
  }
  .vai-slab--2 {
    padding-left: 1rem;
  }
  .vai-icons {
    display: none;
  }
  .vai-mail-row {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}
@media (prefers-reduced-motion: reduce) {
  .vai-typing span,
  .vai-caret {
    animation: none;
  }
}

/* Pausar/Continuar: criado pelo JS, discreto, abaixo da janela. */
.vai-pausa {
  display: block;
  margin: 12px 0 0 auto;
  font: inherit;
  font-family: var(--f-mono, monospace);
  font-size: var(--fs-xs, 12px);
  letter-spacing: 0.04em;
  color: var(--ink-3, #b9a9a8);
  background: none;
  border: 1px solid var(--line-2, rgba(240, 229, 228, 0.2));
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.vai-pausa:hover,
.vai-pausa:focus-visible {
  color: var(--ink, #f0e5e4);
  border-color: var(--ink-3, #b9a9a8);
}
