/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #333;
  --green: #4ade80;
  --amber: #f59e0b;
  --orange: #f97316;
  --red: #ef4444;
  --text: #f0f0f0;
  --muted: #888;
  --radius: 12px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Layout ────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

header h1 { font-size: 1.25rem; font-weight: 700; }
header .badge {
  background: var(--green);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
}

.main-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  height: calc(100vh - 60px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.content {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Stats bar ─────────────────────────────────────────────── */
#stats-box {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  text-align: center;
  min-width: 90px;
}
.stat span { display: block; font-size: 1.5rem; font-weight: 700; color: var(--green); }
.stat small { color: var(--muted); font-size: 0.75rem; }

/* ── Drop zone ─────────────────────────────────────────────── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
}
#drop-zone:hover, #drop-zone.dragover {
  border-color: var(--green);
  background: #4ade8011;
  color: var(--text);
}
#drop-zone .drop-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

#img-preview {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  object-fit: cover;
  max-height: 200px;
}
#img-preview.hidden { display: none; }

/* ── Form ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.form-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
.form-group input:focus {
  outline: none;
  border-color: var(--green);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  background: var(--green);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.2s;
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:hover:not(:disabled) { opacity: 0.85; }

/* ── Spinner ───────────────────────────────────────────────── */
#spinner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}
#spinner.hidden { display: none; }
.spin {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result card ───────────────────────────────────────────── */
.result-card {
  border: 2px solid;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.result-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}
.stage-icon { font-size: 2.5rem; }
.result-header h2 { font-size: 1.4rem; font-weight: 800; }
.conf { color: var(--muted); font-size: 0.9rem; }

/* ── Metrics ───────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
}
.metric-card {
  background: var(--surface2);
  padding: 1.25rem 1.5rem;
}
.metric-card h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
.bar-row span:first-child { width: 70px; color: var(--muted); flex-shrink: 0; }
.bar-row span:last-child { width: 40px; text-align: right; flex-shrink: 0; }
.bar {
  flex: 1;
  background: var(--border);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.bar div {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ── Annotated image ───────────────────────────────────────── */
.annotated-img { padding: 1rem 1.5rem; }
.annotated-img p { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.5rem; }
.annotated-img img { width: 100%; border-radius: 8px; }

/* ── Inference time ────────────────────────────────────────── */
.inference-time {
  padding: 0.5rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── Maturity guide ────────────────────────────────────────── */
.maturity-guide { padding: 1rem 1.5rem; border-top: 1px solid var(--border); }
.guide-bar { display: flex; justify-content: space-between; gap: 4px; }
.guide-step {
  flex: 1;
  text-align: center;
  padding: 0.5rem 0.25rem;
  border-radius: 8px;
  background: var(--surface2);
  opacity: 0.35;
  transition: opacity 0.3s;
}
.guide-step.active { opacity: 1; background: color-mix(in srgb, var(--color) 20%, transparent); }
.guide-step span { display: block; font-size: 1.2rem; }
.guide-step small { font-size: 0.65rem; color: var(--muted); }

/* ── Section title ─────────────────────────────────────────── */
.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

/* ── Error ─────────────────────────────────────────────────── */
.error {
  background: #3f0000;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 1rem;
  border-radius: var(--radius);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main-grid { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .metrics-grid { grid-template-columns: 1fr; }
}
