/* Judicium AI Execution Engine — App Styles */

/* Design tokens from landing page */
:root {
  --bg: #0A0D12;
  --bg-2: #0F1219;
  --surface: #131620;
  --surface-2: #1A1E2A;
  --border: #1E2433;
  --border-bright: #2A3045;
  --fg: #E8ECF2;
  --fg-2: #9AA3B5;
  --fg-3: #5C6578;
  --accent: #00E5A0;
  --accent-dim: rgba(0, 229, 160, 0.12);
  --accent-glow: rgba(0, 229, 160, 0.25);
  --red: #FF5E5E;
  --yellow: #F5C542;
  --green: #00E5A0;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── Header ─── */
.app-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-logo {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-logo span {
  color: var(--accent);
}

.app-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.app-nav a {
  color: var(--fg-2);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.app-nav a:hover, .app-nav a.active {
  color: var(--accent);
}

/* ─── Main Layout ─── */
.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* ─── Test Case Input ─── */
.input-section {
  margin-bottom: 2.5rem;
}

.input-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  display: block;
}

.test-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.6;
}

.test-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.test-input::placeholder {
  color: var(--fg-3);
}

.input-hint {
  font-size: 0.75rem;
  color: var(--fg-3);
  margin-top: 0.5rem;
}

/* ─── Run Button ─── */
.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 0.625rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 1rem;
}

.run-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.run-btn:active:not(:disabled) {
  transform: translateY(0);
}

.run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.run-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.run-btn.running .spinner { display: block; }
.run-btn.running .btn-text { display: none; }
.run-btn.running .btn-loading { display: inline; }
.run-btn .btn-loading { display: none; }

/* ─── Results ─── */
.results-section {
  margin-top: 2.5rem;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.results-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
}

.results-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 100px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.results-badge.passed {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 160, 0.25);
}

.results-badge.failed {
  background: rgba(255, 94, 94, 0.12);
  color: var(--red);
  border: 1px solid rgba(255, 94, 94, 0.25);
}

.results-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Steps ─── */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.step-card:hover {
  border-color: var(--border-bright);
}

.step-card.passed { border-left: 3px solid var(--accent); }
.step-card.failed { border-left: 3px solid var(--red); }

.step-header {
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.step-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--fg-3);
  flex-shrink: 0;
}

.step-card.passed .step-number {
  background: var(--accent-dim);
  border-color: rgba(0, 229, 160, 0.3);
  color: var(--accent);
}

.step-card.failed .step-number {
  background: rgba(255, 94, 94, 0.12);
  border-color: rgba(255, 94, 94, 0.3);
  color: var(--red);
}

.step-info {
  flex: 1;
  min-width: 0;
}

.step-action {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-action .action-type {
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.step-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.step-confidence {
  font-size: 0.6875rem;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.confidence-bar {
  width: 40px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.step-duration {
  font-size: 0.6875rem;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

.step-expand-icon {
  width: 16px;
  height: 16px;
  color: var(--fg-3);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.step-card.open .step-expand-icon {
  transform: rotate(180deg);
}

.step-detail {
  display: none;
  border-top: 1px solid var(--border);
  padding: 1rem;
  font-size: 0.8125rem;
}

.step-card.open .step-detail { display: block; }

.step-reasoning {
  color: var(--fg-2);
  margin-bottom: 0.75rem;
  font-style: italic;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.step-params {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  color: var(--fg-2);
  white-space: pre-wrap;
  word-break: break-all;
}

.step-result {
  padding: 0.625rem 0.875rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
}

.step-result.pass {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0, 229, 160, 0.2);
}

.step-result.fail {
  background: rgba(255, 94, 94, 0.1);
  color: var(--red);
  border: 1px solid rgba(255, 94, 94, 0.2);
}

.step-screenshot {
  margin-top: 0.75rem;
}

.step-screenshot img {
  width: 100%;
  max-width: 600px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.step-screenshot-label {
  font-size: 0.6875rem;
  color: var(--fg-3);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Empty / Loading States ─── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--fg-3);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg-2);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 360px;
  margin: 0 auto;
}

/* ─── Error ─── */
.error-alert {
  background: rgba(255, 94, 94, 0.08);
  border: 1px solid rgba(255, 94, 94, 0.2);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  color: var(--red);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* ─── Animations ─── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-card {
  animation: fadeInUp 0.3s ease-out both;
}

.step-card:nth-child(1) { animation-delay: 0ms; }
.step-card:nth-child(2) { animation-delay: 50ms; }
.step-card:nth-child(3) { animation-delay: 100ms; }
.step-card:nth-child(4) { animation-delay: 150ms; }
.step-card:nth-child(5) { animation-delay: 200ms; }
.step-card:nth-child(6) { animation-delay: 250ms; }

/* ─── Duration Summary ─── */
.duration-summary {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
}

.duration-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.duration-label {
  color: var(--fg-3);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.duration-value {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app-header { padding: 0.875rem 1.25rem; }
  .app-container { padding: 1.25rem; }
  .step-meta .step-confidence { display: none; }
  .duration-summary { flex-wrap: wrap; }
}

/* ─── Demo project banner ─── */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 229, 160, 0.08);
  border: 1px solid rgba(0, 229, 160, 0.25);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--fg-2);
}
.demo-banner .banner-icon { font-size: 1rem; flex-shrink: 0; }
.demo-banner .banner-text { flex: 1; line-height: 1.4; }
.demo-banner .banner-text strong { color: var(--accent); }
.demo-banner .banner-dismiss {
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.demo-banner .banner-dismiss:hover { color: var(--fg); }

/* ─── App layout with examples panel ─── */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
}

/* ─── Examples panel (left sidebar) ─── */
.examples-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  position: sticky;
  top: 5rem;
}
.examples-panel-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.examples-panel-header h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
  margin: 0;
}
.examples-panel-header .example-project-name {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}
.examples-suite-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.75rem;
  color: var(--fg-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.example-case-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.625rem 1rem;
  cursor: pointer;
  color: var(--fg-2);
  font-size: 0.8125rem;
  font-family: var(--font-body);
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
  border-left: 2px solid transparent;
}
.example-case-btn:hover {
  background: var(--surface-2);
  color: var(--fg);
  border-left-color: var(--accent);
}
.example-case-btn .case-title {
  font-weight: 500;
  color: var(--fg);
  display: block;
  margin-bottom: 2px;
}
.example-case-btn .case-hint {
  font-size: 0.75rem;
  color: var(--fg-3);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.examples-panel-empty {
  padding: 1.5rem 1rem;
  color: var(--fg-3);
  font-size: 0.8125rem;
  text-align: center;
}
.examples-loading {
  padding: 1.5rem 1rem;
  color: var(--fg-3);
  font-size: 0.8125rem;
  text-align: center;
}