/* App-page styles (scanner, dashboard).
   Inherits design tokens from theme.css. */

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,10,10,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.app-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--fg); background: var(--bg-elevated); }

/* ── App shell ────────────────────────────────────────────────────────────── */
.app-main {
  min-height: calc(100vh - 56px);
  padding: 40px 24px 80px;
}

.app-container {
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.page-sub { color: var(--fg-muted); font-size: 1rem; }

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-box {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--fg);
  transition: border-color 0.15s;
  outline: none;
}

.search-input::placeholder { color: var(--fg-muted); }
.search-input:focus { border-color: var(--accent); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent);
  color: #000;
  padding: 12px 24px;
  font-size: 0.95rem;
}

.btn-primary:hover:not(:disabled) { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 12px 16px;
  font-size: 0.9rem;
}

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

.btn-danger {
  background: transparent;
  border: 1px solid #333;
  color: var(--fg-muted);
  padding: 8px 14px;
  font-size: 0.85rem;
}

.btn-danger:hover:not(:disabled) { border-color: #c0392b; color: #c0392b; }

.btn-saved {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: default;
}

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

/* ── Demo notice ──────────────────────────────────────────────────────────── */
.demo-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 200, 0, 0.08);
  border: 1px solid rgba(255, 200, 0, 0.2);
  color: #ffc107;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 24px;
}

.demo-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ffc107;
  flex-shrink: 0;
}

/* ── Results grid ─────────────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
}

.item-card:hover { border-color: rgba(0,230,118,0.2); }

.item-img-wrap { height: 160px; overflow: hidden; background: var(--bg-elevated); }

.item-img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 8px;
}

.item-img-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.item-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.item-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
}

.badge-demo {
  background: rgba(255, 200, 0, 0.08);
  border-color: rgba(255, 200, 0, 0.2);
  color: #ffc107;
}

/* ── Price rows ───────────────────────────────────────────────────────────── */
.item-prices { display: flex; flex-direction: column; gap: 4px; }

.price-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
}

.price-label { color: var(--fg-muted); }
.price-value { font-weight: 500; }

.margin-bar-wrap {
  background: var(--bg-elevated);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.margin-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.margin-bar.accent { background: var(--accent); }
.margin-bar.warn { background: #ffc107; }
.margin-bar.loss { background: #888; }

.margin-label { font-size: 0.8rem; font-weight: 600; margin-top: 2px; }

/* ── Color tokens ─────────────────────────────────────────────────────────── */
.accent { color: var(--accent); }
.warn { color: #ffc107; }
.loss { color: var(--fg-muted); }

/* ── Item actions ─────────────────────────────────────────────────────────── */
.item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

/* ── Empty / error states ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--fg-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon { font-size: 3rem; }
.empty-sub { font-size: 0.9rem; }

.error-state {
  color: #e74c3c;
  padding: 16px;
  background: rgba(231,76,60,0.08);
  border: 1px solid rgba(231,76,60,0.2);
  border-radius: 8px;
  font-size: 0.9rem;
}

/* ── Stats row (dashboard) ────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.stat-label { font-size: 0.8rem; color: var(--fg-muted); }

/* ── Dashboard list ───────────────────────────────────────────────────────── */
.dash-list { display: flex; flex-direction: column; gap: 12px; }

.dash-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: border-color 0.2s;
}

.dash-row:hover { border-color: rgba(0,230,118,0.15); }

.dash-img-wrap { width: 80px; flex-shrink: 0; }

.dash-img {
  width: 80px; height: 80px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--bg-elevated);
}

.dash-img-placeholder {
  width: 80px; height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 8px;
  font-size: 2rem;
}

.dash-info { flex: 1; min-width: 0; }

.dash-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-prices {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 6px;
}

.dash-prices strong { color: var(--fg); }

.dash-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.dash-listing {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.listing-ready-badge {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.modal-close:hover { color: var(--fg); }

.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }

.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--fg-muted);
  padding: 20px 0;
}

.modal-error { display: flex; flex-direction: column; gap: 12px; color: #e74c3c; }

/* ── Listing fields ───────────────────────────────────────────────────────── */
.listing-field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.field-value {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-muted);
  font-size: 0.78rem;
  padding: 4px 10px;
  cursor: pointer;
  align-self: flex-end;
  font-family: var(--font-body);
  transition: border-color 0.15s, color 0.15s;
}

.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .results-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dash-row { flex-direction: column; }
  .dash-actions { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .search-box { flex-direction: column; }
}
