/* ==========================================================================
   MAIA FRONTEND - DESIGN SYSTEM & STYLESHEET
   Aesthetic: Ultra-modern Dark Theme, Glassmorphism, Micro-animations
   ========================================================================== */

:root {
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Cores Oficiais da Matera — verde reservado para marca/status, tons mais
     contidos que o neon original (que deixava a tela "gritante"). Indigo
     volta a carregar os estados interativos, dando variedade visual. */
  --matera-black: #08090e;
  --matera-purple-dark: #120e26;
  --matera-purple: #1b1538;
  --matera-purple-card: #231c46;
  --matera-green: #00b368;
  --matera-green-bright: #00d67d;
  --matera-green-dark: #00934f;

  --bg-app: var(--matera-black);
  --bg-sidebar: var(--matera-purple-dark);
  --bg-card: var(--matera-purple);
  --bg-card-hover: var(--matera-purple-card);
  --bg-glass: rgba(27, 21, 56, 0.75);
  --bg-input: #110d24;

  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-cyan: #06b6d4;
  --accent-emerald: var(--matera-green);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #00b368 100%);
  --gradient-glow: radial-gradient(circle, rgba(99, 102, 241, 0.14) 0%, rgba(0,0,0,0) 70%);

  --text-main: #f8fafc;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.35);

  --shadow-lg: 0 20px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 14px rgba(99, 102, 241, 0.16);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* App Layout Grid */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 16px;
  z-index: 10;
  height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.brand-text h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-pro {
  font-size: 10px;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
  border: 1px solid var(--border-highlight);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.brand-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  border: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-glow);
}

.btn-new-chat:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.nav-item i {
  font-size: 15px;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #fff;
  border-left: 3px solid var(--accent-indigo);
  font-weight: 600;
}

.sidebar-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
  margin-top: 2px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.history-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: var(--transition-fast);
}

.history-clear-btn:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
}

.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 8px;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.history-item.active {
  background: rgba(99, 102, 241, 0.14);
  color: #fff;
  border-color: rgba(99, 102, 241, 0.3);
}

.history-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.history-item-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  opacity: 0;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  transition: var(--transition-fast);
}

.history-item:hover .history-item-del {
  opacity: 1;
}

.history-item-del:hover {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.15);
}

.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
}

.system-status-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-indicator.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.status-info {
  display: flex;
  flex-direction: column;
}

.status-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.status-detail {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Area Styles */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-app);
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  z-index: 5;
}

.topbar-title h1 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
}

.topbar-title .subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.provider-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.provider-pill.highlight {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(10, 185, 129, 0.3);
  color: var(--accent-emerald);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* Views Switcher */
.content-view {
  display: none !important;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 77px);
}

.content-view.active {
  display: flex !important;
  flex-direction: column;
}


/* View 1: Chat Styles */
#view-chat {
  position: relative;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chat-welcome {
  max-width: 680px;
  margin: 40px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: var(--shadow-glow);
}

.chat-welcome h2 {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
}

.chat-welcome p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 540px;
}

.quick-prompts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin-top: 16px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.chip i {
  color: var(--accent-indigo);
}

.chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
  color: var(--text-main);
  transform: translateY(-2px);
}

/* Chat Messages */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.message-row {
  display: flex;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.message-row.assistant .avatar {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.message-row.user .avatar {
  background: #334155;
  color: #fff;
}

.bubble {
  max-width: 80%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  position: relative;
}

.message-row.assistant .bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: 4px;
  color: var(--text-main);
}

.message-row.user .bubble {
  background: var(--accent-indigo);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Markdown formatting inside assistant bubble */
.bubble p { margin-bottom: 12px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin-left: 20px; margin-bottom: 12px; }
.bubble li { margin-bottom: 4px; }
.bubble pre {
  background: #0d1117;
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border-subtle);
}
.bubble code {
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  color: var(--matera-green-bright);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
}
.bubble pre code {
  background: none;
  padding: 0;
  color: var(--text-main);
}

/* Markdown gerado pelo modelo usa <a>/<strong>/<h1-6>/<blockquote> sem
   nenhum estilo próprio — herdava o azul padrão do navegador, com contraste
   ruim sobre o fundo escuro. Alinhando à paleta do app. */
.bubble a {
  color: var(--matera-green-bright);
  text-decoration: underline;
  text-decoration-color: rgba(0, 214, 125, 0.4);
  text-underline-offset: 2px;
  font-weight: 600;
}
.bubble a:hover {
  color: #fff;
  text-decoration-color: var(--matera-green-bright);
}
.bubble strong, .bubble b {
  color: var(--text-main);
  font-weight: 700;
}
.bubble h1, .bubble h2, .bubble h3, .bubble h4 {
  font-family: var(--font-heading);
  color: var(--text-main);
  margin: 16px 0 8px;
  line-height: 1.3;
}
.bubble h1:first-child, .bubble h2:first-child,
.bubble h3:first-child, .bubble h4:first-child { margin-top: 0; }
.bubble blockquote {
  border-left: 3px solid var(--accent-indigo);
  padding-left: 12px;
  margin: 12px 0;
  color: var(--text-secondary);
}
.bubble hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 16px 0;
}
.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.bubble th, .bubble td {
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  text-align: left;
}
.bubble th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
}

