/* ============================================
   Decision RAG Agent — Production UI
   Premium dark glassmorphism theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 32, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-active: rgba(99, 102, 241, 0.4);

  --text-primary: #e8e8ed;
  --text-secondary: #8b8b9e;
  --text-muted: #55556a;

  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  --accent-solid: #7c3aed;
  --accent-glow: rgba(124, 58, 237, 0.25);

  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  --user-bubble: linear-gradient(135deg, #6366f1, #7c3aed);
  --agent-bubble: rgba(30, 30, 48, 0.8);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ---- Subtle animated background ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 15%, rgba(99, 102, 241, 0.08), transparent),
    radial-gradient(ellipse 500px 350px at 80% 80%, rgba(168, 85, 247, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ---- App Shell ---- */
.app-container {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.sidebar-logo .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow);
}

.sidebar-logo .logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-new-chat {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-active);
  background: transparent;
  color: var(--accent-solid);
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.btn-new-chat:hover {
  background: var(--accent-glow);
  border-color: var(--accent-solid);
  box-shadow: var(--shadow-glow);
}

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.sidebar-sessions::-webkit-scrollbar {
  width: 4px;
}

.sidebar-sessions::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.session-item {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-size: 0.87rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.session-item.active {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
}

.session-item .session-icon {
  font-size: 14px;
  opacity: 0.6;
}

.session-item .session-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item .session-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  transition: opacity var(--transition-fast);
}

.session-item:hover .session-delete {
  opacity: 0.7;
}

.session-item .session-delete:hover {
  opacity: 1;
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* ---- Top Bar ---- */
.top-bar {
  height: 56px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: rgba(10, 10, 15, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  gap: 12px;
  z-index: 10;
}

.top-bar-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.top-bar .status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
}

.status-badge .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-base);
}

.status-badge .status-dot.ready {
  background: var(--success);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.status-badge .status-dot.processing {
  background: var(--warning);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.status-badge .status-dot.error {
  background: var(--error);
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ---- Chat Area ---- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
  width: 5px;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}

/* ---- Welcome Screen ---- */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
}

.welcome-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-xl);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-glow);
}

.welcome-screen h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-screen p {
  color: var(--text-secondary);
  max-width: 420px;
  line-height: 1.6;
  font-size: 0.9rem;
}

.welcome-hints {
  display: flex;
  gap: 10px;
  margin-top: 28px;
  flex-wrap: wrap;
  justify-content: center;
}

.hint-card {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 220px;
}

.hint-card:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
  transform: translateY(-2px);
}

/* ---- Message Bubbles ---- */
.message-row {
  display: flex;
  gap: 10px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  animation: fadeInUp 0.3s ease-out;
}

.message-row.user-row {
  justify-content: flex-end;
}

.message-row.agent-row {
  justify-content: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 4px;
}

.message-bubble-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-row .message-bubble-wrapper {
  align-items: flex-end;
}

.message-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.message-avatar.user-avatar {
  background: var(--user-bubble);
  order: 2;
}

.message-avatar.agent-avatar {
  background: var(--agent-bubble);
  border: 1px solid var(--border-subtle);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.65;
  max-width: 620px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

.message-bubble.agent-bubble {
  background: var(--agent-bubble);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-bubble.clarification-bubble {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-bubble.error-bubble {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border-bottom-left-radius: 4px;
}

/* ---- Processing Pipeline Display ---- */
.pipeline-container {
  max-width: 780px;
  width: 100%;
  margin: 8px auto;
  animation: fadeInUp 0.3s ease-out;
}

.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  backdrop-filter: blur(8px);
}

.pipeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pipeline-header .pipeline-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent-solid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  transition: all var(--transition-base);
}

.pipeline-step.completed {
  color: var(--success);
  opacity: 0.7;
}

.pipeline-step.active {
  color: var(--accent-solid);
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.15);
}

.pipeline-step.pending {
  color: var(--text-muted);
  opacity: 0.5;
}

.pipeline-step .step-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.pipeline-step.active .step-icon::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-solid);
  animation: pulse-dot 1s ease-in-out infinite;
}

.pipeline-step.completed .step-icon::after {
  content: '✓';
  font-size: 12px;
}

.pipeline-step .step-label {
  flex: 1;
}

