/* assistente.css — o chat do Claude do painel (só admin). JS: js/ui/assistente.js.
   Botão flutuante "Claude" no canto inferior direito (acima da nav inferior no celular) e o painel:
   lateral à direita no desktop (>= 768), folha de tela cheia no celular.
   Camadas: nav 40 < botão 45 < folha do app 100 < painel 150 < toast 300 < confirmação 400.
   Com a folha do app aberta o botão sobe pra cima do véu (dá pra mandar o que está nela). */

/* ---------- botão flutuante ---------- */
.assist-fab {
  position: fixed; z-index: 45; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--alvo); padding: 0 14px 0 11px;
  border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface-3); color: var(--text-2);
  font-family: var(--f-text); font-size: var(--t-13); font-weight: 600; line-height: 1;
  box-shadow: var(--fio), var(--sombra-flutua); cursor: pointer; opacity: .9;
  transition: opacity var(--dur-2), color var(--dur-2), border-color var(--dur-2), transform var(--dur-2) var(--ease-mola);
}

.assist-fab:hover { opacity: 1; color: var(--text); border-color: var(--coach-line); }

.assist-fab:active { transform: scale(.96); }

.assist-fab-ico { display: inline-grid; place-items: center; color: var(--coach); }

.assist-fab-ico svg { width: 18px; height: 18px; }

.assist-fab[aria-expanded="true"] { display: none; }

/* folha do app aberta: o botão fica acessível por cima do véu, sem cobrir o rodapé da folha */
body:has(#modal-overlay:not([hidden]):not(.saindo)) .assist-fab { z-index: 150; bottom: calc(var(--safe-b) + 88px); }

/* modo ligação (tela cheia) é trabalho focado: o botão fica atrás */
html.foco-on .assist-fab { display: none; }

@media (min-width: 768px) {
  body:has(#modal-overlay:not([hidden]):not(.saindo)) .assist-fab { bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
}

@media (min-width: 1024px) {
  .assist-fab, body:has(#modal-overlay:not([hidden]):not(.saindo)) .assist-fab { right: 20px; bottom: 20px; }
}

/* ---------- painel ---------- */
.assist-painel {
  position: fixed; z-index: 150; inset: 0;
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  padding-top: var(--safe-t);
  background: var(--surface); color: var(--text);
  animation: assist-sobe var(--dur-3) var(--ease-saida);
}

@keyframes assist-sobe { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@keyframes assist-entra { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 767.98px) { html.assist-aberto body { overflow: hidden; } }

@media (min-width: 768px) {
  .assist-painel {
    left: auto; width: min(420px, 100vw); padding-top: 0;
    border-left: 1px solid var(--line-2); box-shadow: var(--fio), var(--sombra-flutua);
    animation-name: assist-entra;
  }
}

/* print da tela: some por um instante (o quadro é tirado sem ele) */
.assist-painel.assist-capturando, .assist-fab.assist-capturando { visibility: hidden; animation: none; }

.assist-head {
  flex-shrink: 0; padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line); background: var(--surface);
}

.assist-head-linha { display: flex; align-items: center; gap: var(--sp-2); }

.assist-titulo {
  flex: 1; min-width: 0; margin: 0; font-family: var(--f-display); font-size: var(--t-18); font-weight: 700; line-height: 1.25;
}

.assist-nova { flex: none; }

.assist-nova svg { width: 16px; height: 16px; }

/* celular estreito: sem o ícone, o título cabe numa linha */
@media (max-width: 420px) { .assist-nova svg { display: none; } .assist-nova { padding: 8px 10px; } }

.assist-sub { margin: 6px 0 0; font-size: var(--t-12); line-height: 1.45; color: var(--text-3); }

/* ---------- mensagens ---------- */
.assist-lista {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4);
}

.assist-vazio { margin: auto 0; text-align: center; color: var(--text-3); font-size: var(--t-14); line-height: 1.5; padding: 0 var(--sp-4); }

.assist-msg { display: flex; flex-direction: column; gap: 4px; max-width: 92%; }

.assist-bolha {
  padding: 10px 13px; border-radius: var(--r); font-size: var(--t-14); line-height: 1.5;
  overflow-wrap: anywhere; border: 1px solid var(--line);
}

.assist-pedro { align-self: flex-end; align-items: flex-end; }

.assist-pedro .assist-bolha { white-space: pre-wrap; background: var(--accent-soft); border-color: var(--accent-line); border-bottom-right-radius: var(--r-xs); }

.assist-claude { align-self: flex-start; }

.assist-claude .assist-bolha { background: var(--surface-2); border-bottom-left-radius: var(--r-xs); }

.assist-bolha code {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace; font-size: .9em;
  padding: 1px 5px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line);
}

.assist-pre {
  margin: 8px 0; padding: 10px 12px; max-width: 100%; overflow-x: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: var(--t-12); line-height: 1.5; white-space: pre;
}

.assist-pre code { padding: 0; border: 0; background: none; font-size: inherit; }

.assist-meta { margin: 0; font-size: var(--t-12); color: var(--text-3); }

.assist-estado { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }

.assist-estado-tx { margin: 0; font-size: var(--t-12); font-weight: 600; color: var(--text-3); }

.assist-estado.est-nova .assist-estado-tx::before,
.assist-estado.est-trabalhando .assist-estado-tx::before {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%;
  background: var(--warn); vertical-align: 1px; animation: assist-pisca 1.2s ease-in-out infinite;
}

.assist-estado.est-trabalhando .assist-estado-tx { color: var(--coach); }

.assist-estado.est-trabalhando .assist-estado-tx::before { background: var(--coach); }

.assist-estado.est-erro .assist-estado-tx { color: var(--danger); }

@keyframes assist-pisca { 50% { opacity: .3; } }

.assist-progresso { margin: 0; font-size: var(--t-12); line-height: 1.4; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- pedido de publicar (msg 'sistema') ---------- */
.assist-sistema { align-self: stretch; max-width: none; }

.assist-card {
  display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-card); background: var(--surface-2); border: 1px solid var(--warn-line); box-shadow: var(--fio);
}

.assist-card-rot { margin: 0; font-size: var(--t-12); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--warn); }

