/* MetricPulse App CSS — Test Generator UI */

:root {
  --bg: #080c14;
  --bg-card: #0e1420;
  --bg-card-hover: #131a28;
  --border: rgba(255,255,255,0.07);
  --border-bright: rgba(0,212,255,0.25);
  --accent: #00d4ff;
  --accent2: #0066ff;
  --text: #e8eaf0;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --good: #10b981;
  --bad: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --mono: 'DM Mono', 'Fira Code', monospace;
  --sans: 'Space Grotesk', system-ui, sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ──────────────────────────────── */
.app-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: rgba(8,12,20,0.9);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.app-header .container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 17px;
}

.beta-tag {
  background: rgba(0,212,255,0.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid rgba(0,212,255,0.2);
}

/* ── Main ────────────────────────────────── */
.app-main {
  padding: 48px 0 80px;
}

/* ── Sections ────────────────────────────── */
.generator-section,
.config-section,
.results-section,
.script-section,
.history-section {
  margin-bottom: 48px;
}

.generator-section h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(120deg, #e8eaf0 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 15px;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.hidden { display: none !important; }

/* ── Form ────────────────────────────────── */
.test-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.input-group {
  margin-bottom: 16px;
}

textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  padding: 14px 16px;
  resize: vertical;
  transition: border-color 0.2s;
  outline: none;
}

textarea:focus {
  border-color: var(--border-bright);
  background: rgba(0,212,255,0.03);
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent2), var(--accent));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

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

/* ── Loading ─────────────────────────────── */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px 0;
}

.loading-pulse {
  position: relative;
  width: 60px;
  height: 60px;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: pulse 1.8s ease-out infinite;
  opacity: 0;
}

.pulse-ring.delay-1 { animation-delay: 0.6s; }
.pulse-ring.delay-2 { animation-delay: 1.2s; }

@keyframes pulse {
  0% { transform: scale(0.3); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

#loadingMsg {
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Config grid ─────────────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.config-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.config-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.config-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

/* ── Metrics grid ────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: border-color 0.2s;
}

.metric-card.good { border-color: rgba(16,185,129,0.3); }
.metric-card.bad  { border-color: rgba(239,68,68,0.3); }

.metric-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.metric-card.good .metric-value { color: var(--good); }
.metric-card.bad  .metric-value { color: var(--bad); }

/* ── Latency chart ───────────────────────── */
.latency-chart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.lat-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.lat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.lat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  width: 32px;
  flex-shrink: 0;
}

.lat-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}

.lat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.lat-val {
  font-size: 13px;
  font-family: var(--mono);
  color: var(--text-dim);
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Status codes ────────────────────────── */
.status-codes {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.sc-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.sc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-code {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 14px;
  font-family: var(--mono);
}

.status-code.sc-2xx { color: var(--good); border-color: rgba(16,185,129,0.25); background: rgba(16,185,129,0.08); }
.status-code.sc-4xx { color: var(--warn); border-color: rgba(245,158,11,0.25); background: rgba(245,158,11,0.08); }
.status-code.sc-5xx { color: var(--bad);  border-color: rgba(239,68,68,0.25);  background: rgba(239,68,68,0.08);  }

/* ── Script section ──────────────────────── */
.script-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.script-header h2 {
  margin: 0;
  border: none;
  padding: 0;
}

.btn-copy {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy:hover { background: rgba(255,255,255,0.12); }

.code-block {
  margin-top: 16px;
  background: #050810;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: #a8c8f8;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

/* ── History ─────────────────────────────── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  transition: border-color 0.2s;
}

.history-item:hover { border-color: rgba(255,255,255,0.14); }

.history-desc {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 8px;
}

.history-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  align-items: center;
}

.history-status { font-weight: 600; text-transform: capitalize; }
.history-status.good { color: var(--good); }
.history-status.bad  { color: var(--bad);  }

.history-date { margin-left: auto; }

/* ── Error banner ────────────────────────── */
.error-banner {
  margin-top: 16px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  padding: 12px 16px;
  font-size: 14px;
}

/* ── Empty state ─────────────────────────── */
.empty-state {
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 600px) {
  .form-actions { flex-direction: column; align-items: flex-start; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .config-grid  { grid-template-columns: repeat(2, 1fr); }
  .lat-row      { gap: 8px; }
}
