/**
 * Twilio MCP UI Kit — Dark Theme Base Styles
 * Colors: bg #0f1117, card #1a1d27, primary #6366f1
 */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  line-height: 1.4;
  font-size: 12px;
  -webkit-font-smoothing: antialiased;
  overflow-y: auto;
  overflow-x: hidden;
}

#app, #root { padding: 4px; min-height: fit-content; }

a { color: #818cf8; text-decoration: none; }
a:hover { text-decoration: underline; }

.font-medium { font-weight: 500; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.text-sm { font-size: 13px; }
.text-muted { color: #94a3b8; }
.text-secondary { color: #64748b; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ─── Loading & Error States ──────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 120px; color: #94a3b8;
}
.loading-spinner {
  width: 24px; height: 24px; border: 2px solid #2a2d3a; border-top-color: #6366f1;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state p { font-size: 12px; }

.error-state {
  padding: 12px; margin: 8px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px; color: #ef4444;
}
.error-state h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.error-state p { font-size: 12px; color: #fca5a5; }

/* ─── Status Badges ───────────────────────────────────── */
.status-badge, .status-badge-sm {
  display: inline-flex; align-items: center; border-radius: 9999px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.status-badge { padding: 4px 12px; font-size: 11px; }
.status-badge-sm { padding: 2px 6px; font-size: 9px; }

.status-active { background: rgba(59,130,246,0.15); color: #60a5fa; }
.status-complete { background: rgba(34,197,94,0.15); color: #4ade80; }
.status-paused { background: rgba(245,158,11,0.15); color: #fbbf24; }
.status-draft { background: rgba(100,116,139,0.15); color: #94a3b8; }
.status-error { background: rgba(239,68,68,0.15); color: #f87171; }
.status-sent { background: rgba(59,130,246,0.15); color: #60a5fa; }
.status-paid { background: rgba(34,197,94,0.15); color: #4ade80; }
.status-pending { background: rgba(245,158,11,0.15); color: #fbbf24; }
.status-open { background: rgba(59,130,246,0.15); color: #60a5fa; }
.status-won { background: rgba(34,197,94,0.15); color: #4ade80; }
.status-lost { background: rgba(239,68,68,0.15); color: #f87171; }

/* ─── Page Header ─────────────────────────────────────── */
.page-header {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px;
}
.page-header-gradient {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; padding: 8px 12px; position: sticky; top: 0; z-index: 50;
  border-radius: 8px; margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(99,102,241,0.3);
}
.page-header-top { display: flex; align-items: center; justify-content: space-between; }
.page-header-title { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.page-header-title-light { font-size: 13px; font-weight: 600; }
.page-header-subtitle { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.page-header-subtitle-light { font-size: 10px; opacity: 0.8; margin-top: 1px; }
.badge-light { padding: 2px 8px; border-radius: 9999px; font-size: 10px; font-weight: 600; background: rgba(255,255,255,0.2); }
.page-header-stats { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.page-header-stats-light { display: flex; gap: 10px; margin-top: 4px; }
.stat-item { font-size: 11px; color: #94a3b8; }
.stat-value { font-weight: 500; color: #e2e8f0; }
.stat-item-light { font-size: 10px; display: flex; align-items: center; gap: 4px; }
.stat-value-light { font-weight: 600; }
.stat-label-light { opacity: 0.7; }

/* ─── Card ────────────────────────────────────────────── */
.card {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 8px;
  overflow: hidden; margin-bottom: 8px;
}
.card.no-border { border: none; box-shadow: none; }
.card-header { padding: 8px 12px; border-bottom: 1px solid #2a2d3a; }
.card-title { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.card-subtitle { font-size: 11px; color: #94a3b8; margin-top: 1px; }
.card-body.p-0 { padding: 0; }
.card-body.p-sm { padding: 8px; }
.card-body.p-md { padding: 10px; }
.card-body.p-lg { padding: 12px; }

/* ─── Stats Grid ──────────────────────────────────────── */
.stats-grid { display: grid; gap: 8px; margin-bottom: 8px; }
.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }
.stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) {
  .stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Split Layout ────────────────────────────────────── */
.split-layout { display: grid; }
.split-50-50 { grid-template-columns: 1fr; }
.split-33-67 { grid-template-columns: 1fr; }
.split-67-33 { grid-template-columns: 1fr; }
.gap-sm { gap: 6px; }
.gap-md { gap: 10px; }
.gap-lg { gap: 14px; }
@media (min-width: 640px) {
  .split-50-50 { grid-template-columns: 1fr 1fr; }
  .split-33-67 { grid-template-columns: 1fr 2fr; }
  .split-67-33 { grid-template-columns: 2fr 1fr; }
}

/* ─── Section ─────────────────────────────────────────── */
.section { margin-bottom: 8px; }
.section-header { margin-bottom: 6px; }
.section-title { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.section-desc { font-size: 11px; color: #94a3b8; margin-top: 1px; }

/* ─── Metric Card ─────────────────────────────────────── */
.metric-card {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 8px; padding: 10px;
  text-align: center;
}
.metric-value { font-size: 18px; font-weight: 700; color: #e2e8f0; }
.metric-green { color: #4ade80; }
.metric-blue { color: #60a5fa; }
.metric-purple { color: #a78bfa; }
.metric-yellow { color: #fbbf24; }
.metric-red { color: #f87171; }
.metric-label { font-size: 10px; color: #94a3b8; margin-top: 2px; }
.metric-trend { font-size: 11px; font-weight: 600; margin-top: 4px; }
.trend-up { color: #4ade80; }
.trend-down { color: #f87171; }
.trend-flat { color: #94a3b8; }

/* ─── Data Table ──────────────────────────────────────── */
.data-table-wrap {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 12px; overflow: hidden;
}
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th {
  text-align: left; padding: 6px 8px; background: #1e2333; color: #94a3b8;
  font-weight: 500; font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid #2a2d3a; white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { background: #252938; }
.data-table td { padding: 5px 8px; border-bottom: 1px solid #1e293b; vertical-align: middle; color: #e2e8f0; }
.data-table tr:hover { background: #1e2333; }

.avatar-cell { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: white; font-weight: 600; font-size: 12px; flex-shrink: 0;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 200px; }
.tag {
  display: inline-block; padding: 2px 8px; background: rgba(99,102,241,0.15); color: #818cf8;
  border-radius: 12px; font-size: 11px; font-weight: 500;
}
.tag-more { background: rgba(100,116,139,0.15); color: #94a3b8; }
.link { color: #818cf8; text-decoration: none; }
.link:hover { text-decoration: underline; }

.table-pagination {
  padding: 12px 20px; border-top: 1px solid #2a2d3a; display: flex;
  justify-content: space-between; align-items: center;
}
.pagination-info { font-size: 13px; color: #94a3b8; }
.pagination-buttons { display: flex; gap: 8px; }

.empty-state { padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { color: #94a3b8; font-size: 15px; }

/* ─── Timeline ────────────────────────────────────────── */
.timeline { position: relative; padding-left: 24px; }
.timeline-line { position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: #2a2d3a; }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item:last-child { margin-bottom: 0; }
.timeline-dot {
  position: absolute; left: -16px; top: 4px; width: 16px; height: 16px;
  border-radius: 50%; border: 2px solid; background: #0f1117;
  display: flex; align-items: center; justify-content: center; font-size: 8px;
}
.tl-border-default { border-color: #64748b; }
.tl-border-success { border-color: #4ade80; }
.tl-border-warning { border-color: #fbbf24; }
.tl-border-error { border-color: #f87171; }
.timeline-content { margin-left: 8px; }
.timeline-title { font-weight: 500; font-size: 14px; color: #e2e8f0; }
.timeline-desc { font-size: 14px; color: #94a3b8; margin-top: 2px; }
.timeline-time { font-size: 12px; color: #64748b; margin-top: 2px; }

/* ─── Progress Bar ────────────────────────────────────── */
.progress-wrap { margin-bottom: 20px; }
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.progress-label { font-size: 14px; font-weight: 500; color: #e2e8f0; }
.progress-value { font-size: 14px; color: #94a3b8; }
.progress-value strong { color: #e2e8f0; }
.progress-track { position: relative; height: 24px; background: #2a2d3a; border-radius: 12px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 12px; transition: width 0.5s; }
.bar-green { background: linear-gradient(to right, #22c55e, #16a34a); }
.bar-blue { background: linear-gradient(to right, #6366f1, #4f46e5); }
.bar-purple { background: linear-gradient(to right, #a78bfa, #8b5cf6); }
.bar-yellow { background: linear-gradient(to right, #fbbf24, #f59e0b); }
.bar-red { background: linear-gradient(to right, #f87171, #ef4444); }
.progress-benchmark { position: absolute; top: 0; height: 100%; width: 2px; background: rgba(255,255,255,0.35); }
.progress-benchmark-label { position: absolute; top: -16px; font-size: 10px; color: #94a3b8; transform: translateX(-50%); }

/* ─── Search Bar ──────────────────────────────────────── */
.search-bar { padding: 12px 20px; background: #151822; border-bottom: 1px solid #2a2d3a; }
.search-input {
  width: 100%; padding: 8px 12px; border: 1px solid #2a2d3a; border-radius: 6px;
  font-size: 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  background: #1a1d27; color: #e2e8f0;
}
.search-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.search-input::placeholder { color: #64748b; }

/* ─── Filter Chips ────────────────────────────────────── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 20px; border-bottom: 1px solid #2a2d3a; }
.chip {
  padding: 4px 12px; border-radius: 9999px; font-size: 12px; font-weight: 500;
  background: #252938; color: #94a3b8; border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.chip:hover { background: #2a2d3a; color: #e2e8f0; }
.chip-active { background: #6366f1; color: white; }
.chip-active:hover { background: #4f46e5; }

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; border-radius: 8px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s; border: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #6366f1; color: white; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.btn-primary:hover:not(:disabled) { background: #4f46e5; }
.btn-secondary { background: #1a1d27; color: #e2e8f0; border: 1px solid #2a2d3a; }
.btn-secondary:hover:not(:disabled) { background: #252938; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: none; color: #94a3b8; }
.btn-ghost:hover:not(:disabled) { background: #1a1d27; color: #e2e8f0; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-md { padding: 8px 16px; font-size: 14px; }
.btn-lg { padding: 10px 24px; font-size: 16px; }

/* ─── Charts ──────────────────────────────────────────── */
.chart-container {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 12px; padding: 16px;
  margin-bottom: 16px;
}
.chart-title { font-size: 15px; font-weight: 600; color: #e2e8f0; margin-bottom: 12px; }
.chart-scroll { overflow-x: auto; }
.chart-empty { text-align: center; color: #64748b; padding: 32px; font-size: 14px; }

/* Bar Chart - Horizontal */
.bar-chart-h { display: flex; flex-direction: column; gap: 10px; }
.bar-h-row { display: flex; align-items: center; gap: 10px; }
.bar-h-label { width: 90px; font-size: 13px; color: #e2e8f0; font-weight: 500; text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-h-track { flex: 1; height: 24px; background: #252938; border-radius: 6px; overflow: hidden; }
.bar-h-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; min-width: 2px; }
.bar-h-value { width: 60px; font-size: 13px; font-weight: 600; color: #e2e8f0; font-family: 'SF Mono', 'Fira Code', monospace; }

/* Bar Chart - Vertical SVG */
.bar-chart-svg { width: 100%; height: auto; max-height: 200px; }
.bar-v-rect { transition: opacity 0.2s; }
.bar-v-rect:hover { opacity: 0.8; }
.bar-v-val { font-size: 11px; fill: #e2e8f0; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.bar-v-label { font-size: 10px; fill: #94a3b8; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

/* Pie Chart */
.pie-chart-layout { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.pie-chart-svg { width: 160px; height: 160px; flex-shrink: 0; }
.pie-center-text { font-size: 18px; font-weight: 700; fill: #e2e8f0; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pie-legend-label { color: #e2e8f0; flex: 1; }
.pie-legend-value { color: #94a3b8; font-weight: 500; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }

/* Line Chart */
.line-chart-svg { width: 100%; height: auto; max-height: 200px; }
.chart-axis-text { font-size: 10px; fill: #64748b; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.chart-axis-label { font-size: 10px; fill: #94a3b8; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

/* ─── Chat Thread ─────────────────────────────────────── */
.chat-thread {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 12px; overflow: hidden;
}
.chat-thread-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #2a2d3a; background: #1e2333;
}
.chat-thread-title { font-size: 16px; font-weight: 600; color: #e2e8f0; }
.chat-thread-count { font-size: 12px; color: #94a3b8; background: #252938; padding: 2px 8px; border-radius: 9999px; }
.chat-thread-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; max-height: 600px; overflow-y: auto; }
.chat-msg { display: flex; align-items: flex-end; gap: 8px; }
.chat-msg-outbound { flex-direction: row; justify-content: flex-end; }
.chat-msg-inbound { flex-direction: row; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: white; font-weight: 600; font-size: 11px; flex-shrink: 0;
}
.chat-bubble-wrap { display: flex; flex-direction: column; max-width: 70%; }
.chat-bubble-wrap-right { align-items: flex-end; }
.chat-sender { font-size: 11px; font-weight: 600; color: #94a3b8; margin-bottom: 2px; padding: 0 4px; }
.chat-bubble {
  padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.45;
  word-break: break-word;
}
.chat-bubble-inbound { background: #252938; color: #e2e8f0; border-bottom-left-radius: 4px; }
.chat-bubble-outbound { background: #6366f1; color: white; border-bottom-right-radius: 4px; }
.chat-meta { font-size: 11px; color: #64748b; margin-top: 3px; padding: 0 4px; }

/* ─── Flow Diagram ────────────────────────────────────── */
.flow-diagram {
  background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 12px;
  padding: 20px; margin-bottom: 16px; overflow-x: auto;
}
.flow-title { font-size: 18px; font-weight: 600; color: #e2e8f0; margin-bottom: 16px; }
.flow-container { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 12px 0; }
.flow-node {
  padding: 12px 20px; border-radius: 10px; border: 2px solid; text-align: center;
  min-width: 160px; position: relative; background: #0f1117;
}
.flow-node-start { border-color: #22c55e; }
.flow-node-action { border-color: #6366f1; }
.flow-node-condition { border-color: #f59e0b; border-style: dashed; }
.flow-node-end { border-color: #64748b; }
.flow-node-label { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.flow-node-desc { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.flow-arrow {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 20px; color: #64748b; padding: 4px 0;
}
.flow-edge-label { font-size: 10px; color: #94a3b8; white-space: nowrap; }

/* ─── Card Grid ───────────────────────────────────────── */
.card-grid { display: grid; gap: 12px; }
.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) {
  .card-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ─── KV List ─────────────────────────────────────────── */
.kv-list { background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 12px; overflow: hidden; }
.kv-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; border-bottom: 1px solid #1e293b; }
.kv-row:last-child { border-bottom: none; }
.kv-label { font-size: 13px; color: #94a3b8; }
.kv-value { font-family: 'SF Mono', 'Fira Code', monospace; font-weight: 500; color: #e2e8f0; }

/* ─── Checklist ───────────────────────────────────────── */
.checklist-view { background: #1a1d27; border: 1px solid #2a2d3a; border-radius: 12px; overflow: hidden; }
.checklist-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #2a2d3a;
}
.checklist-title { font-size: 16px; font-weight: 600; color: #e2e8f0; }
.checklist-body { padding: 4px 0; }
.checklist-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid #1e293b; transition: background 0.15s;
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item:hover { background: #1e2333; }
.checklist-checkbox {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid #2a2d3a;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.checklist-checkbox-checked { background: #6366f1; border-color: #6366f1; color: white; }
.checklist-item-title { font-size: 14px; font-weight: 500; color: #e2e8f0; }
.checklist-item-title-done { text-decoration: line-through; color: #64748b; }

/* ─── Gauge ───────────────────────────────────────────── */
.gauge-container { display: flex; flex-direction: column; align-items: center; padding: 16px; }
.gauge-svg { width: 160px; height: 100px; }
.gauge-label { font-size: 12px; color: #94a3b8; margin-top: 8px; }
.gauge-value { font-size: 24px; font-weight: 700; color: #e2e8f0; }

/* ─── Utility ─────────────────────────────────────────── */
.clickable-row { cursor: pointer; transition: background 0.1s; }
.clickable-row:hover { background: #1e2333 !important; }
.muted { color: #94a3b8; }
.dim { color: #64748b; }
.small { font-size: 11px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
