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

:root {
  --bg:          #0f0f1a;
  --surface:     #1a1a2e;
  --surface2:    #252540;
  --border:      rgba(255,255,255,0.08);
  --primary:     #e63946;
  --primary-d:   #c1121f;
  --accent:      #ffd60a;
  --text:        #f0f0f5;
  --text-muted:  #8888aa;
  --green:       #52b788;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── HEADER ────────────────────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: 640px;
  margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; }

/* ── MAIN ──────────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 0 0 96px;
}

/* ── SECTIONS ──────────────────────────────────────────────────────────────── */
.section { display: none; padding: 16px; }
.section.active { display: block; }

/* ── CAMERA AREA ───────────────────────────────────────────────────────────── */
.camera-area {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1/1;
  width: 100%;
}
#videoFeed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.scan-frame {
  width: 72%;
  aspect-ratio: 1;
  position: relative;
  max-width: 260px;
}
.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255,255,255,0.85);
  border-style: solid;
}
.corner.tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.corner.tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
.camera-hint {
  margin-top: 16px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 99px;
}

/* ── FORMAT SELECTOR ───────────────────────────────────────────────────────── */
.format-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}
.format-selector-sm {
  margin-top: 10px;
}
.format-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
  max-width: 110px;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.format-btn .format-icon {
  font-size: 1.1rem;
  line-height: 1;
}
.format-btn:active { transform: scale(0.95); }
.format-btn.active {
  border-color: var(--primary);
  color: var(--text);
  background: rgba(230, 57, 70, 0.12);
}
.format-selector-sm .format-btn {
  flex-direction: row;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  max-width: none;
}
.format-selector-sm .format-btn .format-icon { display: none; }

/* ── CONTROLS ──────────────────────────────────────────────────────────────── */
.scan-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
}

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  -webkit-user-select: none;
  user-select: none;
  text-decoration: none;
}
.btn:active { transform: scale(0.96); }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-full { width: 100%; }
.btn-lg { padding: 16px 28px; font-size: 1.1rem; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

.icon-btn {
  background: var(--surface2);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }

/* ── SEARCH BAR ────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
}
.search-bar input {
  flex: 1;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--primary); }

/* ── STATUS & ERROR ────────────────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.error-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(230,57,70,0.15);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  margin: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  gap: 12px;
}
.error-bar button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
}

/* ── VISION RESULT ─────────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.result-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: rgba(255,214,10,0.1);
  padding: 3px 10px;
  border-radius: 99px;
}
.confidence-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.confidence-high { background: var(--green); }
.confidence-medium { background: var(--accent); }
.confidence-low { background: var(--primary); }

.result-body {
  display: flex;
  gap: 14px;
  padding: 14px;
  align-items: flex-start;
}
.result-thumb-wrap { flex-shrink: 0; }
.result-thumb {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.thumb-placeholder {
  width: 80px; height: 80px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.result-info { flex: 1; min-width: 0; }
.result-artist {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.result-meta span:not(:empty) {
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 99px;
  color: var(--text-muted);
}
.result-actions { padding: 0 14px 14px; }

/* ── RESULTS LIST ──────────────────────────────────────────────────────────── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.results-header h3 { font-size: 1rem; font-weight: 600; }

.results-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  -webkit-user-select: none;
  user-select: none;
}
.result-item:active { background: var(--surface2); border-color: var(--primary); }

.item-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--surface2);
}
.item-thumb-ph {
  width: 56px; height: 56px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.item-info { flex: 1; min-width: 0; }
.item-artist { font-size: 0.9rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-title { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.item-arrow { color: var(--text-muted); flex-shrink: 0; }
.item-arrow svg { width: 18px; height: 18px; }

/* ── DETAIL VIEW ───────────────────────────────────────────────────────────── */
.detail-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-weight: 600;
}
.detail-nav span { flex: 1; }

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.detail-hero {
  display: flex;
  gap: 14px;
  padding: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
}
.detail-img {
  width: 100px; height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--surface2);
}
.detail-hero-info { flex: 1; min-width: 0; }
.detail-hero-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.detail-hero-info h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.detail-meta span:not(:empty) {
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 99px;
  color: var(--text-muted);
}

/* ── PRIJZEN ───────────────────────────────────────────────────────────────── */
.price-section { padding: 16px; border-bottom: 1px solid var(--border); }
.price-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.price-heading { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0; }
.price-loading { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }
.price-error { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* Bron-badge */
.price-source-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.badge-nl    { background: rgba(82, 183, 136, 0.15); color: var(--green); }
.badge-mixed { background: rgba(255, 214, 10, 0.12); color: var(--accent); }
.badge-intl  { background: rgba(255,255,255,0.07);   color: var(--text-muted); }

/* Conditie-grid */
.price-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.price-chip {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.price-chip-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.price-chip-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.price-chip-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── NL AANBIEDERS ─────────────────────────────────────────────────────────── */
.listings-section {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.listings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.listings-heading {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.listings-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 99px;
}
.nl-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.nl-btn {
  justify-content: space-between;
  font-size: 0.9rem;
  border: 1.5px solid var(--border);
  margin-top: 8px;
}

/* ── GESCHIEDENIS ──────────────────────────────────────────────────────────── */
.history-list {
  list-style: none;
  padding: 0 16px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}
.history-item:active { opacity: 0.7; }
.history-thumb {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface3);
}
.history-info { flex: 1; min-width: 0; }
.history-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-artist {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.history-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  text-align: right;
}
.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
  font-size: 0.9rem;
}

/* ── TOAST ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 1000;
  white-space: nowrap;
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── SPINNERS ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABLET / DESKTOP ──────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  main { padding-bottom: 32px; }
  .camera-area { aspect-ratio: 16/9; }
  .price-grid, .nl-list { grid-template-columns: repeat(3, 1fr); }
}
