/* ==========================================================
   VisionPulse Web — style.css
   Dark-mode first · Responsive · Modern glassmorphism
   ========================================================== */

:root {
  --bg-0:        #07070f;
  --bg-1:        #0f0f1e;
  --bg-2:        #16162a;
  --bg-3:        #1e1e38;
  --bg-glass:    rgba(22, 22, 42, 0.75);
  --border:      #2a2a4a;
  --border-glow: rgba(99, 102, 241, 0.4);
  --accent:      #6366f1;
  --accent-b:    #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.22);
  --teal:        #06b6d4;
  --text-1:      #f1f1fa;
  --text-2:      #9898bb;
  --text-3:      #55556e;
  --success:     #22d3ee;
  --warning:     #f59e0b;
  --error:       #ef4444;
  --r-sm: 8px;  --r-md: 14px;  --r-lg: 20px;  --r-xl: 28px;
  --shadow: 0 8px 40px rgba(0,0,0,0.6);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text-1);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Ambient gradient */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 55% 35% at 15% 8%,  rgba(99,102,241,.14) 0%, transparent 70%),
    radial-gradient(ellipse 45% 55% at 85% 90%, rgba(6,182,212,.09)  0%, transparent 70%);
}

/* ── App shell ──────────────────────────────────────── */
#app {
  position: relative; z-index: 1;
  width: 100%; max-width: 960px;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: 0 16px 32px;
  gap: 16px;
}

/* ── Header ─────────────────────────────────────────── */
header { padding: 28px 0 0; text-align: center; }

.logo-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 6px;
}
.logo-icon { font-size: 2.2rem; filter: drop-shadow(0 0 14px var(--accent)); }
h1 {
  font-size: 1.9rem; font-weight: 800; letter-spacing: -.6px;
  background: linear-gradient(130deg, #a5b4fc 0%, var(--teal) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { font-size: .82rem; color: var(--text-3); margin-top: 3px; }
.subtitle a { color: var(--accent-b); text-decoration: none; }
.subtitle a:hover { text-decoration: underline; }

/* ── Status bar ─────────────────────────────────────── */
#status-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 16px;
  font-size: .82rem; transition: border-color .3s;
}
#status-bar.ready   { border-color: var(--success); }
#status-bar.loading { border-color: var(--accent); }
#status-bar.error   { border-color: var(--error); }
#status-bar.busy    { border-color: var(--warning); }

.dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-3); transition: background .3s, box-shadow .3s;
}
#status-bar.ready   .dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
#status-bar.loading .dot { background: var(--accent);  box-shadow: 0 0 8px var(--accent); animation: pulse 1.1s infinite; }
#status-bar.busy    .dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); animation: pulse 1.1s infinite; }
#status-bar.error   .dot { background: var(--error);   box-shadow: 0 0 8px var(--error); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

#status-text { flex: 1; color: var(--text-2); }

#time-badge {
  font-size: .75rem; font-family: var(--mono);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; color: var(--teal);
  display: none;
}
#time-badge.visible { display: block; }

/* ── Progress ───────────────────────────────────────── */
#progress-wrap {
  height: 3px; background: var(--bg-3); border-radius: 2px;
  overflow: hidden; opacity: 0; transition: opacity .3s;
}
#progress-wrap.on { opacity: 1; }
#progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  border-radius: 2px; transition: width .25s ease;
  box-shadow: 0 0 8px var(--accent);
}

/* ── Two-column layout ──────────────────────────────── */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 680px) { .cols { grid-template-columns: 1fr; } }

/* ── Panel card ─────────────────────────────────────── */
.panel {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.panel-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 12px;
}

/* ── Upload zone ────────────────────────────────────── */
#drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  min-height: 120px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; padding: 20px;
  transition: border-color .2s, background .2s;
  color: var(--text-3); font-size: .88rem; text-align: center;
  margin-bottom: 14px;
}
#drop-zone:hover, #drop-zone.drag-over {
  border-color: var(--accent); background: rgba(99,102,241,.07);
  color: var(--text-2);
}
#drop-zone .drop-icon { font-size: 2rem; }
#file-input { display: none; }

