/* ─────────────────────────────────────────────────────────────────────
   Scanfusion Hub — styles
   Visual vocabulary inherited from apps/scan-fusion/hub/ so this Hub
   feels like part of the same product family.

   Theme: light by default, dark via body.dark (matches existing hub).
   Persisted as localStorage key 'projects.theme' (same key as legacy hub
   so users with cached preference see it respected).
   ───────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f5f5f7;
  --fg: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --panel: #ffffff;
  --accent: #cbde67;
  --accent-soft: rgba(203, 222, 103, 0.20);
  --row-hover: rgba(0, 0, 0, 0.04);
  --good: #16a34a;
  --bad: #dc2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body.dark {
  --bg: #0a0a0f;
  --fg: #e0e0ec;
  --muted: #8888a0;
  --border: #2a2a3e;
  --panel: #12121a;
  --row-hover: rgba(255, 255, 255, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  transition: background 0.2s, color 0.2s;
}

/* ── Header (sticky) ──────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.brand-logo {
  height: 32px;
  width: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.badge {
  font-size: 11px;
  color: var(--fg);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

.spacer { flex: 1; }

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

.btn {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}

.btn:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #0a0d14;
  border-color: var(--accent);
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

/* ── Main + grid ──────────────────────────────────────────────────── */

main {
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ── Cards ────────────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

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

.card h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  word-break: break-all;
  line-height: 1.35;
}

.card .client {
  font-size: 12px;
  color: var(--muted);
  margin: -8px 0 0;
}

/* ── Stat pills ───────────────────────────────────────────────────── */

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stat {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat.has  { color: var(--good); border-color: rgba(22, 163, 74, 0.3); }
.stat.miss { color: var(--muted); opacity: 0.7; }
.stat.size { color: var(--fg); }
.stat.code { color: var(--fg); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ── Card actions ─────────────────────────────────────────────────── */

.actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.actions a,
.actions button {
  flex: 1;
  text-align: center;
}

/* ── Empty / error states ─────────────────────────────────────────── */

.empty,
.error {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--bad);
}

/* ── Toast ────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 100;
}

#toast.show {
  opacity: 1;
}

#toast.error {
  background: var(--bad);
  color: #fff;
}

/* ── User chip in header ──────────────────────────────────────────── */

.user-email {
  font-size: 12px;
  color: var(--muted);
  margin-right: 8px;
}

/* ── Login page ───────────────────────────────────────────────────── */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
}

.login-card .subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.login-error {
  margin-bottom: 20px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--bad);
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
}

.login-error code {
  background: rgba(220, 38, 38, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.login-btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

/* ── Share modal ──────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-hover);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-section:last-child {
  border-bottom: none;
}

.modal-section h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.modal-section h3 .muted {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.mint-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
}

.mint-row label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--muted);
  gap: 4px;
}

.mint-row input,
.mint-row select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
}

.share-links-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.share-link-meta {
  flex: 1;
  min-width: 0;
}

.share-link-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.share-link-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.share-link-actions {
  display: flex;
  gap: 6px;
}

.btn.small {
  padding: 4px 10px;
  font-size: 11px;
}

/* ── Footer ───────────────────────────────────────────────────────── */

footer {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.7;
}
