/* ============================================
   YZ250 Tracker — Yamaha Racing Premium Theme
   ============================================ */

:root {
  --bg-dark-blue: #0A2D82;
  --bg-bright-blue: #0032A0;
  --bg-card: #0A2D82;
  --bg-card-hover: #123B9E;
  
  --border: rgba(255,255,255,0.15);
  --border-bright: rgba(255,255,255,0.35);

  --accent: #ffffff;
  --accent-glow: rgba(255, 255, 255, 0.3);

  --blue:   #3b82f6;
  --green:  #10b981;
  --amber:  #f59e0b;
  --red:    #ef4444;
  --purple: #8b5cf6;

  --text-primary:   #ffffff;
  --text-secondary: #cbd5e1;
  --text-muted:     #64748b;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow: none;
  --shadow-lg: none;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-bright-blue);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ──────────────────────────────── */

.header {
  position: relative;
  z-index: 100;
  padding: 40px 20px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-bright-blue);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.brand-logo {
  display: block;
  max-width: 320px;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}

.nav-tabs {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.nav-tab {
  padding: 8px 18px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: var(--border-bright);
}

.nav-tab.active {
  background: #ffffff;
  color: #0032a0;
  border-color: #ffffff;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.status-dot.idle { background: var(--green); box-shadow: 0 0 10px var(--green); }
.status-dot.running {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.85); }
}

.btn-scrape {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: #000000;
  border: none;
  border-radius: 100px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-display);
  box-shadow: 0 4px 16px rgba(255,255,255,0.2);
}

.btn-scrape:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(255,255,255,0.4);
}

.btn-scrape:active { transform: translateY(0); }
.btn-scrape:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── MAIN ────────────────────────────────── */

.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

/* ── STATS GRID ──────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: var(--shadow);
}

.stat-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--accent);
}
.stat-icon svg { width: 18px; height: 18px; }

.stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── SECTIONS ────────────────────────────── */

.section {
  margin-bottom: 48px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 24px;
  background: var(--accent);
}

/* ── PRICE CHART ─────────────────────────── */

.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  height: 320px;
  position: relative;
  width: 100%;
  box-shadow: var(--shadow);
}

.chart-loading {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* ── FILTERS ─────────────────────────────── */

/* ── FILTERS ─────────────────────────────── */

.filters-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  overflow: hidden;
  height: 40px;
}

.filter-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 0, 112, 243), 0.2);
}

.filter-icon, .filter-prefix {
  color: var(--text-muted);
  padding-left: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}

.filter-icon {
  width: 16px;
  height: 16px;
}

.filter-separator {
  color: var(--text-muted);
  font-size: 12px;
  padding: 0 4px;
}

.filters-container input,
.filters-container select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 0 12px;
  height: 100%;
  outline: none;
  min-width: 0;
}

.filters-container input[type="text"] { width: 180px; }
.filters-container input[type="number"] { width: 90px; text-align: center; }

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-color: var(--text-muted);
  clip-path: polygon(100% 0%, 0 0%, 50% 100%);
  pointer-events: none;
}

.filters-container select { 
  width: 160px;
  padding-right: 32px;
  appearance: none;
  cursor: pointer;
}

.filters-container input::placeholder { color: var(--text-muted); }

.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.toggle-container:hover {
  border-color: rgba(255, 255, 255, 0.3);
}
.toggle-container input {
  display: none;
}
.toggle-slider {
  width: 32px;
  height: 18px;
  background-color: var(--border);
  border-radius: 9px;
  position: relative;
  transition: 0.3s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: 0.3s;
}
.toggle-container input:checked + .toggle-slider {
  background-color: var(--blue);
}
.toggle-container input:checked + .toggle-slider::before {
  transform: translateX(14px);
}
.toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
}

/* ── LISTING META ────────────────────────── */

.listing-meta {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ── LISTINGS GRID ───────────────────────── */

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

@media (max-width: 700px) {
  .listings-grid { grid-template-columns: 1fr; }
}

/* Loading spinner */
.loading-spinner {
  grid-column: 1 / -1;
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 60px auto;
}

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

/* ── LISTING CARD ────────────────────────── */

.listing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow);
}

.listing-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.listing-card.new::before {
  content: 'NEW';
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 100px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.listing-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #111;
  display: block;
}

.listing-img-placeholder {
  width: 100%;
  height: 220px;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.listing-img-placeholder svg { width: 48px; height: 48px; opacity: 0.2; }

.listing-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.listing-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 45px; /* Ensures 2 lines of space to prevent card jumping */
}

.listing-price {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
}

.listing-price.no-price {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
}

.listing-meta-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.listing-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.listing-chip svg { width: 14px; height: 14px; opacity: 0.6; }

.listing-source {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 100px;
  padding: 3px 10px;
}

/* Iconic Blue tag (Gemini vision result) */
.listing-source.tag-iconic-blue {
  background: linear-gradient(135deg, #0033a0, #1e50c8);
  color: #fff;
  border-color: #6b8cff;
  box-shadow: 0 0 10px rgba(30, 80, 200, 0.55);
  cursor: help;
}

.toggle-container input#filterIconicBlue:checked + .toggle-slider {
  background: linear-gradient(135deg, #0033a0, #1e50c8);
}

.listing-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  background: var(--bg-dark-blue);
}

.listing-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.listing-link:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.listing-link svg { width: 14px; height: 14px; }

/* ── PAGINATION ──────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
}

.page-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 800;
}

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

/* ── FOOTER ──────────────────────────────── */

.footer {
  text-align: center;
  padding: 24px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  border-top: 1px solid var(--border);
}

/* ── EMPTY STATE ─────────────────────────── */

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: 20px; opacity: 0.2; }
.empty-state h3 { font-size: 18px; color: var(--text-primary); margin-bottom: 8px; font-weight: 700; }

/* ── TOAST NOTIFICATION ──────────────────── */

.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 350px;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: var(--red); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
