/* Appliance Image Scraper — Admin Dashboard */

:root {
  --bg: #f5f5f5;
  --surface: #fff;
  --border: #ddd;
  --text: #222;
  --muted: #666;
  --primary: #2563eb;
  --high: #16a34a;
  --medium: #d97706;
  --low: #dc2626;
  --nav-bg: #1e293b;
  --nav-text: #f8fafc;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* Nav */
nav {
  background: var(--nav-bg);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 48px;
}
nav a { color: var(--nav-text); text-decoration: none; opacity: 0.8; }
nav a:hover { opacity: 1; }
.nav-brand { font-weight: 600; font-size: 15px; opacity: 1 !important; margin-right: 12px; }

/* Main */
main {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px;
}

h2 { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
h4 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
p { margin-bottom: 10px; }
code { background: #f1f1f1; padding: 1px 5px; border-radius: 3px; font-family: monospace; }
.muted { color: var(--muted); font-size: 12px; }
.error { color: var(--low); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}
.stat-number { font-size: 36px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.high .stat-number { color: var(--high); }
.stat-card.medium .stat-number { color: var(--medium); }
.stat-card.low .stat-number { color: var(--low); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}
th {
  background: #f8f8f8;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.high   { background: #dcfce7; color: var(--high); }
.badge.medium { background: #fef3c7; color: var(--medium); }
.badge.low    { background: #fee2e2; color: var(--low); }

/* Buttons */
button, .btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
}
button:hover, .btn:hover { background: #f0f0f0; }
.btn-enable { border-color: var(--high); color: var(--high); }
.btn-enable:hover { background: #dcfce7; }
.btn-disable { border-color: var(--low); color: var(--low); }
.btn-disable:hover { background: #fee2e2; }

/* Forms */
form { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
input[type="text"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
}
input[type="text"]:focus { outline: 2px solid var(--primary); border-color: transparent; }
form button[type="submit"] {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  width: fit-content;
}
form button[type="submit"]:hover { background: #1d4ed8; }

/* Image grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.image-card img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  background: #f8f8f8;
  padding: 8px;
}
.card-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card-info strong { font-size: 13px; }
.card-info small { font-size: 11px; color: var(--muted); }

/* Result card */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.result-meta { flex: 1; }
.result-meta h3 { font-size: 18px; margin-bottom: 10px; }
.result-meta p { margin-bottom: 8px; }

/* Pagination */
.pagination {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
}
.pagination a {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--primary);
}
.pagination a:hover { background: #f0f0f0; }

/* Quick test buttons */
.test-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.test-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--primary);
  background: #eff6ff;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}
.test-btn:hover {
  background: var(--primary);
  color: white;
}

/* Reject button */
.btn-reject {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--low);
  background: #fee2e2;
  color: var(--low);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}
.btn-reject:hover {
  background: var(--low);
  color: white;
}

/* ─── Usage Dashboard ───────────────────────────────────────────────────── */
.usage-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.usage-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.usage-card-header h3 { margin: 0 0 4px 0; }
.usage-meta { font-size: 12px; color: #64748b; margin: 0; }
.usage-stats { display: flex; gap: 20px; }
.usage-stat { text-align: center; }
.stat-num { display: block; font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { display: block; font-size: 11px; color: #64748b; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.usage-last { font-size: 12px; color: #64748b; margin: 10px 0 12px; }
.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 60px;
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 8px 0;
  overflow: hidden;
}
.usage-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.usage-bar {
  width: 100%;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.7;
}
.usage-bar-label { font-size: 8px; color: #94a3b8; margin-top: 2px; }
.usage-chart-label { font-size: 11px; color: #94a3b8; margin: 4px 0 0; text-align: right; }

/* ─── Live Stats Bar ────────────────────────────────────────────────────── */
.live-stats-bar {
  background: #0f172a;
  color: #94a3b8;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 5px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #1e293b;
}
.live-stats-bar .lsb-sep { color: #334155; }
.live-stats-bar .lsb-item { color: #cbd5e1; white-space: nowrap; }

/* ─── Notices ───────────────────────────────────────────────────────────── */
.notice {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.notice-warn {
  background: #fffbeb;
  border: 1px solid #fbbf24;
  color: #92400e;
}

/* ─── Page-header action bars ────────────────────────────────────────────── */
/* Used on review, records, missing-models, customers, usage, database pages */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-header h2 { margin-bottom: 0; flex: 1 1 auto; }

/* Filter / tab bars */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* Tab nav (status tabs on review, decoder, missing-models) */
.tab-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}
.tab-nav a {
  padding: 6px 14px;
  font-size: 13px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-nav a:hover { color: var(--text); }
.tab-nav a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Action button row (inline form buttons + links together) */
.action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

/* ─── Table scroll wrappers ──────────────────────────────────────────────── */
/* Wrap tables in .table-wrap to get horizontal scroll on small screens */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}
.table-wrap table { margin-bottom: 0; min-width: 480px; }

/* Result card → stack on narrow screens */
@media (max-width: 640px) {
  .result-card { flex-direction: column; gap: 16px; }
  .result-card img { width: 100%; max-width: 320px; height: auto; align-self: center; }
}

/* ─── Age Decoder form grid ──────────────────────────────────────────────── */
.ad-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) {
  .ad-form-grid { grid-template-columns: 1fr; }
}

/* ─── Stats grid ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  table { font-size: 12px; }
  th, td { padding: 6px 5px; }
}

/* ─── Image grid ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ─── Pricing compare table ──────────────────────────────────────────────── */
@media (max-width: 700px) {
  .pricing-compare { overflow-x: auto; }
}

/* ─── Main content padding ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { padding: 0 12px; margin: 16px auto; }
}

/* ─── Live stats bar: scroll on tiny screens ─────────────────────────────── */
@media (max-width: 600px) {
  .live-stats-bar { overflow-x: auto; padding: 5px 12px; }
}

/* ─── Usage cards: stack stats on mobile ─────────────────────────────────── */
@media (max-width: 540px) {
  .usage-card-header { flex-direction: column; }
  .usage-stats { justify-content: flex-start; }
}

/* ─── Forms: full width on mobile ────────────────────────────────────────── */
@media (max-width: 540px) {
  form { max-width: 100%; }
}

/* ─── Pagination: tighter on mobile ─────────────────────────────────────── */
@media (max-width: 480px) {
  .pagination { gap: 6px; }
  .pagination a { padding: 5px 10px; font-size: 12px; }
}

/* ─── Nav topbar: shrink gaps on small screens ───────────────────────────── */
@media (max-width: 480px) {
  nav { padding: 0 12px; gap: 12px; }
}

/* ─── Tab nav: scroll horizontally on small screens (no wrapping) ────────── */
@media (max-width: 540px) {
  .tab-nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tab-nav a { flex-shrink: 0; }
}

/* ─── Filter/action/page-header bars: tighter on mobile ─────────────────── */
@media (max-width: 480px) {
  .filter-bar, .action-bar { gap: 6px; }
  .page-header { gap: 8px; }
  .page-header h2 { font-size: 16px; }
}

/* ─── Admin content area: reduce padding on tablet/mobile ───────────────── */
@media (max-width: 900px) {
  .acontent { padding: 20px 16px !important; }
}
@media (max-width: 600px) {
  .acontent { padding: 16px 12px !important; }
  .card { border-radius: 8px; }
}
