/* AtomCat Companion — mobile shell using the desktop app's dark theme tokens
   (src/renderer/styles.css). */

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

:root {
  --bg-base:       #0f1117;
  --bg-surface:    #181c27;
  --bg-elevated:   #1e2333;
  --bg-hover:      #252b3b;
  --border:        rgba(255,255,255,0.07);
  --accent:        #6c63ff;
  --accent-dim:    rgba(108,99,255,0.15);
  --accent-green:  #22c55e;
  --accent-orange: #f97316;
  --text-primary:  #e8eaf0;
  --text-secondary:#8890a4;
  --text-muted:    #4b5268;
  --radius:        10px;
  --radius-sm:     6px;
}

html, body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell ── */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
}
.app-title { font-weight: 700; letter-spacing: 0.02em; }
.sync-status { flex: 1; font-size: 11px; color: var(--text-muted); text-align: right; }
.sync-status.warn { color: var(--accent-orange); }
.icon-btn {
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-secondary);
  width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 16px; cursor: pointer;
}

main { padding: 14px 14px calc(74px + env(safe-area-inset-bottom)); }

.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--bg-surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 0 6px; font-size: 10.5px; color: var(--text-muted); text-decoration: none;
}
.tab.active { color: var(--accent); }
.tab-icon { font-size: 18px; line-height: 1.2; position: relative; }
.tab-badge {
  position: absolute; top: -4px; right: -12px; min-width: 16px; height: 16px;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; padding: 0 4px;
}

/* ── Controls ── */
.field {
  width: 100%; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  padding: 9px 12px; font-size: 14px; font-family: inherit;
}
.field:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; gap: 6px; margin: 10px 0; }
.chip {
  flex: 1; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-secondary);
  padding: 7px 0; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; }
.btn {
  display: inline-block; border: 0; background: var(--accent); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; font-family: inherit; text-align: center;
}
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.ghost { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.btn[disabled] { opacity: 0.4; }

/* ── Lists & rows ── */
.list { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; color: inherit; text-decoration: none;
}
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-name { font-size: 14px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 12px; color: var(--text-secondary); }
.hex-dot {
  flex-none; width: 16px; height: 16px; border-radius: 5px; border: 1px solid var(--border);
}
.hex-none { background: transparent; border-style: dashed; }
.hex-big { width: 28px; height: 28px; border-radius: 8px; }
.badge {
  flex-none; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  color: var(--text-muted); background: var(--bg-hover); white-space: nowrap;
}
.badge.in  { color: var(--accent-green); background: rgba(34,197,94,0.12); }
.badge.low { color: var(--accent-orange); background: rgba(249,115,22,0.12); }
.badge.out { color: #ef4444; background: rgba(239,68,68,0.12); }

/* ── Detail ── */
.back { display: inline-block; color: var(--text-secondary); text-decoration: none; font-size: 13px; margin-bottom: 12px; }
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.detail-head h2 { font-size: 17px; line-height: 1.3; }
.facts { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 12px; margin-bottom: 14px; }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.fact:last-child { border-bottom: 0; }
.fact-label { color: var(--text-muted); flex-none; }
.fact-value { text-align: right; overflow-wrap: anywhere; }
.fact-value code, .facts code {
  font-family: Consolas, Menlo, monospace; font-size: 12px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px;
}
.link-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Products ── */
.comp-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.prod-section { margin-top: 10px; }
.prod-section-hdr {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 12px; color: var(--text-primary); font-family: inherit; font-size: 14px;
  font-weight: 600; cursor: pointer; text-align: left;
}
.prod-caret { color: var(--text-muted); font-size: 10px; width: 14px; }
.prod-section-name { flex: 0 1 auto; }
.prod-section-hdr .badge { margin-left: auto; }
.prod-section .list { margin-top: 6px; }
.prod-price { font-size: 20px; font-weight: 700; color: var(--accent); margin: 4px 0 12px; }

/* Horizontal snap gallery — the "show it off" strip */
.gallery {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.gallery-item {
  flex: 0 0 min(78vw, 340px); scroll-snap-align: center;
  aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.gallery-item img, .gallery-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-ph {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
}

/* Self-authored ecommerce description HTML */
.prod-desc { font-size: 13.5px; color: var(--text-secondary); overflow-wrap: anywhere; }
.prod-desc p { margin-bottom: 8px; }
.prod-desc ul, .prod-desc ol { margin: 0 0 8px 18px; }
.prod-desc h1, .prod-desc h2, .prod-desc h3, .prod-desc h4 { color: var(--text-primary); font-size: 14px; margin: 10px 0 4px; }
.prod-desc a { color: var(--accent); }
.prod-desc img { max-width: 100%; border-radius: var(--radius-sm); }

/* ── Scan ── */
.scan-modes { display: flex; gap: 8px; margin-bottom: 12px; }
.scan-modes .chip.active[data-mode="receive"] { background: rgba(34,197,94,0.15); color: var(--accent-green); border-color: var(--accent-green); }
.scan-modes .chip.active[data-mode="use"] { background: rgba(249,115,22,0.15); color: var(--accent-orange); border-color: var(--accent-orange); }
.scan-stage {
  position: relative; aspect-ratio: 3/4; max-height: 46vh; border-radius: var(--radius);
  overflow: hidden; background: var(--bg-elevated); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.scan-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-stage .btn { position: relative; z-index: 1; }
.scan-reticle {
  position: absolute; left: 12%; right: 12%; top: 34%; bottom: 34%;
  border: 2px solid rgba(108,99,255,0.75); border-radius: 12px; pointer-events: none;
}
.scan-flash {
  margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border); font-size: 13.5px;
}
.scan-flash.ok  { border-color: rgba(34,197,94,0.5); }
.scan-flash.use { border-color: rgba(249,115,22,0.5); }
.scan-flash.err { border-color: rgba(239,68,68,0.5); }

/* ── Misc ── */
.card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 10px; }
.card h2 { color: var(--text-primary); }
.empty { color: var(--text-secondary); text-align: center; padding: 32px 12px; font-size: 14px; }
.hint { color: var(--text-muted); font-size: 12px; text-align: center; margin-top: 10px; }
