/* ============================================================
   CarHaven - base styles
   ============================================================ */
:root {
  --blue-900: #21414f;
  --blue-700: #2f6690;
  --blue-600: #3d7aa4;
  --blue-500: #6c9cbd;
  --blue-100: #e9f1f6;
  --ink: #333f4c;
  --muted: #71808f;
  --border: #e3e7ea;
  --bg: #f7f8fa;
  --card: #ffffff;
  --danger: #c05c56;
  --amber: #cf9f4f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(33, 65, 79, 0.07), 0 1px 2px rgba(33, 65, 79, 0.05);
  --shadow-md: 0 4px 16px rgba(33, 65, 79, 0.09);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.25; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); }
.btn-secondary { background: var(--amber); color: #26210a; }
.btn-secondary:hover { filter: brightness(0.95); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: #f0f2f4; }
.btn-danger { background: #fdeceb; color: var(--danger); border-color: #f7d2cf; }
.btn-danger:hover { background: #fbdedb; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------------------------------------------------------- header ----- */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.topbar { background: var(--blue-900); color: #cfe9db; font-size: 13px; }
.topbar-inner { display: flex; justify-content: space-between; padding: 6px 20px; }
.topbar-links a { margin-right: 16px; opacity: .9; }
.topbar-links a:last-child { margin-right: 0; }
.topbar-links a:hover { opacity: 1; text-decoration: underline; }
.topbar-cta { background: var(--blue-500); color: #fff !important; padding: 3px 10px; border-radius: 6px; opacity: 1 !important; }

.main-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 800; color: var(--blue-700); white-space: nowrap; }
.logo b { color: var(--ink); }
.footer-logo { font-size: 20px; margin-bottom: 10px; }

.header-search { flex: 1; min-width: 220px; display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.header-search input { flex: 1; border: none; padding: 10px 14px; font-size: 14px; outline: none; }
.header-search button { border: none; background: var(--blue-600); color: #fff; padding: 0 16px; cursor: pointer; }
.header-search button:hover { background: var(--blue-700); }
.sell-cta { white-space: nowrap; }

.category-nav { border-top: 1px solid var(--border); background: #fafbfb; }
.category-nav-inner { display: flex; gap: 4px; padding: 4px 20px; overflow-x: auto; }
.nav-link { padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--blue-700); border-color: var(--blue-600); }

/* ------------------------------------------------------------- flash --- */
.flash { padding: 10px 0; font-size: 14px; text-align: center; }
.flash-success { background: var(--blue-100); color: var(--blue-700); }
.flash-error { background: #fdeceb; color: var(--danger); }

/* -------------------------------------------------------------- hero --- */
.hero { background: linear-gradient(135deg, var(--blue-700), var(--blue-900)); color: #fff; padding: 56px 0 64px; }
.hero h1 { font-size: 34px; max-width: 640px; }
.hero-sub { color: #d8ebe0; margin-bottom: 24px; }
.hero-search { display: flex; flex-wrap: wrap; gap: 8px; background: rgba(255,255,255,.08); padding: 10px; border-radius: 12px; }
.hero-search select, .hero-search input { padding: 11px 12px; border-radius: 8px; border: none; font-size: 14px; min-width: 140px; flex: 1; }
.hero-search .btn { flex: 0 0 auto; }
.hero-links { margin-top: 16px; display: flex; gap: 24px; font-size: 14px; }
.hero-links a { color: #fff; text-decoration: underline; opacity: .9; }
.hero-links a:hover { opacity: 1; }

/* ----------------------------------------------------------- sections -- */
.section { padding: 44px 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.see-all { color: var(--blue-600); font-weight: 600; font-size: 14px; }
.see-all:hover { text-decoration: underline; }

/* ------------------------------------------------------------ cards ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* ------------------------------------------------------- listing grid -- */
.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.listing-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; display: block; }
.listing-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.listing-card.is-featured { border-color: var(--amber); }
.listing-card-img { position: relative; aspect-ratio: 4/3; background: #eef1f3; overflow: hidden; }
.listing-card-img img { width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 4px 8px; border-radius: 5px; letter-spacing: .03em; }
.badge-featured { background: var(--amber); color: #26210a; }
.badge-status { position: static; margin-left: 6px; }
.badge-status-active { background: var(--blue-100); color: var(--blue-700); }
.badge-status-sold { background: #eee; color: #777; }
.badge-status-draft { background: #fff4dd; color: #92650b; }
.badge-status-pending { background: #fff4dd; color: #92650b; }
.badge-status-paid { background: var(--blue-100); color: var(--blue-700); }
.badge-status-failed { background: #fdeceb; color: var(--danger); }

.fav-btn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.9); border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #444; }
.fav-btn:hover { background: #fff; }
.fav-btn.is-fav { color: var(--danger); }

.listing-card-body { padding: 12px 14px 16px; }
.listing-card-price { font-size: 19px; font-weight: 800; color: var(--blue-700); }
.listing-card-title { font-weight: 600; margin: 2px 0 6px; font-size: 15px; }
.listing-card-specs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.listing-card-footer { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }

.make-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.make-pill { background: #fff; border: 1px solid var(--border); padding: 8px 16px; border-radius: 20px; font-size: 14px; font-weight: 600; }
.make-pill:hover { border-color: var(--blue-500); color: var(--blue-700); }

.sell-banner { }
.sell-banner-inner { background: var(--blue-100); border-radius: var(--radius); padding: 32px; display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.sell-banner-inner h2 { color: var(--blue-800, var(--blue-700)); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ---------------------------------------------------------- pagination - */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.page-link { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 14px; }
.page-link.active { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.page-link.disabled { opacity: .4; pointer-events: none; }
.page-ellipsis { padding: 8px 4px; color: var(--muted); }

/* ------------------------------------------------------------- search -- */
.search-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; padding: 28px 20px; align-items: start; }
.filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: sticky; top: 130px; }
.filters h3 { margin-top: 0; }
.filters label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.filters label:first-of-type { margin-top: 0; }
.filters input, .filters select { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.range-row { display: flex; gap: 8px; }
.checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; font-size: 14px !important; margin: 0 !important; }
.checkbox input { width: auto !important; }
.filters .btn { margin-top: 16px; }

.results-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.sort-form label { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sort-form select { padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); }

/* --------------------------------------------------------- listing pg -- */
.listing-detail { padding: 24px 20px 60px; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--ink); }
.listing-detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 28px; align-items: start; }
.gallery-main { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/10; background: #eee; margin-bottom: 10px; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 20px; }
.gallery-thumb { width: 84px; height: 60px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .6; border: 2px solid transparent; }
.gallery-thumb.active, .gallery-thumb:hover { opacity: 1; border-color: var(--blue-600); }
.specs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.spec-row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding-bottom: 6px; font-size: 14px; }

.price-card .listing-price { font-size: 30px; font-weight: 800; color: var(--blue-700); }
.listing-title { font-size: 19px; margin: 4px 0; }
.listing-meta { font-size: 13px; margin-bottom: 16px; }
.listing-actions { display: flex; flex-direction: column; gap: 10px; }
.seller-card .seller-name { font-weight: 700; font-size: 16px; }
.contact-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.contact-card input, .contact-card textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; }
.contact-card button { margin-top: 14px; }

/* ------------------------------------------------------------ auth ----- */
.auth-page { display: flex; justify-content: center; padding: 56px 20px; }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.auth-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.auth-card button { margin-top: 20px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; }
.auth-switch a { color: var(--blue-600); font-weight: 600; }
.auth-demo { text-align: center; margin-top: 10px; font-size: 12px; }
.form-error { background: #fdeceb; color: var(--danger); padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 6px; }
.form-success { background: var(--blue-100); color: var(--blue-700); padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }

/* --------------------------------------------------------- listing form */
.form-page { padding: 30px 20px 60px; max-width: 820px; margin: 0 auto; }
.listing-form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.listing-form input, .listing-form select, .listing-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.listing-form button { margin-top: 22px; }
.existing-photos { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.existing-photo { position: relative; width: 100px; height: 76px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.existing-photo img { width: 100%; height: 100%; object-fit: cover; }
.remove-photo { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; line-height: 1; }

/* -------------------------------------------------------------- pricing */
.page-head { text-align: center; max-width: 620px; margin: 0 auto 32px; }
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; align-items: stretch; }
.plan-card { display: flex; flex-direction: column; text-align: center; position: relative; }
.plan-highlight { border: 2px solid var(--amber); }
.plan-price { font-size: 30px; font-weight: 800; color: var(--blue-700); margin: 10px 0 18px; }
.plan-price .muted { font-size: 14px; font-weight: 500; }
.plan-features { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; font-size: 14px; }
.plan-features li { margin-bottom: 8px; }
.plan-card .btn { margin-top: auto; }
.stripe-note { margin-top: 30px; }
.stripe-note code { background: #f0f2f4; padding: 2px 6px; border-radius: 4px; }

/* ------------------------------------------------------------ dashboard */
.dashboard-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 28px 20px 60px; align-items: start; }
.dash-sidebar { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: sticky; top: 130px; }
.dash-user { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.dash-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--blue-600); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.dash-user-name { font-weight: 700; font-size: 14px; }
.dash-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.dash-link { padding: 10px 12px; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.dash-link:hover { background: #f4f6f7; }
.dash-link.active { background: var(--blue-100); color: var(--blue-700); }
.dash-badge { background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; }
.dash-content h1 { margin-bottom: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { text-align: center; margin-bottom: 0; }
.stat-num { font-size: 26px; font-weight: 800; color: var(--blue-700); }

.simple-table { width: 100%; border-collapse: collapse; }
.simple-table td, .simple-table th { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: top; }
.full-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.my-listings { display: flex; flex-direction: column; gap: 12px; }
.my-listing-row { display: flex; gap: 14px; align-items: center; margin-bottom: 0; }
.my-listing-row img { width: 96px; height: 68px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.my-listing-info { flex: 1; min-width: 0; }
.my-listing-title { font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.my-listing-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline-form { display: inline; }

.message-item { margin-bottom: 12px; }
.message-unread { border-left: 3px solid var(--blue-600); }
.message-head { display: flex; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }

.dash-content .card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.dash-content .card input { width: 100%; max-width: 380px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.dash-content .card button { margin-top: 14px; }

/* -------------------------------------------------------------- footer */
.site-footer { background: var(--blue-900); color: #cfe0d6; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 24px; padding: 44px 20px 24px; }
.footer-grid h4 { color: #fff; font-size: 14px; margin-bottom: 12px; }
.footer-grid a { display: block; padding: 4px 0; font-size: 14px; color: #cfe0d6; }
.footer-grid a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.12); padding: 16px 20px; font-size: 12px; text-align: center; color: #9db8ac; }

.static-page { max-width: 760px; margin: 0 auto; }
.static-page h2 { margin-top: 28px; }

/* -------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .search-layout, .dashboard-layout { grid-template-columns: 1fr; }
  .filters, .dash-sidebar { position: static; }
  .listing-detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .pricing-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 26px; }
  .main-header { gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}
