@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Variables ─────────────────────────────────────────────── */
:root {
  --bg:         #080c18;
  --surface:    #0d1526;
  --surface-2:  #111d36;
  --border:     #1a2e50;
  --border-glow:#00d4ff33;
  --cyan:       #00d4ff;
  --cyan-dim:   #00d4ff99;
  --purple:     #8b5cf6;
  --green:      #00ff88;
  --orange:     #f59e0b;
  --red:        #ff4466;
  --text:       #e2e8f0;
  --text-muted: #64748b;
  --text-dim:   #94a3b8;
  --font:       'Space Grotesk', system-ui, sans-serif;
  --mono:       'JetBrains Mono', monospace;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --glow:       0 0 20px rgba(0,212,255,0.15);
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Grid overlay on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ─── Navbar ─────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 60px;
  background: rgba(8,12,24,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan);
  text-decoration: none;
}

.nav-brand:hover { text-decoration: none; }

.nav-icon {
  font-size: 1.3rem;
  animation: pulse-icon 3s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { text-shadow: 0 0 8px var(--cyan); opacity: 1; }
  50% { text-shadow: 0 0 20px var(--cyan), 0 0 40px var(--cyan); opacity: 0.8; }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-links a {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.2s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.nav-links a.active {
  color: var(--cyan);
  background: rgba(0,212,255,0.1);
}

.nav-cta {
  background: var(--cyan) !important;
  color: var(--bg) !important;
  font-weight: 600 !important;
}

.nav-cta:hover {
  background: #00aadd !important;
  color: var(--bg) !important;
}

/* ─── Page wrapper ───────────────────────────────────────────── */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-top: 60px;
}

/* ─── Container ──────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow), var(--glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--cyan);
  color: var(--bg);
}

.btn-primary:hover {
  background: #00aadd;
  box-shadow: 0 0 20px rgba(0,212,255,0.4);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan);
}

.btn-outline:hover {
  background: rgba(0,212,255,0.1);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--cyan-dim);
  color: var(--text);
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 1.05rem;
}

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--mono);
}

.badge-cyan { background: rgba(0,212,255,0.15); color: var(--cyan); }
.badge-purple { background: rgba(139,92,246,0.15); color: var(--purple); }
.badge-green { background: rgba(0,255,136,0.15); color: var(--green); }
.badge-orange { background: rgba(245,158,11,0.15); color: var(--orange); }
.badge-red { background: rgba(255,68,102,0.15); color: var(--red); }

/* ─── Hero ───────────────────────────────────────────────────── */
.hero {
  padding: 6rem 0 4rem;
  text-align: center;
  position: relative;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 1.5rem;
}

.hero-eyebrow::before, .hero-eyebrow::after {
  content: '';
  width: 30px;
  height: 1px;
  background: var(--cyan-dim);
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.hero-title .highlight {
  color: var(--cyan);
  position: relative;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 auto 2.5rem;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ─── Feature grid ───────────────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  padding: 2rem 0 4rem;
}

.feature-card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.25s;
}

.feature-card:hover {
  border-color: rgba(0,212,255,0.3);
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  display: block;
}

.feature-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.feature-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── How it works ───────────────────────────────────────────── */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0;
  position: relative;
  padding: 2rem 0 4rem;
}

.steps::before {
  content: '';
  position: absolute;
  top: 2.5rem;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan-dim), transparent);
}

.step {
  text-align: center;
  padding: 1rem;
  position: relative;
}

.step-num {
  width: 44px;
  height: 44px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cyan);
  font-family: var(--mono);
  box-shadow: 0 0 12px rgba(0,212,255,0.3);
}

.step-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.step-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ─── Section titles ─────────────────────────────────────────── */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.section-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 2rem;
}