.pipeline-step .step-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ---- Input Area ---- */
.input-area {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(10, 10, 15, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.input-wrapper {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-field-wrapper {
  flex: 1;
  position: relative;
}

#messageInput {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
  resize: none;
  min-height: 48px;
  max-height: 120px;
}

#messageInput:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#messageInput::placeholder {
  color: var(--text-muted);
}

#messageInput:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 28px var(--accent-glow);
}

.btn-send:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-send .send-icon {
  display: flex;
  align-items: center;
}

/* ---- Upload Modal / Overlay ---- */
.upload-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: 100;
  animation: fadeIn 0.2s ease-out;
  display: none;
}

.upload-overlay.visible {
  display: flex;
}

.upload-modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s ease-out;
}

.upload-modal h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.upload-modal .upload-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.upload-drop-zone {
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 20px;
}

.upload-drop-zone:hover,
.upload-drop-zone.dragover {
  border-color: var(--accent-solid);
  background: var(--accent-glow);
}

.upload-drop-zone .drop-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.upload-drop-zone .drop-text {
  color: var(--text-secondary);
  font-size: 0.87rem;
}

.upload-drop-zone .drop-text strong {
  color: var(--accent-solid);
  cursor: pointer;
}

.upload-file-info {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
  font-size: 0.85rem;
}

.upload-file-info.visible {
  display: flex;
}

.upload-file-info .file-name {
  flex: 1;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-file-info .file-remove {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 16px;
}

.upload-progress {
  display: none;
  margin-bottom: 20px;
}

.upload-progress.visible {
  display: block;
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-glass);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent-gradient);
  transition: width 0.5s ease;
  width: 0%;
}

.progress-bar-fill.indeterminate {
  width: 30%;
  animation: indeterminate 1.5s ease-in-out infinite;
}

@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(400%);
  }
}

.progress-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

.upload-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-upload {
  padding: 10px 24px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-upload:hover:not(:disabled) {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-upload:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-cancel {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.87rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-cancel:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

/* ---- Execution Trace / Telemetry Panel ---- */
.telemetry-toggle {
  max-width: 780px;
  width: 100%;
  margin: 4px auto 8px;
  animation: fadeInUp 0.3s ease-out;
}

.telemetry-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.telemetry-toggle-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-glass);
}

.telemetry-panel {
  max-width: 780px;
  width: 100%;
  margin: 0 auto 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: slideDown 0.3s ease-out;
  display: none;
}

.telemetry-panel.visible {
  display: block;
}

.telemetry-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.telemetry-body {
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
  max-height: 200px;
  overflow-y: auto;
}

.telemetry-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  gap: 8px;
}

.telemetry-row:last-child {
  border-bottom: none;
}

.telemetry-tag {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
}

.telemetry-tag.plan {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
}

.telemetry-tag.conf {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
}

.telemetry-tag.refine {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

/* ---- Typing Indicator ---- */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  align-items: center;
}

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

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

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

@keyframes typing-bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ---- Sidebar Upload Button ---- */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
}

.btn-upload-sidebar {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-upload-sidebar:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* ---- Clarification Hint ---- */
.clarification-hint {
  max-width: 780px;
  width: 100%;
  margin: 4px auto;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.15);
  color: var(--warning);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeInUp 0.3s ease-out;
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }

  to {
    opacity: 1;
    max-height: 400px;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .chat-area {
    padding: 16px;
  }

  .input-area {
    padding: 12px 16px 16px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .welcome-hints {
    flex-direction: column;
    align-items: center;
  }
}

/* ---- Markdown-like content in agent bubbles ---- */
.message-bubble.agent-bubble p {
  margin-bottom: 8px;
}

.message-bubble.agent-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble.agent-bubble strong {
  color: #c4b5fd;
}

.message-bubble.agent-bubble code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
}

/* ---- Mobile menu toggle ---- */
.mobile-menu-btn {
  display: none;
  /* Hidden by default on desktop if sidebar is visible */
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-active);
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  margin-left: auto;
}

.sidebar-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

/* Sidebar Collapsed State (Desktop) */
@media (min-width: 769px) {
  .sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
    padding: 0;
  }

  .app-container.sidebar-hidden .mobile-menu-btn {
    display: block;
  }
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
}

.sidebar-overlay.visible {
  display: block;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 450px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  transform: translateX(40px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-info {
  border-left: 4px solid var(--info);
}

.toast-icon {
  font-size: 20px;
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ---- Document Name Label ---- */
.doc-name-label {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: #c4b5fd;
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}