/* ============================================================================
   AYIA-TEC · CHAT — acabamento do chat (#/ayia/chat) e do painel lateral (ayia-panel)
   ----------------------------------------------------------------------------
   Arquivo COMPARTILHADO e ADITIVO (2026-11-15). Ver ayia-chat-tec.md.
   Carregado pelo index.html DEPOIS do style.css/modern.css. Remover o <link>
   volta ao visual anterior; nada no layout depende dele.

   Organizacao (para aposentar uma superficie = apagar a secao dela):
     1. Componentes neutros (.ayt-*) — "pensando", rodape de etapas, hairline.
        Sem escopo de superficie: servem a qualquer lista de mensagens.
     2. Encaixe CHAT   — #ayia-resp-root #chatArea / .ayia-dock #inputArea
     3. Encaixe PAINEL — .ayia-panel
     4. prefers-reduced-motion
   Regras da missao AYIA-TEC: neutros Apple, uma familia de fonte, raio 16/10,
   sombra leve SO no claro, foco teal (#0d9488, anel 3px .18). Cor nova so no
   tema claro (body:not(.dark-mode)); no dark muda so a geometria, exceto os
   componentes .ayt-*, que tem tokens proprios para os dois temas.

   ⚠️ O ayia-response.scoped.css/editorial.css sao injetados pelo chat.html DEPOIS
   deste arquivo e usam !important com 1 id. Por isso o encaixe do chat usa 2 ids
   (#ayia-resp-root #chatArea) e !important onde a regra original tem.
   ============================================================================ */

/* ── 1. Componentes neutros ─────────────────────────────────────────────────── */
.ayt-think, .ayt-trail {
  --ayt-tx:   #1d1d1f;
  --ayt-tx2:  #6e6e73;
  --ayt-tx3:  #86868b;
  --ayt-line: rgba(0, 0, 0, .07);
  --ayt-teal: #0d9488;
  --ayt-teal-soft: rgba(13, 148, 136, .12);
  --ayt-skel:    rgba(0, 0, 0, .045);
  --ayt-skel-hi: rgba(0, 0, 0, .09);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
/* Dark: SO onde a superficie de fato escurece (#ayia-resp-root.dark-mode, tokens do scoped).
   `body.dark-mode` sozinho NAO troca: nenhum codigo do portal liga essa classe hoje e o
   painel/cartoes continuam brancos com ela — texto claro sobre branco sumiria (visto no
   teste de navegador de 2026-11-15). */
#ayia-resp-root.dark-mode .ayt-think, #ayia-resp-root.dark-mode .ayt-trail {
  --ayt-tx:   #f5f5f7;
  --ayt-tx2:  #a1a1a6;
  --ayt-tx3:  #86868b;
  --ayt-line: rgba(255, 255, 255, .08);
  --ayt-teal: #5eead4;
  --ayt-teal-soft: rgba(94, 234, 212, .14);
  --ayt-skel:    rgba(255, 255, 255, .05);
  --ayt-skel-hi: rgba(255, 255, 255, .11);
}

/* Host em "pensando": o marcador antigo da superficie (pontinhos, "Gerando SQL · 8s")
   sai de cena — continua no DOM e continua sendo atualizado (o painel le dele). */
.ayt-host > .loading-dots,
.ayt-host > .ayia-dot,
.ayt-host > .ayia-progresso { display: none !important; }
.ayia-msg-loading.ayt-host { display: block; }

