/* Assistente de IA da doc — bolha flutuante (FAB) + painel de chat, canto
   inferior direito. Usa os mesmos tokens de cor de style.css (--surface,
   --line, --text etc). */

:root {
  --assistant-glass-bg: rgba(20, 20, 20, 0.72);
  /* paleta própria do assistente (azul/ciano, tipo o orbe) — em vez do
     vermelho de marca usado no resto do site */
  --assistant-accent: #2f6fed;
  --assistant-accent-bright: #4a90ff;
  --assistant-accent-soft: #7cc4ff;
}

/* bolinha animada — orbe "gelatinoso" (camadas de brilho + sombra pra dar
   volume, tipo uma bala de goma translúcida) girando tipo o ícone do Meta
   AI, com a logo do site em branco girando junto por cima. */
.assistant-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(80, 140, 255, 0.4), 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 -6px 10px rgba(0, 20, 80, 0.25);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  animation: assistant-jelly 3.2s ease-in-out infinite;
}
.assistant-fab::before {
  content: '';
  position: absolute;
  inset: -25%;
  background: conic-gradient(from 0deg, #e3f6ff, #7cc4ff, #3f7cf0, #a685e2, #63d9d0, #e3f6ff);
  animation: assistant-orb-spin 5s linear infinite;
  filter: saturate(135%);
}
.assistant-fab::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.75), transparent 40%),
    radial-gradient(circle at 75% 80%, rgba(0, 10, 60, 0.35), transparent 55%);
}
.assistant-fab img {
  position: relative;
  z-index: 2;
  width: 38px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 10, 40, 0.45));
  animation: assistant-orb-spin 5s linear infinite;
}
@keyframes assistant-orb-spin { to { transform: rotate(360deg); } }
@keyframes assistant-jelly {
  0%, 100% { border-radius: 50%; }
  50% { border-radius: 46% 54% 55% 45% / 52% 48% 52% 48%; }
}
.assistant-fab:hover { transform: scale(1.08); box-shadow: 0 10px 32px rgba(80, 140, 255, 0.5), 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 -6px 10px rgba(0, 20, 80, 0.25); }
.assistant-fab.hidden { display: none; }

/* camada por trás do painel — igual o .modal-overlay das outras janelas
   do site: borra e escurece a página inteira, e captura o clique (sem
   ela, dava pra clicar/interagir com o que tá por baixo mesmo com o
   assistente aberto). */
.assistant-overlay {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}
.assistant-overlay.open { opacity: 1; pointer-events: auto; }

.assistant-panel {
  position: fixed;
  right: 20px;
  bottom: 86px;
  z-index: 9999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--assistant-glass-bg);
  backdrop-filter: blur(32px) saturate(160%);
  -webkit-backdrop-filter: blur(32px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.assistant-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.assistant-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.assistant-header-title img { width: 22px; height: auto; object-fit: contain; }
.assistant-header-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.assistant-close {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  font-size: 15px; width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}
.assistant-close:hover { background: var(--surface-hover); color: var(--text); }

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assistant-msg { max-width: 90%; font-size: 13px; line-height: 1.55; word-break: break-word; }
.assistant-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--assistant-accent-bright), var(--assistant-accent));
  color: #fff;
  padding: 9px 13px;
  border-radius: 14px 14px 3px 14px;
  white-space: pre-wrap;
}
.assistant-msg-assistant {
  align-self: flex-start;
  background: var(--surface-b);
  border: 1px solid var(--line-soft);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 14px 14px 14px 3px;
}
.assistant-msg-assistant a { color: var(--assistant-accent-bright); }

/* formatação markdown das respostas — ver renderMarkdown() em assistant.js */
.assistant-msg-assistant p { margin: 0 0 8px; }
.assistant-msg-assistant p:last-child { margin-bottom: 0; }
.assistant-msg-assistant strong { color: var(--text); font-weight: 700; }
.assistant-msg-assistant .assistant-heading { display: block; font-size: 13px; margin: 10px 0 6px; }
.assistant-msg-assistant .assistant-heading:first-child { margin-top: 0; }
.assistant-msg-assistant ul, .assistant-msg-assistant ol { margin: 0 0 8px; padding-left: 18px; }
.assistant-msg-assistant li { margin-bottom: 3px; }
.assistant-msg-assistant code {
  background: var(--surface-c); border: 1px solid var(--line-soft); border-radius: 4px;
  padding: 1px 5px; font-family: 'Geist Mono', monospace; font-size: 12px;
}
.assistant-msg-assistant pre.assistant-code {
  background: var(--surface-c); border: 1px solid var(--line-soft); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 0 0 8px;
}
.assistant-msg-assistant pre.assistant-code code {
  background: none; border: none; padding: 0; white-space: pre;
}
.assistant-msg-assistant .assistant-hr { border: none; border-top: 1px solid var(--line-soft); margin: 10px 0; }
.assistant-table-wrap { overflow-x: auto; margin: 0 0 8px; border-radius: 8px; border: 1px solid var(--line-soft); }
.assistant-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.assistant-table th, .assistant-table td { padding: 6px 10px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.assistant-table th { background: var(--surface-c); font-weight: 700; color: var(--text); }
.assistant-table tr:last-child td { border-bottom: none; }

.assistant-msg-error { align-self: center; color: var(--red, #e5484d); font-size: 12px; }
.assistant-typing { align-self: flex-start; display: flex; gap: 4px; padding: 10px 13px; }
.assistant-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint);
  animation: assistant-bounce 1.2s infinite ease-in-out;
}
.assistant-typing span:nth-child(2) { animation-delay: 0.15s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes assistant-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.assistant-empty { text-align: center; color: var(--text-faint); font-size: 12px; padding: 30px 10px; }
.assistant-empty i { font-size: 22px; margin-bottom: 8px; display: block; opacity: 0.6; }

.assistant-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.assistant-input-row textarea {
  flex: 1;
  resize: none;
  height: 38px;
  background: var(--surface-b);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.assistant-input-row textarea:focus { border-color: var(--assistant-accent); }
.assistant-send {
  width: 38px; height: 38px; flex-shrink: 0;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--assistant-accent-bright), var(--assistant-accent));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s var(--ease), opacity 0.2s var(--ease);
}
.assistant-send:hover { background: linear-gradient(135deg, var(--assistant-accent-soft), var(--assistant-accent-bright)); }
.assistant-send:disabled { opacity: 0.5; cursor: default; }

.assistant-attach {
  width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-b);
  color: var(--text-faint);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}
.assistant-attach:hover { border-color: var(--assistant-accent); color: var(--assistant-accent); }

.assistant-attached-files {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 10px;
}

.assistant-file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-b);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 11px;
  color: var(--text);
  max-width: 100%;
}
.assistant-file-chip i.fa-file-code { color: var(--assistant-accent); flex-shrink: 0; }
.assistant-file-remove {
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; display: flex; align-items: center; padding: 0;
  font-size: 11px; margin-left: 2px;
}
.assistant-file-remove:hover { color: var(--text); }

.assistant-msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.assistant-msg-user .assistant-file-chip {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.assistant-msg-user .assistant-file-chip i.fa-file-code { color: #fff; }

@media (max-width: 480px) {
  .assistant-panel {
    right: 12px; left: 12px; width: auto;
    top: 16px; bottom: 78px;
    height: auto; max-height: none;
  }
  .assistant-fab { right: 14px; bottom: 14px; }
}
