:root {
  --bg-color: #fdfbf7;
  --panel-bg: #ffffff;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.05), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.05), transparent 25%);
}

.app-container {
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}

.app-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  text-align: center;
  background: var(--panel-bg);
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.content-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-container {
  flex: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-color);
}

.telemetry-sidebar {
  flex: 1;
  background: #f9fafb;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.telemetry-sidebar h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.telemetry-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-style: italic;
}

.telemetry-card {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.telemetry-card h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 0.875rem;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background: var(--bg-color);
}

.chat-history::-webkit-scrollbar {
  width: 6px;
}
.chat-history::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 10px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(10px);
}

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

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

.user-message .message-bubble {
  background: var(--accent-gradient);
  color: white;
  border-radius: 18px 18px 4px 18px;
  padding: 12px 18px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.system-message {
  align-self: flex-start;
  width: 100%;
}

.system-message .message-bubble {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: 18px 18px 18px 4px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  width: 100%;
}

.answer-text {
  font-size: 1rem;
  margin-bottom: 12px;
}

.sql-block {
  margin-top: 12px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  position: relative;
}

.sql-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: block;
}

.sql-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  color: #4338ca;
  white-space: pre-wrap;
  word-break: break-all;
}

.data-table-container {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--panel-bg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: #f8fafc;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

.approval-card {
  margin-top: 16px;
  padding: 16px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 12px;
}

.approval-reason {
  color: #d97706;
  font-size: 0.875rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.approval-actions {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

.btn-approve {
  background: var(--success-color);
  color: white;
}

.btn-approve:hover {
  background: #059669;
}

.btn-reject {
  background: #e2e8f0;
  color: var(--text-primary);
}

.btn-reject:hover {
  background: #cbd5e1;
}

.node-status-container {
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-color);
  font-size: 0.875rem;
  color: var(--accent-color);
  font-weight: 500;
  border-top: 1px solid var(--border-color);
}

.node-status-container.hidden {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(59, 130, 246, 0.3);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s ease-in-out infinite;
}

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

.input-area {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--panel-bg);
}

#chatForm {
  display: flex;
  gap: 12px;
  position: relative;
}

#questionInput {
  flex: 1;
  background: #f9fafb;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: 100px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#questionInput:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #ffffff;
}

#questionInput::placeholder {
  color: var(--text-secondary);
}

#sendButton {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sendButton:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#sendButton svg {
  width: 20px;
  height: 20px;
}

/* Trace UI Styles */
.traces-card {
  margin-top: 16px;
}

.trace-details {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.trace-details summary {
  padding: 10px 12px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: #f8fafc;
  user-select: none;
  outline: none;
}

.trace-details summary:hover {
  background: #f1f5f9;
}

.trace-content {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trace-section strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.trace-section pre {
  background: #1e293b;
  color: #f8fafc;
  padding: 12px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 250px;
  overflow-y: auto;
}
