/* =============================================================
   Listing Scraper Dashboard — Style
   Clean stats card layout, Vietnamese UI
   ============================================================= */

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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #5b8ef0;
  --accent2: #38d9a9;
  --danger: #f06595;
  --warn: #ffa94d;
  --text: #e8eaf6;
  --text-muted: #7c85b0;
  --tag-bg: #1e2a45;
  --card-radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.header h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
.header .sub { color: var(--text-muted); font-size: 12px; }

/* ── Tabs ── */
.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Store Panel ── */
.store-panel { display: none; padding: 24px; }
.store-panel.active { display: block; }

/* ── Input Area ── */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px;
  margin-bottom: 24px;
}
.input-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.link-textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 80px;
  font-family: monospace;
}
.link-textarea::placeholder { color: var(--text-muted); }
.link-textarea:focus { outline: none; border-color: var(--accent); }

.btn-group { display: flex; flex-direction: column; gap: 8px; min-width: 120px; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-scrape { background: var(--accent2); color: #0f1117; }

.status-msg {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

/* ── Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Listing Card ── */
.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.listing-card:hover { border-color: var(--accent); }

.card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.card-img-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 32px;
}

.card-body { padding: 12px; }

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--accent); }

/* ── Stat rows ── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-muted); font-size: 11px; }
.stat-value { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.stat-value.sales { color: var(--accent2); }
.stat-value.views { color: var(--accent); }
.stat-value.favorites { color: var(--danger); }
.stat-value.velocity { color: var(--warn); }

.stat-value.up::before { content: '↑ '; color: var(--accent2); }
.stat-value.down::before { content: '↓ '; color: var(--danger); }
.stat-value.null-val { color: var(--text-muted); font-weight: 400; }

/* ── Price row ── */
.price-row {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}
.price-current { font-size: 15px; font-weight: 700; color: var(--accent2); }
.price-original { font-size: 12px; color: var(--text-muted); text-decoration: line-through; }
.price-discount { font-size: 11px; background: #2d1c1c; color: var(--danger); padding: 1px 6px; border-radius: 4px; }

/* ── Tags / Badges ── */
.card-tags {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-bestseller { background: #2a1a0d; color: var(--warn); }
.badge-sale { background: #1e0e1e; color: var(--danger); }
.badge-in-cart { background: #0e1e2a; color: var(--accent); }

/* ── Dates ── */
.snap-dates {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 24px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Loading ── */
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 13px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--accent2); }
.toast.error { border-color: var(--danger); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .header { padding: 12px 16px; }
  .tabs { padding: 0 12px; }
  .store-panel { padding: 16px 12px; }
  .input-row { flex-direction: column; }
  .btn-group { flex-direction: row; }
}
