@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Premium Dark Theme Variables */
  --bg-app: #070B14;
  --bg-panel: rgba(13, 19, 32, 0.65);
  --bg-element: rgba(255, 255, 255, 0.03);
  --bg-element-hover: rgba(255, 255, 255, 0.07);
  --bg-element-active: rgba(255, 255, 255, 0.1);
  --bg-input: rgba(10, 15, 26, 0.7);

  --brand-aso: #4169e1;
  --brand-aso-glow: rgba(65, 105, 225, 0.4);
  --brand-candido: #f59e0b;
  --brand-candido-glow: rgba(245, 158, 11, 0.4);

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --glass-blur: blur(20px);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body.dark {
  background: var(--bg-app);
  background-image: radial-gradient(circle at 50% 0%, #111a2e 0%, var(--bg-app) 100%);
  color: var(--text-main);
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

.aso-app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ==========================================================
   SIDEBARS (Glassmorphism)
   ========================================================== */
.aso-sidebar {
  width: 280px;
  background: var(--bg-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-main);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  box-sizing: border-box;
  z-index: 10;
  overflow: hidden;
}

.aso-sidebar-docs {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
  width: 300px;
}

.sidebar-header {
  margin-bottom: 20px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--brand-candido);
  text-shadow: 0 0 16px rgba(245, 158, 11, 0.14);
}

.sidebar-new-chat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 12px;
  margin: 10px 0 24px 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-new-chat {
  margin-bottom: 8px;
}

.sidebar-new-chat:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-chats-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 4px;
}
.project-chats-label-highlight {
  display: block;
  margin-top: 4px;
  color: #ffd54f;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.sidebar-chat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.sidebar-session-summary {
  margin-top: 16px;
  padding: 14px 12px 4px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-session-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--brand-candido);
  text-shadow: 0 0 16px rgba(245, 158, 11, 0.14);
}

.sidebar-session-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-session-sep {
  opacity: 0.45;
}

.sidebar-session-user {
  opacity: 0.72;
}
#project-list-container.project-list-scroll {
  max-height: 210px;
  overflow-y: auto;
  padding-right: 2px;
}

#project-list-container.project-list-scroll::-webkit-scrollbar {
  width: 4px;
}

#project-list-container.project-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 9999px;
}

.sidebar-chat-list::-webkit-scrollbar {
  width: 4px;
}

.sidebar-chat-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.sidebar-chat-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  text-align: left;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.sidebar-chat-item:hover {
  background: var(--bg-element);
  color: var(--text-main);
}

.sidebar-chat-item.is-active {
  background: var(--bg-element-active);
  color: #fff;
  border-color: var(--border-subtle);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.sidebar-chat-item.is-document-active {
  border-color: rgba(100, 181, 246, 0.45);
  background: rgba(100, 181, 246, 0.14);
  color: #fff;
}

.chat-options-button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
  margin-left: auto;
  border-radius: var(--radius-sm);
  padding: 4px;
}

.sidebar-chat-item:hover .chat-options-button {
  opacity: 1;
  color: var(--text-muted);
}

.chat-options-button:hover {
  background: var(--bg-element-hover);
  color: #fff !important;
}

.doc-scope-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.doc-scope-button {
  border: 1px solid rgba(100, 181, 246, 0.35);
  background: rgba(100, 181, 246, 0.12);
  color: #d8ecff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
  transition: var(--transition);
}

.doc-scope-button:hover {
  background: rgba(100, 181, 246, 0.2);
  border-color: rgba(100, 181, 246, 0.5);
}

.doc-scope-button.is-active {
  background: rgba(129, 199, 132, 0.16);
  border-color: rgba(129, 199, 132, 0.5);
  color: #d8f4dc;
}

/* Chat Options Menu (Rename/Delete) */
.chat-options-menu {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  padding: 4px;
  z-index: 1000;
  min-width: 120px;
}

.chat-options-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.chat-options-item:hover {
  background: var(--bg-element-hover);
  color: #fff;
}

/* ==========================================================
   DOCUMENT ZONE (Right Sidebar)
   ========================================================== */
.docs-drop-zone {
  min-height: 110px;
  border: 1.5px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  margin: 0 0 20px 0;
  font-size: 12.5px;
  font-weight: 500;
  transition: var(--transition);
}

.docs-drop-zone.is-dragover {
  border-color: var(--brand-aso);
  background: var(--brand-aso-glow);
  color: #fff;
  transform: scale(1.02);
}

.docs-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.docs-status-stack {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.docs-filter-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}

.docs-filter-input:focus {
  border-color: var(--border-focus);
  background: rgba(0, 0, 0, 0.5);
}

/* ==========================================================
   MAIN CHAT PANEL
   ========================================================== */
.aso-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: transparent;
}

