/* UZEX AI — Modern Minimal Premium Styling */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Light Theme */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-bubble-user: #0f766e;
  --text-bubble-user: #ffffff;
  --bg-bubble-bot: #ffffff;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;
  
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-light: #ccfbf1;
  --primary-focus: rgba(15, 118, 110, 0.2);

  /* Status Tokens */
  --status-verified-bg: #ecfdf5;
  --status-verified-text: #065f46;
  --status-verified-border: #a7f3d0;

  --status-ambiguous-bg: #fffbeb;
  --status-ambiguous-text: #92400e;
  --status-ambiguous-border: #fde68a;

  --status-not_found-bg: #f8fafc;
  --status-not_found-text: #475569;
  --status-not_found-border: #cbd5e1;

  --status-unsupported-bg: #faf5ff;
  --status-unsupported-text: #6b21a8;
  --status-unsupported-border: #e9d5ff;

  --status-error-bg: #fef2f2;
  --status-error-text: #991b1b;
  --status-error-border: #fecaca;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

html.dark {
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-subtle: #1f2937;
  --bg-bubble-user: #0d9488;
  --text-bubble-user: #ffffff;
  --bg-bubble-bot: #111827;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-color: #1f2937;
  --border-subtle: #374151;

  --primary: #14b8a6;
  --primary-hover: #2dd4bf;
  --primary-light: #134e4a;
  --primary-focus: rgba(20, 184, 166, 0.25);

  --status-verified-bg: #064e3b;
  --status-verified-text: #6ee7b7;
  --status-verified-border: #047857;

  --status-ambiguous-bg: #78350f;
  --status-ambiguous-text: #fde68a;
  --status-ambiguous-border: #b45309;

  --status-not_found-bg: #1e293b;
  --status-not_found-text: #cbd5e1;
  --status-not_found-border: #475569;

  --status-unsupported-bg: #581c87;
  --status-unsupported-text: #e9d5ff;
  --status-unsupported-border: #7e22ce;

  --status-error-bg: #7f1d1d;
  --status-error-text: #fecaca;
  --status-error-border: #b91c1c;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0f766e, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  background-color: var(--primary-light);
  color: var(--primary);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-full);
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #94a3b8;
}

.status-badge.online .status-indicator {
  background-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.lang-selector {
  display: flex;
  background-color: var(--bg-surface-subtle);
  border-radius: var(--radius-full);
  padding: 2px;
  border: 1px solid var(--border-color);
}

.lang-btn {
  background: transparent;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.lang-btn.active {
  background-color: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background-color: var(--border-color);
  color: var(--text-primary);
}

/* Chat Layout */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

.disclaimer-banner {
  background-color: var(--bg-surface-subtle);
  border-bottom: 1px solid var(--border-color);
  padding: 0.4rem 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.disclaimer-banner svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: #f59e0b;
}

.messages-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

/* Welcome Card */
.welcome-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-top: 0.5rem;
}

.welcome-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.welcome-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.examples-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.examples-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.example-chip {
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.example-chip:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* Chat Bubbles */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}

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

.message-row.bot {
  align-self: flex-start;
  align-items: flex-start;
  width: 100%;
}

.message-bubble {
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.15rem;
  font-size: 0.92rem;
  word-break: break-word;
  position: relative;
}

.message-row.user .message-bubble {
  background-color: var(--bg-bubble-user);
  color: var(--text-bubble-user);
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-row.bot .message-card {
  background-color: var(--bg-bubble-bot);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 4px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

/* Bot Message Header */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-pill {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}

.status-pill.VERIFIED {
  background-color: var(--status-verified-bg);
  color: var(--status-verified-text);
  border: 1px solid var(--status-verified-border);
}

.status-pill.AMBIGUOUS {
  background-color: var(--status-ambiguous-bg);
  color: var(--status-ambiguous-text);
  border: 1px solid var(--status-ambiguous-border);
}

.status-pill.NOT_FOUND {
  background-color: var(--status-not_found-bg);
  color: var(--status-not_found-text);
  border: 1px solid var(--status-not_found-border);
}

.status-pill.UNSUPPORTED {
  background-color: var(--status-unsupported-bg);
  color: var(--status-unsupported-text);
  border: 1px solid var(--status-unsupported-border);
}

.status-pill.ERROR {
  background-color: var(--status-error-bg);
  color: var(--status-error-text);
  border: 1px solid var(--status-error-border);
}

.latency-pill {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background-color: var(--bg-surface-subtle);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.copy-btn:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

/* Answer Body */
.answer-body {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Analytical Key-Value Grid */
.analytical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  margin: 0.75rem 0;
  background-color: var(--bg-surface-subtle);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.analytical-item {
  display: flex;
  flex-direction: column;
}

.analytical-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.analytical-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Evidence Drawer */
.evidence-drawer {
  margin-top: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.evidence-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.25rem 0;
  text-align: left;
}

.evidence-toggle:hover {
  color: var(--primary);
}

.evidence-toggle svg {
  transition: transform 0.2s ease;
}

.evidence-toggle.open svg {
  transform: rotate(180deg);
}

.evidence-content {
  display: none;
  background-color: var(--bg-surface-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  border: 1px solid var(--border-color);
}

.evidence-content.open {
  display: block;
}

.evidence-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border-color);
}

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

.evidence-key {
  color: var(--text-muted);
}

.evidence-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
}

/* Loading Dots */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  width: fit-content;
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dots-wrapper {
  display: flex;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 50%;
  animation: pulse 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.input-section {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 0.85rem 1.25rem;
  flex-shrink: 0;
}

.input-box {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
  background-color: var(--bg-surface);
}

.chat-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  color: var(--text-primary);
  outline: none;
  resize: none;
  min-height: 24px;
  max-height: 140px;
  line-height: 1.45;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-color);
}

.input-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.clear-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-decoration: underline;
}

.clear-btn:hover {
  color: var(--text-primary);
}

.send-btn {
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.send-btn:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .app-header {
    padding: 0.5rem 0.75rem;
  }
  .brand-logo {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  .brand-info h1 {
    font-size: 0.95rem;
  }
  .brand-info p {
    display: none;
  }
  .status-badge {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
  }
  .status-text {
    display: none;
  }
  .messages-feed {
    padding: 0.75rem;
    gap: 1rem;
  }
  .message-row {
    max-width: 95%;
  }
  .input-section {
    padding: 0.5rem 0.75rem;
  }
  .input-meta span.hint {
    display: none;
  }
}

