/* App-specific styles — the /app page generator UI */

.app-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 100vh;
  padding-top: 65px; /* header offset */
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  overflow-y: auto;
  position: sticky;
  top: 65px;
  height: calc(100vh - 65px);
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 1.5rem;
  background: var(--bg);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.05);
}

.upload-icon {
  color: var(--accent);
  margin-bottom: 1rem;
}

.upload-zone h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.upload-zone p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.upload-zone input[type="file"] {
  display: none;
}

/* Or divider */
.or-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Textarea */
.spec-textarea {
  width: 100%;
  height: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Space Grotesk', monospace;
  font-size: 0.75rem;
  padding: 0.75rem;
  resize: none;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.spec-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.spec-textarea::placeholder {
  color: var(--text-muted);
}

/* Filename badge */
.file-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 107, 53, 0.1);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.file-badge-clear {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.25rem;
}

.file-badge-clear:hover { color: var(--text); }

/* Generate button */
.btn-generate {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-generate:hover:not(:disabled) {
  background: var(--accent-muted);
  transform: translateY(-1px);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Recent runs sidebar section */
.recent-runs {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.recent-run-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 0.5rem;
}

.recent-run-item:hover { background: var(--surface-hover); }

.run-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.run-status-dot.complete { background: #27ca40; }
.run-status-dot.running { background: var(--accent); animation: pulse 1.5s infinite; }
.run-status-dot.failed { background: #ff5f56; }
.run-status-dot.pending { background: var(--border); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.recent-run-meta { flex: 1; min-width: 0; }
.recent-run-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-run-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

/* Main area */
.main-area {
  padding: 2rem 2.5rem;
  overflow-y: auto;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  opacity: 0.3;
}

.empty-state h2 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  max-width: 420px;
  line-height: 1.7;
}

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1.5rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-steps {
  list-style: none;
  text-align: left;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.loading-steps li {
  padding: 0.375rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.loading-steps li.done { color: #27ca40; }
.loading-steps li.active { color: var(--text); }
.step-icon { font-size: 0.875rem; }

/* Scenarios section */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.risk-low    { background: rgba(39, 202, 64, 0.15); color: #27ca40; }
.risk-medium { background: rgba(255, 189, 46, 0.15); color: #ffbd2e; }
.risk-high   { background: rgba(255, 107, 53, 0.15); color: var(--accent); }
.risk-critical { background: rgba(255, 95, 86, 0.2); color: #ff5f56; }

/* Scenario cards */
.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.scenario-card:hover,
.scenario-card.selected {
  border-color: var(--accent);
}

.scenario-card.selected {
  background: rgba(255, 107, 53, 0.05);
}

.scenario-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.scenario-card h3 { font-size: 1rem; }

.scenario-card p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.scenario-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.step-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.6875rem;
  font-family: 'Space Grotesk', monospace;
  color: var(--text-muted);
}

.method-get    { color: #27ca40; }
.method-post   { color: var(--accent); }
.method-put    { color: #ffbd2e; }
.method-patch  { color: #ffbd2e; }
.method-delete { color: #ff5f56; }

.selected-check {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: white;
}

.scenario-card.selected .selected-check { display: flex; }

/* Profile selector */
.profile-selector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.profile-tab {
  flex: 1;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.profile-tab:hover { border-color: var(--accent); color: var(--text); }

.profile-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.profile-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.profile-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Risk summary */
.risk-summary-box {
  background: rgba(255, 107, 53, 0.06);
  border: 1px solid rgba(255, 107, 53, 0.3);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.risk-summary-box strong { color: var(--accent); }

/* Run button */
.btn-run {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-run:hover:not(:disabled) {
  background: var(--accent-muted);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(255, 107, 53, 0.3);
}

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

/* Running progress */
.running-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.progress-title { font-size: 0.9375rem; font-weight: 600; }

.progress-bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  font-size: 0.8125rem;
}

.progress-metric-label { color: var(--text-muted); }
.progress-metric-value { font-weight: 600; color: var(--text); margin-top: 0.125rem; }

/* Results */
.results-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grade-badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.grade-A { background: rgba(39, 202, 64, 0.15); color: #27ca40; }
.grade-B { background: rgba(100, 210, 200, 0.15); color: #64d2c8; }
.grade-C { background: rgba(255, 189, 46, 0.15); color: #ffbd2e; }
.grade-D { background: rgba(255, 107, 53, 0.15); color: var(--accent); }
.grade-F { background: rgba(255, 95, 86, 0.2); color: #ff5f56; }

.results-title { font-size: 1.25rem; }
.results-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.375rem;
}

.metric-label { font-size: 0.8125rem; color: var(--text-muted); }

/* Chart */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.chart-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.chart-container {
  height: 140px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  position: relative;
}

.chart-bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
  position: relative;
}

.chart-bar.latency { background: var(--accent); }
.chart-bar.error   { background: #ff5f56; }

.chart-y-labels {
  position: absolute;
  left: -2.5rem;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chart-y-label {
  font-size: 0.625rem;
  color: var(--text-muted);
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.625rem;
  color: var(--text-muted);
}

/* Endpoint table */
.endpoints-table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.endpoints-table-section .chart-title {
  padding: 1.25rem 1.5rem 0;
}

table.endpoints-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

table.endpoints-table th {
  background: var(--surface-hover);
  padding: 0.75rem 1.5rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

table.endpoints-table td {
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text);
}

table.endpoints-table tbody tr:hover { background: var(--surface-hover); }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.status-healthy  { background: rgba(39, 202, 64, 0.12); color: #27ca40; }
.status-warning  { background: rgba(255, 189, 46, 0.12); color: #ffbd2e; }
.status-degraded { background: rgba(255, 95, 86, 0.15); color: #ff5f56; }

/* Bottleneck call-out */
.bottleneck-box {
  background: rgba(255, 95, 86, 0.08);
  border: 1px solid rgba(255, 95, 86, 0.3);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.bottleneck-icon { font-size: 1.5rem; flex-shrink: 0; }
.bottleneck-title { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.25rem; }
.bottleneck-text  { font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }
.bottleneck-threshold {
  display: inline-block;
  margin-top: 0.5rem;
  background: rgba(255, 95, 86, 0.15);
  color: #ff5f56;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
}

/* New test button */
.btn-new-test {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.btn-new-test:hover { border-color: var(--accent); color: var(--accent); }

/* Hide/show utilities */
.hidden { display: none !important; }

/* Header launch link */
.launch-app-btn {
  background: var(--accent);
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.launch-app-btn:hover { background: var(--accent-muted); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Responsive */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .scenarios-grid { grid-template-columns: 1fr; }
  .profile-details { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .main-area { padding: 1.5rem 1rem; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