.assist-card-tx { font-size: var(--t-14); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

.assist-card-acoes { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: 2px; }

.assist-card-estado { margin: 0; font-size: var(--t-13); font-weight: 600; color: var(--text-2); }

.assist-sistema.est-aprovada .assist-card, .assist-sistema.est-publicando .assist-card { border-color: var(--coach-line); }

.assist-sistema.est-publicada .assist-card { border-color: var(--primary-line); }

.assist-sistema.est-publicada .assist-card-estado { color: var(--primary); }

.assist-sistema.est-cancelada .assist-card { border-color: var(--line); }

.assist-sistema.est-cancelada .assist-card-rot { color: var(--text-3); }

.assist-sistema.est-erro .assist-card { border-color: var(--danger-line); }

.assist-sistema.est-erro .assist-card-estado { color: var(--danger); }

/* ---------- campo e envio ---------- */
.assist-form {
  flex-shrink: 0; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-b));
  border-top: 1px solid var(--line); background: var(--surface);
}

.assist-campo {
  width: 100%; min-height: 76px; max-height: 40vh; padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text); font-size: var(--t-16); line-height: 1.45; outline: none;
}

@media (min-width: 768px) { .assist-campo { font-size: var(--t-14); } }

.assist-barra { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); }

.assist-ctx { flex: 1 1 auto; display: inline-flex; align-items: center; gap: 8px; min-height: var(--alvo); font-size: var(--t-13); color: var(--text-2); cursor: pointer; }

.assist-ctx input { flex: none; }

.assist-barra-dir { display: inline-flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.assist-print svg { width: 16px; height: 16px; }

.assist-enviar { min-width: 88px; }

.assist-anexo { display: flex; align-items: center; gap: var(--sp-3); padding: 6px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }

.assist-anexo-img { width: 72px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg); }

.assist-anexo-tx { flex: 1; min-width: 0; font-size: var(--t-13); color: var(--text-2); }

.assist-aviso { margin: 0; min-height: 0; font-size: var(--t-12); line-height: 1.4; color: var(--text-3); }

.assist-aviso:empty { display: none; }

.assist-aviso[data-tipo="erro"] { color: var(--danger); }