.ayt-think { min-width: 240px; max-width: 520px; font-size: 13px; line-height: 1.4; color: var(--ayt-tx2); }
.ayt-think-head { display: flex; align-items: center; gap: 10px; }
.ayt-orb {
  flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ayt-teal);
  animation: ayt-pulso 1.8s ease-in-out infinite;
}
.ayt-think-now {
  color: var(--ayt-tx); font-weight: 500; letter-spacing: -.005em;
  /* brilho que atravessa o rotulo — discreto, so no texto */
  background: linear-gradient(90deg, var(--ayt-tx) 0%, var(--ayt-tx) 38%, var(--ayt-teal) 50%, var(--ayt-tx) 62%, var(--ayt-tx) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ayt-brilho 2.4s linear infinite;
}
.ayt-think-now.ayt-troca { animation: ayt-brilho 2.4s linear infinite, ayt-entra .26s cubic-bezier(.2,.8,.2,1); }
.ayt-think-t { margin-left: auto; padding-left: 12px; font-size: 12px; color: var(--ayt-tx3); white-space: nowrap; }

.ayt-steps { margin: 8px 0 0 3px; padding: 0 0 0 14px; border-left: 1px solid var(--ayt-line); }
.ayt-steps:empty { display: none; }
.ayt-step, .ayt-trail-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 12px; color: var(--ayt-tx2); }
.ayt-step { animation: ayt-entra .26s cubic-bezier(.2,.8,.2,1); }
.ayt-step-ok {
  flex: 0 0 auto; position: relative; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ayt-teal-soft);
}
.ayt-step-ok::after {   /* check desenhado (sem fonte de icone) */
  content: ''; position: absolute; left: 4px; top: 2px; width: 3px; height: 6px;
  border: solid var(--ayt-teal); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.ayt-step-lab { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ayt-step-ms { margin-left: auto; padding-left: 12px; color: var(--ayt-tx3); white-space: nowrap; }

/* 🤖 Selo de agente (2026-11-15): "[icone] Agente X · acao". So em etapa feita por modelo de IA
   (mapa AGENTES no ayia-status-poll.js); etapa sintetica (consultar o banco) fica sem selo. */
.ayt-bot { width: 12px; height: 12px; flex: 0 0 auto; vertical-align: -2px; margin-right: 5px;
  fill: none; stroke: var(--ayt-teal); stroke-width: 1.4; color: var(--ayt-teal); }
.ayt-think-ic:empty { display: none; }
.ayt-think-ic { display: inline-flex; margin-right: -6px; }
.ayt-think-ic .ayt-bot { width: 14px; height: 14px; }
.ayt-think-now { flex: 0 0 auto; }
.ayt-think-acao { margin-left: -8px; color: var(--ayt-tx2); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ayt-think-acao:empty { display: none; }
.ayt-ag { color: var(--ayt-tx); font-weight: 500; }
.ayt-acao { color: var(--ayt-tx3); }

/* Esqueleto com a FORMA da resposta (manchete + 2 linhas) — placeholder, nao conteudo */
.ayt-skel { display: grid; gap: 7px; margin-top: 14px; }
.ayt-skel i {
  display: block; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--ayt-skel) 0%, var(--ayt-skel-hi) 50%, var(--ayt-skel) 100%);
  background-size: 250% 100%;
  animation: ayt-brilho 1.8s linear infinite;
}
.ayt-skel i:nth-child(1) { width: 46%; height: 11px; }
.ayt-skel i:nth-child(2) { width: 92%; }
.ayt-skel i:nth-child(3) { width: 68%; }

/* Rodape "Etapas percorridas" (retroativo; so com etapas que o servidor informou) */
.ayt-trail { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--ayt-line); font-size: 12px; color: var(--ayt-tx3); }
.ayt-trail > summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; width: fit-content; border-radius: 10px; transition: color .15s ease; }
.ayt-trail > summary::-webkit-details-marker { display: none; }
.ayt-trail > summary:hover { color: var(--ayt-teal); }
.ayt-trail > summary:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(13,148,136,.18); }
.ayt-trail-bar { display: flex; gap: 2px; flex: 0 0 64px; width: 64px; height: 4px; }
.ayt-trail-bar i { display: block; min-width: 2px; height: 100%; border-radius: 2px; background: var(--ayt-teal); opacity: .35; }
.ayt-trail-bar i:nth-child(even) { opacity: .6; }
.ayt-trail-txt { white-space: nowrap; }
.ayt-trail-list { margin: 8px 0 0; max-width: 420px; }
.ayt-trail-nota { margin-top: 6px; font-size: 11px; line-height: 1.45; color: var(--ayt-tx3); max-width: 60ch; }

/* Hairline teal no topo do cartao em foco (pensando / ultima resposta) */
.ayt-host, .ayt-ultimo { position: relative; }
.ayt-host::after, .ayt-ultimo::after {
  content: ''; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(13,148,136,.55), transparent);
  pointer-events: none;
}

@keyframes ayt-pulso { 0%, 100% { opacity: .45; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }
@keyframes ayt-brilho { from { background-position: 100% 0; } to { background-position: -150% 0; } }
@keyframes ayt-entra { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── 2. Encaixe CHAT (#/ayia/chat) ──────────────────────────────────────────── */
/* O fadeInUp de .6s do scoped reanimava TODA mensagem a cada replay (abrir conversa
   antiga). A entrada agora e do ayia-chat-motion.js, so na resposta nova. */
#ayia-resp-root #chatArea .msg.assistant .msg-content { animation: none !important; border-radius: 16px !important; }
body:not(.dark-mode) #ayia-resp-root:not(.dark-mode) #chatArea .msg.assistant .msg-content {
  border-color: rgba(0, 0, 0, .06) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04) !important;
}
/* Pergunta: bolha neutra e discreta (estilo Mensagens), sem borda */
#ayia-resp-root #chatArea .msg.user .msg-content { border-radius: 18px 18px 6px 18px !important; }
body:not(.dark-mode) #ayia-resp-root:not(.dark-mode) #chatArea .msg.user .msg-content {
  background: #e8e8ed !important; border-color: transparent !important; color: #1d1d1f !important;
}
/* Proximos passos (<a href="#" data-original-text>) em pilula */
#ayia-resp-root #chatArea .msg-content a[data-original-text] {
  display: inline-flex; align-items: center; padding: 4px 12px; margin: 2px 0;
  border-radius: 999px; border: 0 !important; text-decoration: none !important;
  font-size: 13px; font-weight: 500; line-height: 1.5;
  transition: background-color .15s ease, transform .15s ease;
}
body:not(.dark-mode) #ayia-resp-root:not(.dark-mode) #chatArea .msg-content a[data-original-text] { background: rgba(13,148,136,.08); color: #0a7166 !important; }
body:not(.dark-mode) #ayia-resp-root:not(.dark-mode) #chatArea .msg-content a[data-original-text]:hover { background: rgba(13,148,136,.15); }
#ayia-resp-root #chatArea .msg-content a[data-original-text]:active { transform: scale(.98); }
#ayia-resp-root #chatArea .suggestion-link-wrap { display: inline-block; margin: 4px 6px 0 0; }
/* Linhas de tabela: hover discreto */
body:not(.dark-mode) #ayia-resp-root:not(.dark-mode) #chatArea .msg-content table tbody tr { transition: background-color .12s ease; }
body:not(.dark-mode) #ayia-resp-root:not(.dark-mode) #chatArea .msg-content table tbody tr:hover { background-color: rgba(0,0,0,.025); }

