/* ============================================================
   Tema — mesmas cores base do design de referência
   ============================================================ */
:root {
  --background: #080808;
  --surface: #161616;
  --divider: rgba(245, 245, 245, 0.14);
  --foreground: #f5f5f5;

  --accent-100: #f7fae5;
  --accent-200: #eaf2c2;
  --accent-300: #dce69b;
  --accent-400: #d2e080;
  --accent-500: #c8d96a;
  --accent-600: #a8ba4e;
  --accent-700: #86963a;

  --neutral-100: #f5f5f5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-600: #525252;

  --gray-500: #6a7282;
  --gray-700: #364153;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* Link "pular para o conteúdo" (acessibilidade) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 1rem;
  z-index: 60;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  background: var(--accent-500);
  color: #000;
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
}
.skip-link:focus { left: 1rem; }

/* ============================================================
   Layout geral
   ============================================================ */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Header
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--divider);
  background: rgba(8, 8, 8, 0.95);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}

.header-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  flex-shrink: 0;
  text-decoration: none;
  transition: opacity 0.15s;
}
.brand:hover { opacity: 0.8; }

.brand-logo { width: 2rem; height: 2rem; object-fit: contain; flex-shrink: 0; }

.brand-name {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--neutral-100);
  white-space: nowrap;
}
.brand-name .accent { color: var(--accent-500); }

.brand-tagline {
  font-size: 0.875rem;
  color: var(--neutral-400);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* ============================================================
   Botões
   ============================================================ */
.btn {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
  white-space: nowrap;
  background: transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-accent {
  color: var(--accent-500);
  border: 1px solid rgba(200, 217, 106, 0.35);
  background: rgba(200, 217, 106, 0.05);
}
.btn-accent:hover { border-color: rgba(200, 217, 106, 0.6); }

.btn-ghost {
  color: var(--neutral-400);
  border: 1px solid var(--divider);
}
.btn-ghost:hover { color: var(--neutral-100); border-color: var(--neutral-600); }

.btn-icon { padding: 0.5rem; }

.icon { width: 0.875rem; height: 0.875rem; }
.icon-lg { width: 1rem; height: 1rem; }

/* Menu dropdown */
.menu-wrap { position: relative; }
.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.375rem);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 0.625rem;
  padding: 0.375rem;
  min-width: 11rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  z-index: 50;
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--neutral-300);
  font-size: 0.875rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.375rem;
  cursor: pointer;
}
.menu-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--neutral-100); }

/* ============================================================
   Área do chat
   ============================================================ */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
}

.chat-inner {
  max-width: 48rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: fade-in-up 0.3s ease both;
}

.msg-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
  overflow: hidden;
}
.msg-avatar img { width: 1.25rem; height: 1.25rem; object-fit: contain; }

.msg-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg-bubble {
  background: var(--surface);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--neutral-300);
  max-width: 560px;
}
.msg-bubble p + p { margin-top: 0.5rem; }
.msg-bubble strong { color: var(--neutral-100); }
.msg-bubble .cite {
  display: block;
  margin-top: 0.625rem;
  font-size: 0.75rem;
  color: var(--accent-400);
}

/* Mensagem do usuário */
.msg-user { flex-direction: row-reverse; }
.msg-user .msg-body { align-items: flex-end; }
.msg-user .msg-bubble {
  background: rgba(200, 217, 106, 0.12);
  border: 1px solid rgba(200, 217, 106, 0.25);
  color: var(--neutral-100);
}

/* Indicador "digitando" */
.typing { display: inline-flex; gap: 0.3rem; padding: 0.35rem 0; }
.typing span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--neutral-500);
  animation: typing-blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* Sugestões dentro do chat */
.suggestions { display: flex; flex-direction: column; gap: 0.5rem; max-width: 560px; }
.suggestions-label { font-size: 0.875rem; color: var(--gray-500); }
.pill-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.pill {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--divider);
  color: var(--neutral-300);
  background: transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.pill:hover { border-color: var(--accent-500); color: var(--accent-300); }

.pill-featured {
  border-color: rgba(200, 217, 106, 0.4);
  color: var(--accent-300);
}
.pill-featured:hover { border-color: rgba(200, 217, 106, 0.7); color: var(--accent-200); }
.pill-featured .icon { width: 0.875rem; height: 0.875rem; }

.pill-dot {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

/* ============================================================
   Barra inferior (composer)
   ============================================================ */
.composer {
  border-top: 1px solid var(--divider);
  background: rgba(8, 8, 8, 0.95);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}

.composer-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.75rem 1rem 1rem;
}

.quick-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scrollbar-width: none;
}
.quick-pills::-webkit-scrollbar { display: none; }
.quick-pills .pill { flex-shrink: 0; color: var(--neutral-400); }
.quick-pills .pill:hover { border-color: var(--accent-500); color: var(--neutral-200); }

.input-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 9999px;
  padding: 0.5rem;
  transition: border-color 0.15s;
}
.input-bar:focus-within { border-color: var(--accent-700); }

.input-bar textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.375rem 0;
  max-height: 6rem;
}
.input-bar textarea::placeholder { color: var(--gray-500); }

.input-btn {
  cursor: pointer;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.input-btn-cat {
  background: rgba(200, 217, 106, 0.15);
  color: var(--accent-500);
}
.input-btn-cat:hover { background: rgba(200, 217, 106, 0.25); }

.input-btn-send {
  background: var(--accent-500);
  color: #000;
}
.input-btn-send:hover { background: #b9cb54; }
.input-btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.disclaimer {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-700);
}

/* ============================================================
   Modal de categorias
   ============================================================ */
.modal-overlay[hidden] { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #0d0d0d;
  border: 1px solid var(--divider);
  border-radius: 1rem;
  width: 100%;
  max-width: 34rem;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 1.25rem;
  animation: fade-in-up 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-header h2 { font-size: 1.125rem; font-weight: 800; color: var(--neutral-100); }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
}

.cat-card {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  color: var(--neutral-200);
  font-size: 0.875rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.cat-card:hover { border-color: var(--accent-500); background: rgba(200, 217, 106, 0.05); }
.cat-card .pill-dot { width: 0.625rem; height: 0.625rem; }

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .modal-grid { grid-template-columns: 1fr; }
}
