/* ==========================================================================
   Explorer — Shared CSS for benchmark explorer apps
   Sidebar + task list + main detail panel + trajectory viewer
   ========================================================================== */

/* Layout */
.app {
  display: grid;
  grid-template-columns: 440px 1fr;
  grid-template-rows: auto 1fr;
  height: calc(100vh - 32px);
  overflow: hidden;
  max-width: 1600px;
  margin: 16px auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.app-header {
  grid-column: 1 / -1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  overflow: hidden;
  background: var(--bg);
}

.sidebar-controls {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.search-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--ink);
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s var(--ease);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-row {
  display: flex;
  gap: var(--sp-2);
}

.filter-row select {
  flex: 1;
  padding: var(--sp-1) var(--sp-2);
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--ink-2);
  font-family: inherit;
  min-width: 0;
}

/* Task list */
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}

.task-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease);
  border: 1px solid transparent;
}

.task-item:hover {
  background: var(--bg-surface);
}

.task-item.active {
  background: var(--bg-surface);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.task-item-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.task-item-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
  margin-left: auto;
}

.task-item-bar {
  width: 6px;
  border-radius: 1px;
  min-height: 2px;
}

/* Mini badges */
.mini-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  line-height: 1.6;
}

/* Summary bar */
.summary-bar {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
  font-size: 0.75rem;
  color: var(--ink-3);
  flex-wrap: wrap;
}

.summary-bar strong {
  color: var(--ink-2);
  font-weight: 600;
}

/* Main content */
.main {
  overflow-y: auto;
  padding: var(--sp-8) var(--sp-10);
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.main.empty-state {
  align-items: center;
  justify-content: center;
}

.empty-msg {
  color: var(--ink-3);
  font-size: 0.9375rem;
}

/* Task header */
.task-header {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.task-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.task-badges {
  display: flex;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.8125rem;
  color: var(--ink-2);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.meta-chip strong {
  font-weight: 600;
  color: var(--ink);
}

/* Tabs */
.detail-tabs {
  display: flex;
  gap: var(--sp-2);
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--sp-2);
}

.detail-tab {
  padding: var(--sp-2) var(--sp-4);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink-3);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.detail-tab:hover {
  color: var(--ink);
  background: var(--bg-surface);
}

.detail-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* Section heading */
.section-heading {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: var(--sp-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Instruction text */
.instruction-text {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  padding: var(--sp-5);
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* Score bars */
.scores-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.score-row {
  display: grid;
  grid-template-columns: 180px 1fr 48px;
  align-items: center;
  gap: var(--sp-4);
}

.score-label {
  font-size: 0.875rem;
  color: var(--ink-2);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-bar-bg {
  height: 24px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s var(--ease);
}

.score-pct {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Trials table */
.trials-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.trials-table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  color: var(--ink-2);
  border-bottom: 2px solid var(--line);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.trials-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.trials-table tr:hover td {
  background: oklch(95.5% 0.01 55 / 50%);
}

.result-pass {
  color: oklch(45% 0.18 145);
  font-weight: 600;
}

.result-fail {
  color: oklch(50% 0.2 27);
  font-weight: 600;
}

/* Trajectory viewer */
.traj-viewer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.traj-picker {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.traj-picker-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
}

.traj-picker-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 64px;
}

.traj-btn {
  padding: var(--sp-1) var(--sp-3);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.traj-btn:hover {
  border-color: var(--line-hover);
  color: var(--ink);
}

.traj-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.traj-btn.pass {
  border-color: oklch(72% 0.19 145 / 40%);
}

.traj-btn.fail {
  border-color: oklch(63% 0.24 27 / 40%);
}

/* Trajectory steps */
.traj-steps {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.traj-step {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  content-visibility: auto;
  contain-intrinsic-size: auto 80px;
}

.step-badge {
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

.step-tools {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

/* Tool calls */
.tool-call {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid oklch(88% 0.015 55 / 80%);
}

.tool-call-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  background: oklch(92% 0.01 55);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.tool-call-header:hover {
  background: oklch(90% 0.012 55);
}

.tool-call-header .tool-fn {
  font-family: var(--font-mono);
  color: oklch(40% 0.18 270);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.tool-call-header .tool-preview {
  color: var(--ink-3);
  font-weight: 400;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.tool-call-header .tool-arrow {
  margin-left: auto;
  color: var(--ink-3);
  transition: transform 0.15s var(--ease);
  font-size: 0.6875rem;
  flex-shrink: 0;
}

.tool-call-header.open .tool-arrow {
  transform: rotate(90deg);
}

.tool-call-body {
  display: block;
}

.tool-call-body.collapsed {
  display: none;
}

.tool-call-cmd {
  padding: var(--sp-2) var(--sp-3);
  background: oklch(15% 0.01 55);
  color: oklch(85% 0.01 55);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.tool-call-obs {
  padding: var(--sp-2) var(--sp-3);
  background: oklch(96% 0.008 55);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  border-top: 1px solid oklch(88% 0.015 55 / 80%);
}

/* Step expand button */
.step-expand {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  padding: 0;
}

.step-expand:hover {
  color: var(--accent);
}

/* Loading bar */
.loading-bar {
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin: var(--sp-4) 0;
}

.loading-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: 2px;
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* Responsive */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    margin: 0;
    height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 40vh;
  }
  .main {
    padding: var(--sp-5);
  }
}

/* Scrollbar */
.task-list::-webkit-scrollbar,
.main::-webkit-scrollbar {
  width: 6px;
}
.task-list::-webkit-scrollbar-thumb,
.main::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}
.task-list::-webkit-scrollbar-thumb:hover,
.main::-webkit-scrollbar-thumb:hover {
  background: var(--line-hover);
}
