/* ---------------------------------------------------------------------------
   Ravi — painel do assistente de IA.

   O esqueleto (.assistant, .assistant-panel, .bubble, .chip) já vem do
   app.css; aqui entra só o que a conversa com IA trouxe de novo: corpo
   formatado, fontes citadas, bolha de recusa, indicador de digitação e a
   barra com contador. Tudo em variáveis do tema, para acompanhar as
   preferências de aparência de cada pessoa.
   --------------------------------------------------------------------------- */

.assistant-panel {
  width: min(400px, calc(100vw - 40px));
}

.assistant-head {
  gap: 10px;
}
.assistant-head .icon-btn {
  flex: 0 0 30px;
  color: var(--muted);
  border-radius: 9px;
}
.assistant-head .icon-btn:hover {
  color: var(--text);
  background: var(--surface-3);
}

/* ---------- Mensagens ---------- */

.assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble-user {
  align-self: flex-end;
  max-width: 88%;
  color: #fff;
  background: linear-gradient(135deg, var(--personal-accent), var(--personal-accent-ink));
  border-bottom-right-radius: 5px;
}

.bubble-ai {
  align-self: flex-start;
  max-width: 94%;
  border-bottom-left-radius: 5px;
}

/* Recusa de guarda (fora de assunto, injeção, escopo): tom de aviso, sem
   parecer erro de sistema — é o Ravi explicando um limite dele. */
.bubble-ai.is-guarded {
  background: color-mix(in srgb, var(--surface-3) 78%, rgba(210, 150, 40, .3));
  border-left: 2px solid rgba(200, 140, 30, .55);
}

.bubble-body > * + * {
  margin-top: 7px;
}
.bubble-body p {
  margin: 0;
}
.bubble-body strong {
  font-weight: 700;
}
.bubble-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
}

.ravi-list {
  margin: 0;
  padding-left: 17px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ravi-list li {
  padding-left: 1px;
}

.ravi-link {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

/* ---------- Fontes citadas ---------- */

.bubble-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line-2);
}
.bubble-sources-label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.bubble-source {
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.bubble-source.is-link {
  color: var(--accent-strong);
  border-color: rgba(var(--personal-accent-rgb), .32);
  text-decoration: none;
}
.bubble-source.is-link:hover {
  border-color: rgba(var(--personal-accent-rgb), .6);
  background: rgba(var(--personal-accent-rgb), .08);
}

.bubble-handoff {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

/* ---------- "Escrevendo…" ---------- */

.bubble-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 13px 15px;
}
.bubble-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: ravi-typing 1.15s ease-in-out infinite;
}
.bubble-typing span:nth-child(2) { animation-delay: .16s; }
.bubble-typing span:nth-child(3) { animation-delay: .32s; }

@keyframes ravi-typing {
  0%, 62%, 100% { opacity: .28; transform: translateY(0); }
  32%           { opacity: 1;   transform: translateY(-3px); }
}

/* Respeita "reduzir animações" em Aparência: o indicador continua legível,
   só para de pular. */
[data-motion="reduzida"] .bubble-typing span {
  animation: none;
  opacity: .55;
}
@media (prefers-reduced-motion: reduce) {
  .bubble-typing span { animation: none; opacity: .55; }
}

/* ---------- Entrada ---------- */

.assistant-input {
  position: relative;
}
.assistant-counter {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.assistant-input input:disabled {
  opacity: .6;
}

.assistant-panel.is-thinking .assistant-send {
  opacity: .55;
}

/* ---------- Celular ---------- */

@media (max-width: 720px) {
  .assistant-panel { width: auto; }
  .bubble-user { max-width: 92%; }
}
