/* ============================================================
   Pathway Testing - Styles
   ============================================================ */

:root {
  --bg:            #f6f7fb;
  --surface:       #ffffff;
  --surface-alt:   #f0f2f7;
  --border:        #e2e6ef;
  --border-strong: #cbd2e0;
  --text:          #1a1f2e;
  --text-muted:    #6b7280;
  --text-soft:     #9ca3af;

  --primary:       #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;

  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #3b82f6;
  --info-light:    #dbeafe;

  --radius:        8px;
  --radius-sm:     6px;
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow:        0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:     0 12px 32px rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

.hidden { display: none !important; }
.muted  { color: var(--text-muted); font-size: 13px; }

/* ----- Top bar ----- */

.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo  { font-size: 20px; }
.title { font-weight: 600; font-size: 15px; }
.subtitle { color: var(--text-soft); font-size: 12px; border-left: 1px solid var(--border); padding-left: 10px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-soft);
}
.status-dot.status-ok      { background: var(--success); }
.status-dot.status-bad     { background: var(--danger); }
.status-dot.status-unknown { background: var(--text-soft); }

/* ----- Layout ----- */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 52px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.sidebar-title {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.pathway-list { display: flex; flex-direction: column; gap: 2px; }

.pathway-group {
  margin-bottom: 12px;
}
.pathway-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 6px 4px 4px;
}

.pathway-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.1s;
}
.pathway-item:hover  { background: var(--surface-alt); }
.pathway-item.active { background: var(--primary-light); color: var(--primary); }
.pathway-item-name   { font-size: 13px; font-weight: 500; }
.pathway-item-meta   { font-size: 11px; color: var(--text-soft); }
.pathway-item.active .pathway-item-meta { color: var(--primary); opacity: 0.7; }

.empty-state {
  color: var(--text-soft);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

/* ----- Main panel ----- */

.main-panel { padding: 20px 28px; overflow-y: auto; }

.empty-panel {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.empty-panel-inner { text-align: center; max-width: 400px; }
.empty-panel-inner h2 { font-size: 20px; margin-bottom: 8px; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.meta-row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
}
.chip-muted    { background: var(--surface-alt); color: var(--text-muted); }
.chip-success  { background: var(--success-light); color: var(--success); }
.chip-danger   { background: var(--danger-light);  color: var(--danger); }
.chip-warning  { background: var(--warning-light); color: #92400e; }
.chip-info     { background: var(--info-light);    color: var(--info); }

.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----- Tabs ----- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  background: none;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.tab-panel        { display: none; }
.tab-panel.active { display: block; }

/* ----- Scenario list ----- */

.scenario-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.search-input {
  flex: 1;
  max-width: 320px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.search-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

.scenario-stats { font-size: 12px; color: var(--text-muted); }

.scenario-list, .runs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scenario-item, .run-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  transition: border-color 0.1s;
}
.scenario-item:hover, .run-item:hover { border-color: var(--border-strong); }

.scenario-checkbox { margin: 0; }

.scenario-main   { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.scenario-name   { font-weight: 500; font-size: 13px; color: var(--text); }
.scenario-desc   { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.scenario-badges { display: flex; gap: 4px; flex-wrap: wrap; }

.scenario-actions { display: flex; gap: 4px; }

.icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.icon-btn.run   { color: var(--primary); }
.icon-btn.run:hover { background: var(--primary-light); }

/* ----- Buttons ----- */

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s;
}

.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover     { background: var(--primary-hover); }
.btn-primary:disabled  { background: var(--border-strong); cursor: not-allowed; }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover    { background: var(--surface-alt); }
.btn-secondary:disabled { color: var(--text-soft); cursor: not-allowed; }

.btn-ghost     { background: none; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

/* ----- Modals ----- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-wide { max-width: 800px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  width: 28px; height: 28px;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ----- Forms ----- */

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  flex: 1;
}
.field-narrow { max-width: 120px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.field-hint {
  font-size: 11px;
  color: var(--text-soft);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
.field textarea { font-family: ui-monospace, "SF Mono", Monaco, monospace; font-size: 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.field-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 14px;
}
.field-toggle input { margin: 0; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.form-row .field { flex: 1; min-width: 180px; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.assertions-section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

.assertion-item {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 6px;
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 8px;
  align-items: center;
}
.assertion-item select, .assertion-item input, .assertion-item textarea { font-size: 12px; padding: 5px 7px; }

.health-box {
  padding: 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, "SF Mono", Monaco, monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----- Run results ----- */

.run-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.run-header h3 { margin-bottom: 4px; }
.run-scorecard { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.score-card {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.score-value { font-size: 18px; font-weight: 600; color: var(--text); }
.score-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-top: 2px; }

.run-section { margin-bottom: 18px; }
.run-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.transcript {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 12px;
}
.transcript-turn { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.transcript-turn:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.transcript-role {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 6px;
}
.transcript-role.user      { color: var(--info); }
.transcript-role.assistant { color: var(--primary); }

.assertion-result {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 12px;
  align-items: center;
}
.assertion-result.passed { border-color: var(--success); background: var(--success-light); }
.assertion-result.failed { border-color: var(--danger);  background: var(--danger-light); }

/* ----- Batch progress ----- */

.batch-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.batch-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 12px;
}
.batch-row.status-RUNNING { border-left: 3px solid var(--info); }
.batch-row.status-PASSED  { border-left: 3px solid var(--success); }
.batch-row.status-FAILED  { border-left: 3px solid var(--danger); }
.batch-row.status-ERROR   { border-left: 3px solid var(--warning); }
.batch-row.status-PENDING { border-left: 3px solid var(--text-soft); }

.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Toasts ----- */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--text);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  min-width: 220px;
  animation: slideIn 0.2s ease-out;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--info); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ----- Responsive ----- */

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 200px; border-right: none; border-bottom: 1px solid var(--border); }
  .run-scorecard, .batch-summary { grid-template-columns: repeat(2, 1fr); }
}