/* Estado de erro — backend indisponível. Visualmente distinto de uma
   resposta real (borda/texto em vermelho) para nunca ser confundido com
   conteúdo vindo da base de conhecimento. */
.bubble-error {
  border-color: var(--accent-rose) !important;
  background: rgba(244, 63, 94, 0.08) !important;
}

.error-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--accent-rose);
}

.error-banner i {
  font-size: 18px;
  margin-bottom: 4px;
}

.error-banner strong {
  color: var(--accent-rose);
}

.error-banner p {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.error-banner code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.citations-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-view-citations {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--border-highlight);
  color: var(--accent-indigo);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.btn-view-citations:hover {
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 20px 32px 24px;
  background: var(--bg-app);
  border-top: 1px solid var(--border-subtle);
}

.chat-form {
  max-width: 860px;
  margin: 0 auto;
}

.input-container {
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 12px 8px 18px;
  transition: var(--transition-fast);
}

.input-container:focus-within {
  border-color: var(--accent-indigo);
  box-shadow: var(--shadow-glow);
}

.input-container textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  resize: none;
  max-height: 140px;
  padding: 6px 0;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-brand);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  margin-left: 8px;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow);
}

.input-footer {
  max-width: 860px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* View 2: Knowledge Base Styles */
#view-knowledge {
  padding: 32px;
  overflow-y: auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  flex: 1;
  max-width: 500px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  width: 100%;
}

.doc-stats-summary {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.doc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: var(--transition-fast);
}

.doc-card:hover {
  border-color: var(--border-highlight);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.doc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.doc-card-header .module-badge {
  font-size: 11px;
  font-weight: 700;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  padding: 4px 8px;
  border-radius: 4px;
}

.doc-card h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.doc-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* View 3: Diagnostic & Stats */
#view-stats {
  padding: 32px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.purple { background: rgba(124, 58, 237, 0.15); color: var(--accent-purple); }
.stat-icon.blue { background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }

.stat-content .stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-content h3 {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  margin: 2px 0;
}

.stat-content .stat-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.config-details-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.config-details-card h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.config-table th, .config-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.config-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

.status-tag.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}

.badge-device {
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-purple);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}

/* Citations Drawer Modal */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-content {
  width: 480px;
  height: 100%;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-overlay.open .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.citation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.citation-title {
  font-weight: 600;
  color: var(--accent-indigo);
  font-size: 14px;
}

.citation-text {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: var(--radius-sm);
  max-height: 150px;
  overflow-y: auto;
}

/* Typing Indicator Animation */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-indigo);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ==========================================
   STUNNING GLASSMORPHISM LOGIN OVERLAY
   ========================================== */
.login-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 9, 14, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-backdrop {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 550px; height: 550px;
  background: radial-gradient(circle, rgba(0, 179, 104, 0.28) 0%, rgba(27, 21, 56, 0.45) 50%, transparent 70%);
  filter: blur(70px);
  pointer-events: none;
  animation: pulseGlow 6s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

.login-card {
  position: relative;
  width: 90%; max-width: 420px;
  padding: 40px 32px;
  background: rgba(18, 14, 38, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 179, 104, 0.18);
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column; gap: 24px;
  animation: modalAppear 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalAppear {
  0% { transform: translateY(20px) scale(0.96); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.login-card.shake {
  animation: shakeError 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeError {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.login-header {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}

.login-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #00b368 0%, #00d67d 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  box-shadow: 0 8px 24px rgba(0, 179, 104, 0.4);
  margin-bottom: 6px;
}

.login-header h2 {
  font-family: 'Outfit', -apple-system, sans-serif;
  font-size: 24px; font-weight: 700; color: #ffffff;
  display: flex; align-items: center; gap: 8px; justify-content: center;
}

.login-header p {
  font-size: 13px; color: #94a3b8;
}

.login-form {
  display: flex; flex-direction: column; gap: 18px;
}

.login-field-group {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
}

.login-field-group label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: #cbd5e1;
}

.password-input-wrapper {
  position: relative; display: flex; align-items: center;
}

.password-input-wrapper .input-icon {
  position: absolute; left: 14px; color: #64748b; font-size: 15px;
}

.password-input-wrapper input {
  width: 100%;
  padding: 13px 44px 13px 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #ffffff; font-size: 14px;
  outline: none; transition: all 0.2s ease;
}

.password-input-wrapper input:focus {
  border-color: #00b368;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(0, 179, 104, 0.2);
}

.btn-toggle-pass {
  position: absolute; right: 12px;
  background: none; border: none;
  color: #64748b; cursor: pointer;
  font-size: 15px; padding: 4px; transition: color 0.2s;
}

.btn-toggle-pass:hover {
  color: #ffffff;
}

.login-error-msg {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171; font-size: 13px; font-weight: 500;
}

.login-error-msg.hidden {
  display: none !important;
}

.btn-login-submit {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #00b368 0%, #00d67d 100%);
  color: #08090e; font-family: 'Outfit', -apple-system, sans-serif;
  font-size: 15px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 6px 20px rgba(0, 179, 104, 0.35);
  transition: all 0.2s ease;
}

.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 179, 104, 0.5);
  background: linear-gradient(135deg, #00c975 0%, #00ea89 100%);
}

.btn-login-submit:active {
  transform: translateY(0);
}

.login-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11px; color: #64748b; text-align: center;
  margin-top: 4px;
}
