/* ============================================
   Ana Chat Widget — Digital Scene Library
   Paleta DSL: gold #f4a825 sobre #0a0a0a (combina com a landing).
   ============================================ */

.ana-chat {
  --ana-c1: #f4a825;
  --ana-c2: #d6921f;
  --ana-c1-rgb: 244, 168, 37;
  --ana-c2-rgb: 214, 146, 31;
  --ana-bg: #0a0a0a;
  --ana-bg2: #111111;
  --ana-bg3: #161616;
  --ana-text: #f0f0f0;
  --ana-text2: #888;
  --ana-text3: #555;
}

.ana-chat * { box-sizing: border-box; }

/* ── Launcher (bolha flutuante) ───────────────────────────── */
/* Especificidade .ana-chat .ana-launcher pra superar .landing-body button. */
.ana-chat .ana-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ana-c1) 0%, var(--ana-c2) 100%);
  border: none;
  cursor: pointer;
  z-index: 999999;
  box-shadow: 0 8px 24px rgba(var(--ana-c1-rgb), 0.4),
              0 2px 8px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}
.ana-chat .ana-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(var(--ana-c1-rgb), 0.55),
              0 4px 12px rgba(0, 0, 0, 0.4);
}
.ana-chat .ana-launcher svg {
  width: 32px;
  height: 32px;
  fill: #0a0a0a;
}
.ana-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 2px solid var(--ana-bg);
}

/* ── Janela do chat ───────────────────────────────────────── */
.ana-window {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: var(--ana-bg);
  border: 1px solid rgba(var(--ana-c1-rgb), 0.25);
  border-radius: 18px;
  z-index: 999998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(var(--ana-c1-rgb), 0.08);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.ana-window.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Header ───────────────────────────────────────────────── */
.ana-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--ana-bg2) 0%, var(--ana-bg) 100%);
  border-bottom: 1px solid rgba(var(--ana-c1-rgb), 0.2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.ana-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ana-c1) 0%, var(--ana-c2) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a0a0a;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  border: 2px solid rgba(var(--ana-c2-rgb), 0.4);
}
.ana-header-info { flex: 1; min-width: 0; }
.ana-name {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 2px;
}
.ana-status {
  color: var(--ana-text2);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ana-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}
.ana-chat .ana-close {
  background: none;
  border: none;
  color: var(--ana-text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ana-chat .ana-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.ana-chat .ana-close svg { width: 18px; height: 18px; }

/* ── Mensagens ────────────────────────────────────────────── */
.ana-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(circle at 30% 20%, rgba(var(--ana-c1-rgb), 0.04) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(var(--ana-c1-rgb), 0.03) 0%, transparent 50%),
    var(--ana-bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--ana-c1-rgb), 0.3) transparent;
}
.ana-messages::-webkit-scrollbar { width: 6px; }
.ana-messages::-webkit-scrollbar-thumb {
  background: rgba(var(--ana-c1-rgb), 0.3);
  border-radius: 3px;
}

.ana-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: anaBubbleIn 0.25s ease-out;
}
@keyframes anaBubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ana-bubble a {
  color: var(--ana-c1);
  text-decoration: underline;
  word-break: break-all;
}
.ana-bubble strong { color: var(--ana-c1); font-weight: 700; }
.ana-bubble.assistant {
  align-self: flex-start;
  background: var(--ana-bg2);
  color: var(--ana-text);
  border: 1px solid rgba(var(--ana-c1-rgb), 0.12);
  border-top-left-radius: 4px;
}
.ana-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg,
              rgba(var(--ana-c1-rgb), 0.22) 0%,
              rgba(var(--ana-c2-rgb), 0.14) 100%);
  color: #fff;
  border: 1px solid rgba(var(--ana-c1-rgb), 0.3);
  border-top-right-radius: 4px;
}
.ana-bubble-time {
  font-size: 10px;
  color: var(--ana-text3);
  margin-top: 4px;
  text-align: right;
}

/* ── Typing indicator ─────────────────────────────────────── */
.ana-typing {
  align-self: flex-start;
  background: var(--ana-bg2);
  padding: 12px 16px;
  border-radius: 16px;
  border-top-left-radius: 4px;
  border: 1px solid rgba(var(--ana-c1-rgb), 0.12);
  display: flex;
  gap: 4px;
}
.ana-typing span {
  width: 8px;
  height: 8px;
  background: var(--ana-c1);
  border-radius: 50%;
  animation: anaDot 1.2s infinite ease-in-out;
}
.ana-typing span:nth-child(2) { animation-delay: 0.15s; }
.ana-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes anaDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input ────────────────────────────────────────────────── */
.ana-input-wrap {
  padding: 12px 14px;
  background: var(--ana-bg3);
  border-top: 1px solid rgba(var(--ana-c1-rgb), 0.15);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.ana-input {
  flex: 1;
  background: var(--ana-bg);
  border: 1px solid rgba(var(--ana-c1-rgb), 0.2);
  border-radius: 22px;
  padding: 11px 16px;
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  resize: none;
  max-height: 100px;
  min-height: 42px;
  outline: none;
  transition: border-color 0.15s;
}
.ana-input:focus { border-color: rgba(var(--ana-c1-rgb), 0.5); }
.ana-input::placeholder { color: var(--ana-text3); }
.ana-chat .ana-send {
  background: linear-gradient(135deg, var(--ana-c1) 0%, var(--ana-c2) 100%);
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.ana-chat .ana-send:hover:not(:disabled) { transform: scale(1.06); }
.ana-chat .ana-send:disabled { opacity: 0.4; cursor: not-allowed; }
.ana-chat .ana-send svg { width: 20px; height: 20px; fill: #0a0a0a; }

/* ── Rodapé ───────────────────────────────────────────────── */
.ana-footer {
  padding: 6px 14px 10px;
  background: var(--ana-bg3);
  text-align: center;
  font-size: 10.5px;
  color: var(--ana-text3);
  border-top: 1px solid rgba(var(--ana-c1-rgb), 0.05);
}
.ana-footer strong { color: var(--ana-text2); font-weight: 600; }

/* ── Erro / aviso ─────────────────────────────────────────── */
.ana-error {
  align-self: center;
  background: rgba(231, 76, 60, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(231, 76, 60, 0.3);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  text-align: center;
  max-width: 90%;
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 500px) {
  .ana-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  .ana-launcher {
    bottom: 16px;
    right: 16px;
    width: 58px;
    height: 58px;
  }
  .ana-launcher svg { width: 28px; height: 28px; }
  .ana-chat:has(.ana-window.open) .ana-launcher { display: none; }
}