/* ─── Upload Zone ────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.05);
  box-shadow: var(--glow);
}

.upload-zone.drag-over {
  border-style: solid;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

.upload-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.upload-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.upload-hint span {
  color: var(--cyan);
  font-weight: 500;
}

#file-input { display: none; }

/* ─── Detection layout ───────────────────────────────────────── */
.detect-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .detect-layout { grid-template-columns: 1fr; }
}

/* ─── Canvas container ───────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-placeholder {
  color: var(--text-muted);
  text-align: center;
  padding: 3rem;
}

.canvas-placeholder .ph-icon { font-size: 3rem; margin-bottom: 1rem; display: block; }
.canvas-placeholder p { font-size: 0.9rem; }

#preview-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Scanning line animation */
.canvas-wrap.scanning::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  animation: scanline 1.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scanline {
  0%   { top: 0; opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ─── Results panel ──────────────────────────────────────────── */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detection-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 480px;
  overflow-y: auto;
}

.detection-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: slide-in 0.3s ease both;
  transition: border-color 0.2s;
}

.detection-card:hover { border-color: var(--cyan-dim); }

@keyframes slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.det-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.det-label {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  text-transform: capitalize;
}

.det-conf {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--cyan);
}

.conf-bar-wrap {
  width: 60px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.conf-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ─── Loading state ──────────────────────────────────────────── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8,12,24,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
  border-radius: var(--radius);
}

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

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

.loading-text {
  font-size: 0.9rem;
  color: var(--cyan);
  font-family: var(--mono);
  animation: blink 1s step-end infinite;
}

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

/* ─── Alert / Error ──────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error {
  background: rgba(255,68,102,0.1);
  border: 1px solid rgba(255,68,102,0.3);
  color: var(--red);
}

.alert-success {
  background: rgba(0,255,136,0.1);
  border: 1px solid rgba(0,255,136,0.3);
  color: var(--green);
}

.alert-info {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.3);
  color: var(--cyan);
}

/* ─── Stats row ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: rgba(0,212,255,0.3);
  box-shadow: var(--glow);
}

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

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--cyan);
  line-height: 1.1;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ─── Chart wrapper ──────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 260px;
}

/* ─── History table ──────────────────────────────────────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.history-table th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: middle;
}

.history-table tr:last-child td { border-bottom: none; }

.history-table tr:hover td {
  background: var(--surface-2);
  color: var(--text);
}

.history-table .det-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.det-chip {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(0,212,255,0.1);
  color: var(--cyan);
  border: 1px solid rgba(0,212,255,0.2);
  font-family: var(--mono);
}

/* ─── Labels bar chart (dashboard) ───────────────────────────── */
.label-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.label-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 40px;
  align-items: center;
  gap: 0.75rem;
}

.label-bar-name {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
}

.label-bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.label-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  transition: width 0.6s ease;
}

.label-bar-count {
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--text-muted);
  text-align: right;
}

/* ─── About / tech stack ─────────────────────────────────────── */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.tech-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.tech-block-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.75rem;
}

.tech-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.tech-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.tech-list li::before {
  content: '▸';
  color: var(--cyan);
  font-size: 0.7rem;
}

.pipeline-steps {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.pipe-step {
  flex: 1;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1rem 0.75rem;
  text-align: center;
  position: relative;
  font-size: 0.85rem;
}

.pipe-step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.pipe-step:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }

.pipe-step:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cyan);
  font-size: 1rem;
  z-index: 1;
}

.pipe-icon { font-size: 1.4rem; display: block; margin-bottom: 0.3rem; }
.pipe-label { font-size: 0.8rem; color: var(--text-muted); }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ─── Footer ─────────────────────────────────────────────────── */
.footer {
  margin-top: 4rem;
  padding: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-cyan { color: var(--cyan); }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--mono); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .navbar { padding: 0 1rem; }
  .nav-links a { padding: 0.4rem 0.6rem; font-size: 0.82rem; }
  .hero { padding: 4rem 0 2.5rem; }
  .steps::before { display: none; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
