/* ==========================================================================
   Intelligent Model Router — Studio & Color-Coded Model Matrix
   Vikram Samal — Systems & Decision Architecture Lab
   ========================================================================== */

:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;
  
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #2563eb;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  
  --brand-blue: #2563eb;
  --brand-blue-hover: #1d4ed8;
  --brand-blue-light: #eff6ff;

  /* Color Codes for Model Matrix Tiers */
  --tier1-color: #059669; /* Emerald Green: Ultra-Lightweight / Utility */
  --tier1-bg: #ecfdf5;
  --tier1-border: #a7f3d0;

  --tier2-color: #0284c7; /* Cyan / Blue: Workhorse / Mid-tier */
  --tier2-bg: #f0f9ff;
  --tier2-border: #bae6fd;

  --tier3-color: #7c3aed; /* Purple / Violet: Advanced Reasoning */
  --tier3-bg: #f5f3ff;
  --tier3-border: #ddd6fe;

  --tier4-color: #dc2626; /* Rose / Amber: Flagship Frontier */
  --tier4-bg: #fef2f2;
  --tier4-border: #fecaca;
  
  --status-emerald: #059669;
  --status-emerald-bg: #ecfdf5;
  --status-emerald-border: #a7f3d0;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-secondary);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

code, pre, .mono-font {
  font-family: 'JetBrains Mono', monospace;
}

/* Top Navigation */
.top-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-xs);
  width: 100%;
}

.nav-wrapper {
  width: 100%;
  max-width: 100%;
  padding: 12px clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.98rem;
  font-weight: 600;
}

.badge-tag {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border: 1px solid #bfdbfe;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-secondary-nav:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.nav-link-active {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border-color: #bfdbfe;
}

/* Layout */
.layout-container {
  width: 100%;
  max-width: 100%;
  padding: 16px clamp(16px, 3vw, 40px) 60px;
}

/* Header Card */
.portal-header-card {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #ffffff;
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.portal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.portal-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.pill-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--status-emerald-bg);
  color: var(--status-emerald);
  border: 1px solid var(--status-emerald-border);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pulse-circle {
  width: 8px;
  height: 8px;
  background-color: var(--status-emerald);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 1.8s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Primary Two Tabs */
.primary-tabs-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}

.primary-tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

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

.primary-tab-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
}

.primary-tab-btn.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* ==========================================================================
   TAB 1: CHATGPT-STYLE PROMPT STUDIO & INTELLIGENT ROUTER
   ========================================================================== */
.studio-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.prompt-input-container {
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prompt-presets-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.preset-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  transition: all 0.12s ease;
}

.preset-chip:hover {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border-color: #bfdbfe;
}

.chip-tier1 { border-left: 3px solid var(--tier1-color); }
.chip-tier2 { border-left: 3px solid var(--tier2-color); }
.chip-tier3 { border-left: 3px solid var(--tier3-color); }

.prompt-textarea-box {
  width: 100%;
  background: #f8fafc;
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  transition: all 0.15s ease;
}

.prompt-textarea-box:focus {
  background: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.prompt-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-route-action {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
}

.btn-route-action:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* 3-Dimensional Routing Decision Telemetry */
.routing-decision-bar {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.decision-vector-grid {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.vector-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--border-medium);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  box-shadow: var(--shadow-xs);
}

.vector-pill strong {
  color: var(--text-primary);
}

.vector-frontier { border-left: 4px solid var(--tier2-color); }
.vector-price { border-left: 4px solid var(--tier1-color); }
.vector-discount { border-left: 4px solid #f59e0b; }

/* Side-by-Side Dual Execution Panels */
.dual-chat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  min-height: 460px;
}

@media (max-width: 992px) {
  .dual-chat-grid {
    grid-template-columns: 1fr;
  }
}

.chat-panel {
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.panel-routed {
  border-right: 1px solid var(--border-light);
  background: #fbfdff;
}

.panel-default {
  background: #fffdf9;
}

.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.model-spec-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.panel-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.panel-badge-routed {
  background: var(--tier2-bg);
  color: var(--tier2-color);
  border: 1px solid var(--tier2-border);
}

.panel-badge-default {
  background: var(--tier4-bg);
  color: var(--tier4-color);
  border: 1px solid var(--tier4-border);
}

.panel-telemetry {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
}

.telemetry-item { color: var(--text-muted); }
.telemetry-val { font-weight: 700; }
.text-cyan { color: var(--tier2-color); }
.text-amber { color: #d97706; }
.text-emerald { color: var(--status-emerald); }

.chat-stream-container {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.awaiting-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 10px;
  background: #ffffff;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  margin: auto 0;
  min-height: 380px;
}

.response-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.card-routed {
  border: 1px solid var(--tier2-border);
  border-left: 4px solid var(--tier2-color);
}

.card-default {
  border: 1px solid var(--tier4-border);
  border-left: 4px solid var(--tier4-color);
}

/* Symmetrical Response Text Box */
.response-output-box {
  background: #0f172a;
  color: #f1f5f9;
  border: 1px solid #1e293b;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.86rem;
  line-height: 1.6;
  height: 250px;
  min-height: 250px;
  max-height: 250px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.telemetry-footer-bar {
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

.footer-routed {
  background: var(--tier2-bg);
  border: 1px solid var(--tier2-border);
  color: var(--tier2-color);
}

.footer-default {
  background: var(--tier4-bg);
  border: 1px solid var(--tier4-border);
  color: var(--tier4-color);
}

.studio-comparison-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
}

.delta-badge {
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
}

.delta-badge-green {
  background: var(--status-emerald-bg);
  color: var(--status-emerald);
  border: 1px solid var(--status-emerald-border);
}

/* ==========================================================================
   TAB 2: COLOR-CODED MODEL MATRIX DIRECTORY
   ========================================================================== */
.matrix-section {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.matrix-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-subtle);
}

.tier-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.legend-tier1 { background: var(--tier1-bg); color: var(--tier1-color); border: 1px solid var(--tier1-border); }
.legend-tier2 { background: var(--tier2-bg); color: var(--tier2-color); border: 1px solid var(--tier2-border); }
.legend-tier3 { background: var(--tier3-bg); color: var(--tier3-color); border: 1px solid var(--tier3-border); }
.legend-tier4 { background: var(--tier4-bg); color: var(--tier4-color); border: 1px solid var(--tier4-border); }

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.83rem;
}

.matrix-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-medium);
}

.matrix-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: middle;
}

.matrix-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Tier Specific Row Borders & Badges */
.row-tier1 td:first-child { border-left: 4px solid var(--tier1-color); }
.row-tier2 td:first-child { border-left: 4px solid var(--tier2-color); }
.row-tier3 td:first-child { border-left: 4px solid var(--tier3-color); }
.row-tier4 td:first-child { border-left: 4px solid var(--tier4-color); }

.tier-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.frontier-rating-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.frontier-score-num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 0.85rem;
}

.frontier-progress-wrap {
  width: 70px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.frontier-progress-fill {
  height: 100%;
  border-radius: 9999px;
}

.btn-test-route {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  border: 1px solid #bfdbfe;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.btn-test-route:hover {
  background: var(--brand-blue);
  color: #ffffff;
}

.site-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}
