/* ═══════════════════════════════════════
   Boxster Intelligence — Premium Styles
   ═══════════════════════════════════════ */

:root {
  --navy: #0f0f1a;
  --dark: #1a1a2e;
  --mid: #2a2a4a;
  --light: #3a3a5a;
  --gold: #e3b43a;
  --gold-dim: #c49a2e;
  --red: #c62828;
  --green: #2e7d32;
  --bg: #f0f2f6;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #8888a0;
  --border: #e8eaf0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

#app { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: 220px;
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand-icon { font-size: 28px; }
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.brand-sub { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: var(--gold); color: var(--navy); font-weight: 700; }
.nav-item .nav-icon { font-size: 14px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.sidebar-stats span { color: var(--gold); font-weight: 700; }

/* ── MAIN ── */
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 32px;
  max-width: 1400px;
}

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.view-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--dark);
}

.view-sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.view-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-top: 4px;
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.card-body { padding: 16px 20px; }

/* ── LISTING GRID ── */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ── FILTER BAR ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  margin-bottom: 12px;
  align-items: center;
}

.filter-bar .filter-select {
  min-width: 120px;
  flex: 0 1 auto;
}

.filter-bar .filter-input {
  min-width: 80px;
  max-width: 120px;
  flex: 0 1 auto;
}

.filter-bar .filter-input[placeholder="Engine..."] {
  min-width: 100px;
  max-width: 140px;
}

.filter-bar .btn-sm {
  white-space: nowrap;
}

/* ── END FILTER BAR ── */

.listing-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.listing-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.listing-card .photo {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--border);
  display: block;
}

.listing-card .photo-placeholder {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, var(--dark), var(--mid));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--gold);
}

.listing-card .info {
  padding: 14px 16px 16px;
}

.listing-card .title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.listing-card .specs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.listing-card .spec {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.listing-card .price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.listing-card .price {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
}

.listing-card .price .pound { font-size: 16px; }

.listing-card .score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  color: white;
}

.score-excellent { background: var(--green); }
.score-good { background: #558b2f; }
.score-average { background: #f9a825; }
.score-poor { background: #e65100; }
.score-bad { background: var(--red); }

.listing-card .card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
}

.listing-card:hover .card-actions { opacity: 1; }

.listing-card .card-actions button {
  background: rgba(0,0,0,0.6);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}

.listing-card .card-actions button:hover { background: rgba(0,0,0,0.8); }
.listing-card .card-actions button.compare-active { background: var(--gold); color: var(--navy); }

.listing-card .reg-plate-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 3px 10px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.listing-card .verdict-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.verdict-strong_buy { background: #e8f5e9; color: #1b5e20; }
.verdict-buy { background: #e8f5e9; color: #2e7d32; }
.verdict-consider { background: #fff8e1; color: #e65100; }
.verdict-caution { background: #fff0f0; color: #c62828; }
.verdict-avoid { background: #ffebee; color: #b71c1c; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}

.modal-sm { max-width: 480px; }

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

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

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

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

.modal-body { padding: 20px 24px; }

/* ── FORMS ── */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: var(--transition);
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(227,180,58,0.15); }
.form-row { display: flex; gap: 10px; }
.flex-1 { flex: 1; }

/* ── BUTTONS ── */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: var(--gold-dim); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: var(--gold-dim); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b71c1c; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── SCANNER ── */
.scanner-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scanner-form .form-input,
.scanner-form .form-select { width: auto; min-width: 140px; flex: 1; }

/* ── SCAN RESULTS ── */
.scan-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.scan-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.scan-card .scan-photo {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: var(--border);
}

.scan-card .scan-body { padding: 10px 14px 14px; }
.scan-card .scan-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scan-card .scan-price { font-size: 18px; font-weight: 800; }
.scan-card .scan-specs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.scan-card .scan-spec { font-size: 11px; color: var(--text-muted); background: var(--bg); padding: 1px 6px; border-radius: 3px; }
.scan-card .scan-actions { margin-top: 8px; display: flex; gap: 6px; }

/* ── DETAIL MODAL CONTENT ── */
.detail-photo { width: 100%; max-height: 300px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 16px; background: var(--border); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.detail-item { padding: 8px 12px; background: var(--bg); border-radius: var(--radius-sm); }
.detail-item .label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.detail-item .value { font-size: 14px; font-weight: 600; margin-top: 1px; }

.detail-mot-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.detail-mot-table th { background: var(--dark); color: white; padding: 6px 10px; text-align: left; font-size: 11px; text-transform: uppercase; }
.detail-mot-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
.detail-mot-table tr:hover td { background: var(--bg); }
.mot-pass { color: var(--green); font-weight: 700; }
.mot-fail { color: var(--red); font-weight: 700; }

.risk-flags, .positive-indicators { list-style: none; margin: 6px 0; }
.risk-flags li, .positive-indicators li { padding: 4px 0 4px 20px; font-size: 13px; position: relative; }
.risk-flags li::before { content: '⚠'; position: absolute; left: 0; }
.positive-indicators li::before { content: '✓'; position: absolute; left: 0; color: var(--green); }

/* ── COMPARE ── */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.compare-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.compare-card.is-best { border-color: var(--green); }
.compare-card .compare-photo { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; background: var(--border); margin-bottom: 8px; }
.compare-card .compare-title { font-size: 11px; font-weight: 600; margin-bottom: 4px; }
.compare-card .compare-price { font-size: 18px; font-weight: 800; }
.compare-card .compare-stat { font-size: 12px; color: var(--text-muted); margin: 2px 0; }
.compare-card .best-badge { display: inline-block; background: var(--green); color: white; padding: 2px 10px; border-radius: 4px; font-size: 10px; font-weight: 700; margin-top: 6px; }

/* ── RECOMMENDATION ── */
.rec-hero {
  background: linear-gradient(135deg, var(--dark), var(--mid));
  border-radius: var(--radius);
  padding: 32px;
  color: white;
  text-align: center;
  margin-bottom: 20px;
}

.rec-hero .rec-score {
  font-size: 56px;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.rec-hero .rec-verdict { font-size: 16px; margin-top: 6px; opacity: 0.9; }
.rec-hero .rec-detail { font-size: 13px; margin-top: 4px; opacity: 0.6; }

.rec-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.rec-card .rec-rank { font-size: 20px; font-weight: 800; color: var(--gold); width: 36px; }
.rec-card .rec-info { flex: 1; }
.rec-card .rec-info h3 { font-size: 14px; font-weight: 600; }
.rec-card .rec-info p { font-size: 12px; color: var(--text-muted); }
.rec-card .rec-price { font-size: 18px; font-weight: 800; }
.rec-card .rec-score-sm { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: white; }

/* ── UTILITIES ── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 14px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* ── VERDICT TEXT ── */
.verdict-text { font-size: 16px; font-weight: 700; margin: 8px 0; }
.verdict-excellent { color: var(--green); }
.verdict-good { color: #558b2f; }
.verdict-average { color: #f9a825; }
.verdict-poor { color: #e65100; }
.verdict-bad { color: var(--red); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }
  .sidebar-brand .brand-text,
  .sidebar-nav .nav-item span:not(.nav-icon),
  .sidebar-footer { display: none; }
  .sidebar-brand { justify-content: center; padding: 16px 0; }
  .nav-item { justify-content: center; padding: 10px; }
  .main-content { margin-left: 60px; padding: 16px; }
  .listing-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .scanner-form .form-input,
  .scanner-form .form-select { min-width: 100%; }
}

@media (max-width: 480px) {
  .main-content { padding: 12px; }
  .view-header h1 { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-num { font-size: 20px; }
}