/* Compositor: pilula flutuante de vidro, foco teal */
.ayia-dock #inputArea { border-radius: 22px; transition: border-color .2s ease, box-shadow .2s ease; }
body:not(.dark-mode) .ayia-dock #inputArea {
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-color: rgba(0, 0, 0, .08);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.08);
}
body:not(.dark-mode) .ayia-dock #inputArea:focus-within {
  border-color: rgba(13, 148, 136, .45);
  box-shadow: 0 0 0 3px rgba(13,148,136,.18), 0 8px 28px rgba(0,0,0,.08);
}
.ayia-dock #inputArea textarea { background: transparent; }
.ayia-dock #inputArea #chat-send { border-radius: 999px; padding-left: 1rem; padding-right: 1rem; transition: transform .15s ease, filter .15s ease; }
.ayia-dock #inputArea #chat-send:not(:disabled):active { transform: scale(.97); }

/* ── 3. Encaixe PAINEL (ayia-panel) ─────────────────────────────────────────── */
body:not(.dark-mode) .ayia-panel .ayia-panel-body { background: #f5f5f7; }
.ayia-panel .ayia-panel-body { gap: 10px; }
/* O corpo do painel e flex-column com altura fixa e overflow-y:auto: sem isto a bolha
   ENCOLHE na vertical e o "pensando" (que cresce a cada etapa) vaza para fora do cartao
   (visto em 2026-11-15). A bolha mantem a altura do conteudo; quem rola e o corpo. */
.ayia-panel .ayia-panel-body > .ayia-msg { flex-shrink: 0; }
.ayia-panel .ayia-msg { border-radius: 16px; font-size: 13.5px; line-height: 1.5; }
.ayia-panel .ayia-msg-bot { border-bottom-left-radius: 6px; }
.ayia-panel .ayia-msg-user { border-bottom-right-radius: 6px; }
body:not(.dark-mode) .ayia-panel .ayia-msg-bot:not(.ayia-msg-error):not(.ayia-msg-live) {
  background: #fff; color: #1d1d1f; padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, .06);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
body:not(.dark-mode) .ayia-panel .ayia-msg-user:not(.ayia-msg-live) { background: #e8e8ed; color: #1d1d1f; }
body:not(.dark-mode) .ayia-panel .ayia-msg-bot table.table { border-color: rgba(0,0,0,.06); }
body:not(.dark-mode) .ayia-panel .ayia-msg-bot table.table th { background: #f5f5f7; color: #424245; font-weight: 600; }
body:not(.dark-mode) .ayia-panel .ayia-msg-bot table.table tbody tr:hover { background: rgba(0,0,0,.025); }
.ayia-panel .ayia-msg-bot table.table td, .ayia-panel .ayia-msg-bot table.table th { font-variant-numeric: tabular-nums; }

/* Compositor do painel: grupo vira pilula, foco teal */
.ayia-panel .ayia-panel-footer .input-group > .btn { border-radius: 999px !important; }
body:not(.dark-mode) .ayia-panel .ayia-panel-footer .input-group {
  align-items: center; padding: 3px; gap: 3px; border-radius: 999px; background: #fff;
  border: 1px solid rgba(0, 0, 0, .10);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  transition: border-color .2s ease, box-shadow .2s ease;
}
body:not(.dark-mode) .ayia-panel .ayia-panel-footer .input-group:focus-within {
  border-color: rgba(13, 148, 136, .45);
  box-shadow: 0 0 0 3px rgba(13,148,136,.18);
}
body:not(.dark-mode) .ayia-panel #ayia-input {
  border: 0 !important; background: transparent; box-shadow: none !important; padding-left: 12px;
}

/* ── 4. Movimento reduzido: tudo parado (o conteudo nunca depende da animacao) ── */
@media (prefers-reduced-motion: reduce) {
  .ayt-orb, .ayt-skel i, .ayt-step, .ayt-think-now, .ayt-think-now.ayt-troca { animation: none !important; }
  .ayt-think-now { background: none !important; -webkit-text-fill-color: currentColor !important; color: var(--ayt-tx) !important; }
  #ayia-resp-root #chatArea .msg-content a[data-original-text],
  .ayia-dock #inputArea, .ayia-dock #inputArea #chat-send { transition: none !important; }
}
