/* ==========================================================================
   CHAT WIDGET — assistente de IA (canto inferior direito).
   Usa as variáveis da marca (variables.css) com fallback. Tema claro/escuro.
   ========================================================================== */
.av-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 240;
  font-family: 'Exo 2', system-ui, sans-serif;
}

/* ── Botão flutuante (FAB) ── */
.av-chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #05121f;
  background: linear-gradient(135deg, var(--electric, #00CFFF), #0a97c9);
  box-shadow: 0 8px 26px rgba(0, 207, 255, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.av-chat-fab svg { width: 27px; height: 27px; }
.av-chat-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 32px rgba(0, 207, 255, 0.55); }
.av-chat-fab::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--green, #00FF99);
  border: 2px solid #05121f;
}
.av-chat.av-open .av-chat-fab { display: none; }

/* ── Painel ── */
.av-chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: min(560px, 76vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(9, 20, 36, 0.97);
  border: 1px solid rgba(0, 207, 255, 0.28);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  animation: avChatIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes avChatIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Cabeçalho ── */
.av-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  background: linear-gradient(120deg, rgba(0, 207, 255, 0.12), rgba(0, 207, 255, 0.02));
  border-bottom: 1px solid rgba(0, 207, 255, 0.18);
}
.av-chat-head-id { display: flex; align-items: center; gap: 11px; }
.av-chat-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 0.82rem; letter-spacing: 1px;
  color: #05121f;
  background: linear-gradient(135deg, var(--electric, #00CFFF), var(--gold, #F0A500));
  flex: 0 0 auto;
}
.av-chat-title {
  font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 1rem;
  color: var(--white, #eaf2fb); line-height: 1.1;
}
.av-chat-status {
  font-family: 'Share Tech Mono', monospace; font-size: 0.58rem; letter-spacing: 0.5px;
  color: var(--green, #00FF99); margin-top: 2px;
}
.av-chat-status::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green, #00FF99); margin-right: 5px; vertical-align: 1px;
}
.av-chat-close {
  border: none; background: transparent; cursor: pointer;
  color: var(--gray, #8FA8C8); width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.av-chat-close svg { width: 18px; height: 18px; }
.av-chat-close:hover { color: var(--white, #fff); background: rgba(255, 255, 255, 0.08); }

/* ── Corpo (mensagens) ── */
.av-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.av-chat-body::-webkit-scrollbar { width: 7px; }
.av-chat-body::-webkit-scrollbar-thumb { background: rgba(0, 207, 255, 0.25); border-radius: 4px; }

.av-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--white, #eaf2fb);
}
.av-msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(0, 207, 255, 0.14);
  border-bottom-left-radius: 4px;
}
.av-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0, 207, 255, 0.9), #0a97c9);
  color: #05121f;
  border-bottom-right-radius: 4px;
}

/* Indicador "digitando" */
.av-typing { display: flex; gap: 4px; align-items: center; }
.av-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--electric, #00CFFF); opacity: 0.5;
  animation: avTyping 1s infinite ease-in-out;
}
.av-typing span:nth-child(2) { animation-delay: 0.15s; }
.av-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes avTyping { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ── Formulário ── */
.av-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(0, 207, 255, 0.16);
  background: rgba(5, 13, 26, 0.5);
}
.av-chat-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 207, 255, 0.2);
  background: rgba(0, 207, 255, 0.05);
  color: var(--white, #eaf2fb);
  font-family: 'Exo 2', sans-serif;
  font-size: 0.9rem;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.av-chat-input::placeholder { color: var(--gray, #8FA8C8); opacity: 0.8; }
.av-chat-input:focus { border-color: var(--electric, #00CFFF); background: rgba(0, 207, 255, 0.09); }
.av-chat-input:disabled { opacity: 0.6; }
.av-chat-send {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #05121f;
  background: linear-gradient(135deg, var(--electric, #00CFFF), #0a97c9);
  transition: transform 0.15s, opacity 0.2s;
}
.av-chat-send svg { width: 20px; height: 20px; }
.av-chat-send:hover { transform: scale(1.06); }
.av-chat-send:disabled { opacity: 0.5; cursor: default; transform: none; }

.av-chat-foot {
  text-align: center;
  padding: 6px 10px 9px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.52rem;
  letter-spacing: 0.5px;
  color: var(--gray, #8FA8C8);
  opacity: 0.7;
  background: rgba(5, 13, 26, 0.5);
}

/* ── Tema claro ── */
body.light-theme .av-chat-panel {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 130, 180, 0.28);
  box-shadow: 0 24px 60px rgba(15, 40, 70, 0.22);
}
body.light-theme .av-chat-title { color: #0a2137; }
body.light-theme .av-chat-head { background: linear-gradient(120deg, rgba(0, 160, 210, 0.12), rgba(0, 160, 210, 0.02)); }
body.light-theme .av-msg { color: #10233a; }
body.light-theme .av-msg-bot { background: rgba(10, 40, 70, 0.05); border-color: rgba(0, 130, 180, 0.18); }
body.light-theme .av-msg-user { color: #05121f; }
body.light-theme .av-chat-input { color: #10233a; background: rgba(0, 130, 180, 0.06); }
body.light-theme .av-chat-input::placeholder { color: #5a748f; }
body.light-theme .av-chat-form,
body.light-theme .av-chat-foot { background: rgba(240, 246, 251, 0.7); }

/* ── Mobile ── */
@media (max-width: 480px) {
  .av-chat { right: 16px; bottom: 16px; }
  .av-chat-panel {
    width: calc(100vw - 24px);
    height: min(72vh, 560px);
  }
  .av-chat-fab { width: 54px; height: 54px; }
}

/* Acessibilidade: sem animações para quem pediu menos movimento */
@media (prefers-reduced-motion: reduce) {
  .av-chat-panel { animation: none; }
  .av-typing span { animation: none; }
  .av-chat-fab, .av-chat-send { transition: none; }
}