/* ── Sample images ──────────────────────────────────── */
.samples-label {
  font-size: .72rem; color: var(--text-3); margin-bottom: 8px;
  letter-spacing: .05em; text-transform: uppercase;
}
.samples {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.sample-thumb {
  width: 80px; height: 60px; border-radius: var(--r-sm);
  object-fit: cover; cursor: pointer;
  border: 2px solid var(--border);
  transition: border-color .2s, transform .15s, box-shadow .2s;
  background: var(--bg-3);
}
.sample-thumb:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.sample-thumb.active { border-color: var(--teal); box-shadow: 0 0 10px rgba(6,182,212,.4); }

/* ── Confidence slider ──────────────────────────────── */
.slider-row {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
}
.slider-row label { font-size: .78rem; color: var(--text-2); white-space: nowrap; }
input[type="range"] {
  flex: 1; -webkit-appearance: none; height: 4px;
  border-radius: 2px; background: var(--bg-3); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow); cursor: pointer;
}
.slider-val {
  font-size: .78rem; font-family: var(--mono);
  color: var(--accent-b); min-width: 32px; text-align: right;
}

/* ── Canvas wrapper ─────────────────────────────────── */
#canvas-wrap {
  position: relative; border-radius: var(--r-md); overflow: hidden;
  background: var(--bg-3); min-height: 180px;
  display: flex; align-items: center; justify-content: center;
}
#canvas-wrap .placeholder {
  color: var(--text-3); font-size: .85rem; text-align: center; padding: 24px;
}
#main-canvas {
  display: block; max-width: 100%; border-radius: var(--r-md);
}

/* ── Detect button ──────────────────────────────────── */
#detect-btn {
  width: 100%; margin-top: 14px;
  padding: 12px; border: none; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: white; font-size: .95rem; font-weight: 600;
  cursor: pointer; letter-spacing: .02em;
  box-shadow: 0 4px 18px var(--accent-glow);
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
#detect-btn:hover:not(:disabled) {
  transform: translateY(-2px); box-shadow: 0 8px 24px var(--accent-glow);
}
#detect-btn:active:not(:disabled) { transform: translateY(0); }
#detect-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ── Results panel ──────────────────────────────────── */
#results-list { display: flex; flex-direction: column; gap: 8px; }

.det-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 10px 12px;
  animation: fadeUp .2s ease;
}
@keyframes fadeUp { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

.det-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
}
.det-label { flex: 1; font-size: .88rem; font-weight: 600; }
.det-score {
  font-size: .78rem; font-family: var(--mono);
  color: var(--text-2); flex-shrink: 0;
}
.det-bar-wrap {
  width: 100%; height: 3px; background: var(--bg-3);
  border-radius: 2px; margin-top: 5px; overflow: hidden; grid-column: 2/-1;
}
.det-bar { height: 100%; border-radius: 2px; }

.det-item { width: 100%; }
.det-top { display: flex; align-items: center; gap: 10px; }

#empty-state {
  text-align: center; color: var(--text-3); font-size: .85rem; padding: 32px 0;
}

/* ── JSON toggle ────────────────────────────────────── */
#json-wrap {
  margin-top: 12px;
}
#json-toggle {
  font-size: .75rem; color: var(--accent-b); background: none;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px;
  cursor: pointer; transition: border-color .2s, color .2s;
}
#json-toggle:hover { border-color: var(--accent); }
#json-block {
  display: none; margin-top: 8px;
  background: var(--bg-0); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px;
  font-family: var(--mono); font-size: .72rem; color: #94a3b8;
  overflow-x: auto; white-space: pre; max-height: 240px; overflow-y: auto;
}
#json-block.open { display: block; }

/* ── Footer ─────────────────────────────────────────── */
footer {
  text-align: center; font-size: .72rem; color: var(--text-3);
}
footer a { color: var(--accent-b); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
