/* Rebricka — Dark theme, mobile-first */

:root {
  --bg:       #0a0a0a;
  --surface:  #141414;
  --surface2: #1e1e1e;
  --border:   #2a2a2a;
  --text:     #e8e8e8;
  --text-dim: #888;
  --text-faint: #555;

  --sell:    #00E676;    /* Green  — sälj enskilt */
  --maybe:   #FFD700;    /* Yellow — kanske */
  --bulk:    #666;       /* Gray   — bulk */
  --bulk-text:#aaa;
  --gold:    #FFB800;    /* Gold   — rare find */
  --danger:  #ff4444;
  --blue:    #4488ff;

  --touch-min: 48px;
  --radius:    8px;
  --gap:       12px;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Typography ──────────────────────────────────────────────────────────── */

h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }

.price { font-family: ui-monospace, 'Cascadia Code', monospace; font-variant-numeric: tabular-nums; }
.dim   { color: var(--text-dim); font-size: 0.85rem; }
.faint { color: var(--text-faint); font-size: 0.8rem; }

/* ── Login Screen ────────────────────────────────────────────────────────── */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 { font-size: 2rem; letter-spacing: -1px; }
.login-logo p  { color: var(--text-dim); margin-top: 4px; font-size: 0.9rem; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus { border-color: var(--blue); }

.login-error {
  background: rgba(255,68,68,0.1);
  border: 1px solid rgba(255,68,68,0.3);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.85rem;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: none;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 20px;
  text-decoration: none;
  transition: opacity 0.12s, transform 0.08s;
  -webkit-user-select: none;
}

.btn:active { opacity: 0.8; transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary   { background: var(--blue);  color: #fff; }
.btn-sell      { background: var(--sell);  color: #000; }
.btn-bulk      { background: #333;         color: var(--bulk-text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-ghost     { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-full      { width: 100%; }
.btn-sm        { min-height: 36px; font-size: 0.85rem; padding: 6px 14px; }

/* Scan trigger — big and unmissable */
.scan-trigger {
  width: 100%;
  min-height: 180px;
  font-size: 1.3rem;
  background: var(--surface2);
  border: 2px dashed var(--border);
  color: var(--text-dim);
  flex-direction: column;
  gap: 8px;
  border-radius: 12px;
}

.scan-trigger:active { border-color: var(--blue); color: var(--text); }
.scan-trigger .scan-icon { font-size: 3rem; line-height: 1; }

/* ── App Shell ───────────────────────────────────────────────────────────── */

#app { display: none; flex-direction: column; min-height: 100vh; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .logo { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.5px; }
.app-header .user-info { color: var(--text-dim); font-size: 0.85rem; }

/* ── Tab Bar ─────────────────────────────────────────────────────────────── */

.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--text-dim);
  background: transparent;
  transition: all 0.12s;
  min-height: 36px;
}

.tab.active {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}

.tab .tab-dot { width: 7px; height: 7px; border-radius: 50%; }
.tab-dot-active  { background: var(--sell); }
.tab-dot-paused  { background: var(--gold); }
.tab-dot-done    { background: var(--text-faint); }

.tab-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: transparent;
  transition: all 0.12s;
}

.tab-add:active { border-color: var(--blue); color: var(--blue); }

/* ── Main Content ────────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Dashboard ───────────────────────────────────────────────────────────── */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
  margin-bottom: 24px;
}

.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.quick-action:active { border-color: var(--blue); }
.quick-action .qa-icon { font-size: 1.8rem; }
.quick-action .qa-label { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }

.section-title {
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.session-card:active { border-color: var(--blue); }

.session-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.session-card-name { font-weight: 600; font-size: 0.95rem; }

.session-card-stats {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-sell  { color: var(--sell); }
.stat-bulk  { color: var(--bulk-text); }
.stat-value { color: var(--gold); font-family: ui-monospace, monospace; }

.total-stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.total-stat-item { text-align: center; }
.total-stat-value { font-size: 1.3rem; font-weight: 700; }
.total-stat-label { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ── Scan View ───────────────────────────────────────────────────────────── */

.scan-mode-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.12s;
}

.mode-pill.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* Scan result card */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 16px;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-card-body {
  display: flex;
  gap: 12px;
  padding: 14px;
}

.result-img {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}

.result-img-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.result-info { flex: 1; min-width: 0; }
.result-name { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-meta { color: var(--text-dim); font-size: 0.82rem; margin-top: 2px; }

.result-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
}

.result-price-main {
  font-family: ui-monospace, monospace;
  font-size: 1.2rem;
  font-weight: 700;
}

.result-price-quick {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Recommendation badge */
.rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 6px;
}

.rec-single { background: rgba(0,230,118,0.15); color: var(--sell);  border: 1px solid rgba(0,230,118,0.3); }
.rec-maybe  { background: rgba(255,215,0,0.12); color: var(--maybe); border: 1px solid rgba(255,215,0,0.3); }
.rec-bulk   { background: rgba(102,102,102,0.15); color: var(--bulk-text); border: 1px solid var(--border); }

/* Decision buttons */
.decision-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.decision-row .btn { flex: 1; font-size: 0.85rem; }
.decision-row .btn.active-decision { opacity: 1; box-shadow: 0 0 0 2px currentColor; }

/* Session stats bar */
.session-stats-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 16px;
}

.session-stats-bar strong { color: var(--text); }

/* ── Multi Scan Results ───────────────────────────────────────────────────── */

.multi-group {
  margin-top: 16px;
}

.multi-group-header {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 6px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.multi-group-header.sell  { color: var(--sell); }
.multi-group-header.bulk  { color: var(--bulk-text); }
.multi-group-header.maybe { color: var(--maybe); }

.multi-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.multi-item:last-child { border-bottom: none; }

.multi-item-info { flex: 1; min-width: 0; }
.multi-item-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.multi-item-meta { font-size: 0.78rem; color: var(--text-dim); }

.multi-item-price {
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
}

/* ── Build Mode ───────────────────────────────────────────────────────────── */

.build-suggestion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.build-rank { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 6px; }
.build-name { font-weight: 700; font-size: 1rem; }
.build-price { font-family: ui-monospace, monospace; font-size: 1.1rem; color: var(--gold); }

.progress-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: var(--sell);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.missing-parts { font-size: 0.82rem; color: var(--text-dim); }
.missing-part { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; }

/* ── Items List ───────────────────────────────────────────────────────────── */

.items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  transition: all 0.12s;
}

.filter-pill.active { background: var(--surface2); color: var(--text); }

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.item-row:last-child { border-bottom: none; }

.item-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}

.item-thumb-ph {
  width: 44px;
  height: 44px;
  background: var(--surface2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: 0.75rem; color: var(--text-dim); }

.item-price {
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
}

.decision-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.decision-dot-single { background: var(--sell); }
.decision-dot-bulk   { background: var(--bulk); }
.decision-dot-build  { background: var(--maybe); }
.decision-dot-undecided { background: var(--text-faint); }

/* ── Loading / Spinner ────────────────────────────────────────────────────── */

.scanning-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 500;
  display: none;
}

.scanning-overlay.active { display: flex; }

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

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

.scanning-text { color: var(--text); font-weight: 600; }
.scanning-sub  { color: var(--text-dim); font-size: 0.85rem; }

/* ── Modal ────────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.active { display: flex; }

.modal-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px 36px;
  width: 100%;
  max-width: 640px;
  animation: slideUpModal 0.25s ease;
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 16px; }

/* ── Confidence badge ─────────────────────────────────────────────────────── */

.conf-high   { color: var(--sell); }
.conf-medium { color: var(--maybe); }
.conf-low    { color: var(--danger); }

/* ── Notification toast ───────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.toast.show { opacity: 1; }

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}

.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-text { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-sub  { font-size: 0.85rem; }


/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 380px) {
  .quick-actions { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .quick-action  { padding: 12px 4px; }
  .quick-action .qa-icon { font-size: 1.5rem; }
}

@media (min-width: 640px) {
  .app-header { padding: 0 24px; }
  .main-content { padding: 24px; }
  .scan-trigger { min-height: 200px; }
}