.chat-header {
  padding: 18px 24px;
  gap: 16px;
  background: linear-gradient(to bottom, rgba(7, 11, 20, 0.95) 0%, rgba(7, 11, 20, 0) 100%);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  pointer-events: none;
}

.chat-header>* {
  pointer-events: auto;
}

.chat-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  max-width: min(46vw, 420px);
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.system-status-badge {
  font-size: 11.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  border: 1px solid transparent;
  background: var(--bg-element);
  color: var(--text-muted);
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.system-status-badge.is-ok {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.system-status-badge.is-degraded {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.system-status-badge.is-down {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.chat-model-indicator {
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.chat-memory-indicator {
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.chat-model-indicator .model-label {
  opacity: 0.6;
  font-weight: 500;
  font-size: 12px;
}

/* Glowing Memory Toggle */
.memory-toggle {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-element);
  color: var(--text-muted);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.memory-toggle.is-on {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.memory-toggle.is-on::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: sweep 3s infinite;
}

@keyframes sweep {
  0% {
    left: -100%;
  }

  50% {
    left: 200%;
  }

  100% {
    left: 200%;
  }
}

/* ==========================================================
   CHAT MESSAGES AREA
   ========================================================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 108px 0 140px 0;
  /* Leave room for the visible top header and the floating footer. */
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  /* Stack bubble + trace vertically, not side by side! */
  width: 100%;
  max-width: 100%;
  margin: 0 auto 24px auto;
  padding: 0 24px;
  box-sizing: border-box;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) ease-out;
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message-user {
  align-items: flex-end;
  /* User messages aligned to the right */
}

.chat-message-wrapper {
  display: block;
  /* Removido o flex para nÃ£o colapsar com o trace */
  max-width: 100%;
  width: 100%;
}


.chat-message-aso {
  align-items: flex-start;
  /* ASO messages aligned to the left */
}

.chat-message-doc {
  align-items: flex-start;
}

.chat-message-candido {
  align-items: flex-start;
  /* Candido messages aligned to the left */
  margin: 24px auto;
}

/* Candido on the right like user but distinct */

.chat-message-bubble {
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  width: 75%;
  /* Force exactly 75% of the central area, matching the user diagram */
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

/* Preserve raw newlines only for plain-text bubbles. */
.chat-message-user .chat-message-bubble,
.chat-message-doc .chat-message-bubble {
  white-space: pre-wrap;
}

/* Markdown bubbles should rely on HTML structure, not preserved source newlines. */
.chat-message-aso .chat-message-bubble,
.chat-message-candido .chat-message-bubble {
  white-space: normal;
}

/* Tighten markdown rhythm to avoid oversized gaps between paragraphs/lists. */
.chat-message-bubble p {
  margin-top: 0;
  margin-bottom: 0.45em;
}

.chat-message-bubble ul,
.chat-message-bubble ol {
  margin: 0.2em 0 0.45em;
  padding-left: 1.35em;
}

.chat-message-bubble li {
  margin-bottom: 0.15em;
}

.chat-message-bubble li p {
  margin-bottom: 0.2em;
}

.chat-message-bubble > :last-child {
  margin-bottom: 0;
}
.chat-message-bubble strong {
  color: #fff;
  font-weight: 700;
}


.chat-message-user .chat-message-bubble {
  background: linear-gradient(135deg, #2563eb, var(--brand-aso));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message-aso .chat-message-bubble {
  background: rgba(30, 41, 59, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border-bottom-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.chat-message-doc>.chat-message-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ccc;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.chat-message-candido {
  align-items: flex-start;
}

.chat-message-candido>.chat-message-bubble {
  background: rgba(161, 110, 22, 0.18);
  border: 1px solid rgba(245, 188, 74, 0.38);
  color: #ffe6a8;
  border-bottom-left-radius: 0;
}

.chat-message-candido .chat-message-bubble {
  background: linear-gradient(135deg, rgba(154, 103, 19, 0.58), rgba(109, 74, 16, 0.5));
  border: 1px solid rgba(245, 188, 74, 0.28);
  color: #fff3cf;
  border-bottom-right-radius: 4px;
  position: relative;
}

.chat-message-candido::before {
  content: "CANDIDO";
  position: absolute;
  top: -20px;
  right: 28px;
  font-size: 11px;
  color: var(--brand-candido);
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

.doc-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(45, 212, 191, 0.2);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: #5eead4;
  margin-bottom: 12px;
}

/* ==========================================================
   TRACE CARDS (Neo-Brutalism/Glass merge)
   ========================================================== */
.trace-details {
  margin-top: 8px;
  max-width: 75%;
  /* Limit trace to the same width as the bubble */
  width: 100%;
}

.trace-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.trace-summary::before {
  content: "\25B6";
  font-size: 10px;
  transition: transform 0.2s;
}

.trace-details[open] .trace-summary::before {
  transform: rotate(90deg);
}

.trace-card {
  margin-top: 10px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--glass-shadow);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  color: #cbd5e1;
}

.trace-row {
  display: grid;
  grid-template-columns: 200px 140px 1fr 140px 70px;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.trace-row:last-child {
  border-bottom: none;
}

.trace-row.is-verdict .trace-decision {
  color: #fed7aa;
  font-weight: 600;
}

.trace-row.is-warning {
  background: rgba(245, 158, 11, 0.05);
  border-radius: 6px;
}

.trace-row.is-delivery {
  background: rgba(59, 130, 246, 0.08);
  border-radius: 6px;
}

.trace-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-reason {
  white-space: normal;
  overflow: visible;
  color: #94a3b8;
}

.trace-ms {
  text-align: right;
}

.trace-status {
  font-weight: 600;
}

/* Thinking state */
.chat-message-aso.is-thinking .chat-message-bubble {
  background: rgba(30, 41, 59, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
}

.chat-message-candido.is-thinking .chat-message-bubble {
  background: rgba(138, 92, 16, 0.28);
  border: 1px dashed rgba(245, 188, 74, 0.45);
  color: #ffe7b3;
  position: relative;
  overflow: hidden;
}

.chat-message-aso.is-thinking .chat-message-bubble::before,
.chat-message-candido.is-thinking .chat-message-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 42%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: skewX(-16deg);
  animation: thinkingSweep 2.1s linear infinite;
}

.thinking-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.thinking-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transform-origin: 50% 50%;
  animation: thinkingSpinnerRotate 1.05s linear infinite;
}

.thinking-label {
  display: inline-block;
}

@keyframes thinkingSweep {
  0% {
    left: -120%;
  }

  100% {
    left: 220%;
  }
}

@keyframes thinkingSpinnerRotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}
/* ==========================================================
   FLOATING FOOTER & INPUT
   ========================================================== */
.chat-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 0 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(to top, var(--bg-app) 40%, rgba(7, 11, 20, 0) 100%);
  pointer-events: none;
}

.chat-footer>* {
  pointer-events: auto;
}

/* Pill Mode Selector */
.chat-mode-selector {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.mode-btn {
  padding: 6px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-btn:hover {
  color: #fff;
}

.mode-btn.mode-active {
  background: var(--bg-element);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mode-btn[data-mode="aso"].mode-active {
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
}

.mode-btn[data-mode="candido"].mode-active {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.mode-btn.repo-toggle {
  position: relative;
  overflow: hidden;
}

.mode-btn.repo-toggle.repo-on {
  background: rgba(16, 185, 129, 0.15);
  color: #4ade80;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.mode-btn.aso-professor-toggle.mode-active {
  background: rgba(234, 179, 8, 0.16);
  color: #fde047;
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.22);
}

.mode-btn.aso-legal-toggle.mode-active {
  background: rgba(14, 165, 233, 0.16);
  color: #67e8f9;
  box-shadow: 0 0 15px rgba(14, 165, 233, 0.18);
}

.mode-btn.full-consult-toggle {
  position: relative;
  overflow: hidden;
}

.mode-btn.full-consult-toggle.mode-active {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.32);
  color: #fca5a5;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.mode-btn.full-consult-toggle.mode-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  animation: sweep 3s infinite;
}

.mode-btn.is-pipeline-locked,
.chat-input-shell.is-pipeline-locked,
.chat-input.is-pipeline-locked,
.chat-send-button.is-pipeline-locked,
.chat-icon-button.is-pipeline-locked {
  opacity: 0.56;
  pointer-events: none;
}

.mode-btn.repo-toggle.repo-on::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: sweep 3s infinite;
}

.mode-indicator {
  display: none;
}

/* Removed dots in favor of pill background */

/* Floating Input Shell */
.chat-input-shell {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  max-width: 800px;
  background: var(--bg-input);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-focus);
  border-radius: 24px;
  padding: 8px 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: var(--transition);
}

.chat-input-shell:focus-within {
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* Glowing boundary based on mode - we use a class added via JS or inherit */
body.mode-candido-active .chat-input-shell:focus-within {
  border-color: var(--brand-candido);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

body:not(.mode-candido-active) .chat-input-shell:focus-within {
  border-color: var(--brand-aso);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

.chat-icon-button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  height: 38px;
  width: 38px;
}

.chat-icon-button:hover {
  background: var(--bg-element-active);
  color: #fff;
}

.chat-input {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: #fff;
  padding: 8px 4px;
  font-size: 15px;
  line-height: 1.5;
  font-family: 'Inter', sans-serif;
  max-height: 200px;
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-weight: 400;
}

.chat-input:focus {
  outline: none;
}

.chat-send-button {
  background: #fff;
  color: #000;
  border: none;
  height: 38px;
  width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: var(--transition);
}

.chat-send-button:hover {
  transform: scale(1.05);
}

/* Tools Menu */
.chat-tools-menu {
  position: absolute;
  bottom: 65px;
  left: 10px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 0;
  min-width: 220px;
  box-shadow: var(--glass-shadow);
  z-index: 30;
  backdrop-filter: blur(16px);
}

.chat-tools-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chat-tools-menu li {
  padding: 10px 16px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text-main);
  font-weight: 500;
  transition: 0.1s;
}

.chat-tools-menu li:hover {
  background: var(--brand-aso);
  color: #fff;
}

.chat-tools-menu li.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.chat-hint {
  position: absolute;
  left: 24px;
  bottom: 24px;
  margin-top: 0;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 320px;
  text-align: left;
}

.doc-ingest-indicator {
  font-size: 12px;
  line-height: 1.35;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
}

.doc-ingest-indicator.is-pending {
  border-color: rgba(255, 193, 7, 0.45);
  background: rgba(255, 193, 7, 0.12);
  color: #ffe082;
}

.doc-ingest-indicator.is-ready {
  border-color: rgba(129, 199, 132, 0.45);
  background: rgba(129, 199, 132, 0.12);
  color: #c8e6c9;
}

.doc-ingest-indicator.is-error {
  border-color: rgba(239, 83, 80, 0.45);
  background: rgba(239, 83, 80, 0.14);
  color: #ffcdd2;
}

.candido-doc-scope {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(127, 29, 29, 0.42);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.candido-doc-scope-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.candido-doc-scope-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(254, 226, 226, 0.88);
}

.candido-doc-scope-name {
  font-size: 12.5px;
  color: #fee2e2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.candido-doc-scope-clear {
  border: 1px solid rgba(248, 113, 113, 0.36);
  background: rgba(239, 68, 68, 0.18);
  color: #fee2e2;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex: 0 0 auto;
}

.candido-doc-scope-clear:hover {
  background: rgba(239, 68, 68, 0.28);
}

.doc-inline-status {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}

.doc-inline-status.is-active {
  color: #fca5a5;
}

.doc-inline-status.is-armed {
  color: #fecaca;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  animation: doc-status-armed-pulse 1.1s ease-in-out infinite;
}

.doc-inline-status.is-error {
  color: #fca5a5;
  font-weight: 700;
}

@keyframes doc-status-armed-pulse {
  0%,
  100% {
    opacity: 1;
    color: #fca5a5;
    text-shadow: 0 0 0 rgba(248, 113, 113, 0);
  }
  50% {
    opacity: 0.38;
    color: #ef4444;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.35);
  }
}
/* ==========================================================
   STATUS CORNER (Bottom-right indicators)
   ========================================================== */
.status-corner {
  position: fixed;
  bottom: 12px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 25;
  pointer-events: auto;
}

/* ==========================================================
   MODAL
   ========================================================== */
.modal-overlay[hidden] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--glass-shadow);
  color: #fff;
  animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 14.5px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}

.modal-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.modal-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.modal-btn-primary {
  background: #fff;
  color: #000;
}

.modal-btn-primary:hover {
  transform: scale(1.03);
}


.generated-docs-modal {
  max-width: 900px;
  width: min(92vw, 900px);
}

.generated-docs-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.generated-docs-close-top {
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.generated-docs-close-top:hover {
  background: rgba(255, 255, 255, 0.14);
}

.generated-docs-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.generated-docs-search {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
}

.generated-docs-search:focus {
  border-color: var(--border-focus);
}

.generated-docs-list {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.24);
  max-height: 52vh;
  overflow-y: auto;
}

.generated-doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.generated-doc-row:last-child {
  border-bottom: none;
}

.generated-doc-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.generated-doc-name {
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.generated-doc-sub {
  color: var(--text-muted);
  font-size: 12px;
}

.generated-doc-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.generated-doc-btn {
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
}

.generated-doc-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.generated-doc-btn-danger {
  border-color: rgba(239, 68, 68, 0.28);
  color: #fca5a5;
}

.generated-doc-btn-danger:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.generated-docs-empty {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

@media (max-width: 900px) {
  .generated-docs-modal {
    width: min(96vw, 96vw);
    padding: 16px;
  }

  .generated-docs-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .generated-doc-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .generated-doc-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}
/* Toasts */
.system-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 7000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.system-toast {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.system-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}




.chat-model-indicator:empty {
  display: none;
}

.chat-memory-indicator:empty {
  display: none;
}

@media (max-width: 1180px) {
  .chat-header {
  padding: 18px 24px;
  gap: 16px;
  background: linear-gradient(to bottom, rgba(7, 11, 20, 0.95) 0%, rgba(7, 11, 20, 0) 100%);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  pointer-events: none;
}

