/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black: #111;
  --grey-dark: #444;
  --grey-mid: #888;
  --grey-light: #e8e8e8;
  --grey-bg: #f5f5f5;
  --white: #fff;
  --accent: #d94f00;
  --accent-hover: #b83e00;
  --font: 'Helvetica Neue', Arial, sans-serif;
  --radius: 4px;
}

[data-theme="dark"] {
  --black: #f0f0f0;
  --grey-dark: #bbb;
  --grey-mid: #777;
  --grey-light: #2e2e2e;
  --grey-bg: #1a1a1a;
  --white: #242424;
  --accent: #ff6b2b;
  --accent-hover: #e55a1a;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--black);
  background: var(--grey-bg);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────── */
header {
  background: var(--white);
  border-bottom: 2px solid var(--black);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -1px;
  text-decoration: none;
}

.tagline {
  font-size: 13px;
  color: var(--grey-mid);
  flex: 1;
}

.lang-switcher {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid var(--grey-light);
  border-radius: 6px;
  color: var(--grey-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, color 0.15s;
}

.lang-switcher:hover,
.lang-switcher:focus {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Buttons ──────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--white);
  color: var(--black);
  border: 1px solid var(--grey-light);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { border-color: var(--grey-mid); }

.btn-full { width: 100%; margin-top: 12px; }

.btn-danger {
  background: #c0392b;
  color: var(--white);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger:hover { background: #a93226; }

/* ── Ad Slots ─────────────────────────────────────── */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border: 1px dashed var(--grey-light);
  color: var(--grey-mid);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ad-leaderboard {
  max-width: 1300px;
  margin: 12px auto;
  height: 90px;
}

.ad-sidebar {
  width: 100%;
  height: 250px;
  margin-top: 20px;
}

.ad-rail {
  padding-top: 8px;
}

.ad-skyscraper {
  width: 160px;
  height: 600px;
  position: sticky;
  top: 80px;
}

.ad-footer-leaderboard {
  max-width: 1300px;
  margin: 0 auto 0;
  height: 90px;
}

/* ── Adblock banner ───────────────────────────────── */
#adblock-banner {
  position: fixed;
  bottom: -80px;
  left: 0;
  right: 0;
  background: var(--black);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  z-index: 999;
  transition: bottom 0.3s ease;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.2);
}
#adblock-banner.visible { bottom: 0; }
#adblock-banner-close {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: var(--white);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Layout ───────────────────────────────────────── */
main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: 200px 1fr 160px;
  gap: 24px;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar { padding-top: 8px; }

.filter-group { margin-bottom: 20px; }

.filter-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey-mid);
  margin-bottom: 6px;
}

.filter-group select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--white);
  color: var(--black);
  color-scheme: light;
}

.category-list {
  list-style: none;
}

.category-list li {
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--grey-dark);
}

.category-list li:hover { background: var(--grey-light); }
.category-list li.active { background: var(--black); color: var(--white); font-weight: 600; }

/* ── Listings ─────────────────────────────────────── */
.listings-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--grey-light);
  margin-bottom: 16px;
}

.listings-header h2 { font-size: 16px; }

#listings-count {
  font-size: 12px;
  color: var(--grey-mid);
}

/* ── Post Card ────────────────────────────────────── */
.post-card {
  background: var(--white);
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  transition: border-color 0.1s;
}

.post-card:hover { border-color: var(--grey-mid); }

.post-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.post-card-meta {
  font-size: 12px;
  color: var(--grey-mid);
}

.post-card-meta span { margin-right: 10px; }

.post-card-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  align-self: center;
}

.post-card-thumb {
  width: 70px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-left: 12px;
}

.category-badge {
  display: inline-block;
  font-size: 11px;
  background: var(--grey-bg);
  border: 1px solid var(--grey-light);
  border-radius: 2px;
  padding: 1px 6px;
  color: var(--grey-dark);
  margin-right: 6px;
}

/* ── Modal ────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 600px;
  position: relative;
}

.modal-box--narrow { max-width: 440px; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--grey-mid);
  line-height: 1;
}
.modal-close:hover { color: var(--black); }

.modal-box h2 { margin-bottom: 18px; font-size: 18px; }

/* ── Post Detail ──────────────────────────────────── */
.detail-images {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.detail-images img {
  height: 180px;
  border-radius: var(--radius);
  object-fit: cover;
}

.detail-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.detail-desc { margin: 12px 0; line-height: 1.6; white-space: pre-wrap; }

.detail-meta {
  font-size: 13px;
  color: var(--grey-mid);
  margin-bottom: 12px;
}

.detail-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin: 12px 0;
}

.contact-box {
  background: var(--grey-bg);
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  padding: 14px;
  margin: 16px 0;
}

.contact-box p { font-size: 13px; margin-bottom: 4px; }

.share-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 8px;
}

.share-btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  color: #fff;
}

.share-wa  { background: #25D366; }
.share-fb  { background: #1877F2; }
.share-x   { background: #000; }
.share-copy { background: var(--grey-dark); }

.report-link {
  font-size: 11px;
  color: var(--grey-mid);
  cursor: pointer;
  text-decoration: underline;
  display: inline-block;
  margin-top: 16px;
}

/* ── Form ─────────────────────────────────────────── */
form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-dark);
  margin-bottom: 14px;
}

form label input,
form label textarea,
form label select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font);
}

form label input:focus,
form label textarea:focus,
form label select:focus {
  outline: none;
  border-color: var(--black);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hint {
  font-size: 11px;
  color: var(--grey-mid);
  margin-bottom: 12px;
}

.form-error {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #c0392b;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 10px;
}
.form-error.hidden { display: none; }

/* ── Manage link ──────────────────────────────────── */
.manage-link-box {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.manage-link-box input {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--grey-bg);
  color: var(--black);
}

/* ── Search bar ───────────────────────────────────── */
.search-bar {
  margin-bottom: 12px;
}

.search-bar input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--white);
  color: var(--black);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--black);
}

/* ── Checkbox label ───────────────────────────────── */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  font-weight: normal !important;
  cursor: pointer;
  margin-bottom: 14px;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.car-badge {
  display: inline-block;
  font-size: 11px;
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-radius: 2px;
  padding: 1px 6px;
  color: #e65100;
  margin-left: 4px;
}

[data-theme="dark"] .filter-group select {
  color-scheme: dark;
}

[data-theme="dark"] .car-badge {
  background: #2a1a00;
  border-color: #5c3000;
  color: #ff9966;
}

/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 24px 0 8px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.page-btn:hover { border-color: var(--grey-mid); }

.page-btn.active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
  cursor: default;
}

.page-gap {
  color: var(--grey-mid);
  font-size: 13px;
  padding: 0 4px;
  line-height: 36px;
}

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--grey-mid);
}

.empty-state p { font-size: 15px; }

/* ── Footer ───────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--grey-mid);
  border-top: 1px solid var(--grey-light);
  margin-top: 20px;
}

footer a { color: var(--grey-mid); margin: 0 4px; }
footer a:hover { color: var(--black); }

/* ── Mobile-only / desktop-only helpers ───────────── */
.mobile-only { display: none; }

/* ── Sidebar close button (hidden on desktop) ─────── */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--grey-mid);
  cursor: pointer;
  padding: 4px;
  margin-bottom: 16px;
  align-self: flex-end;
}

/* ── Filter toggle button (hidden on desktop) ─────── */
.btn-filter-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--white);
  border: 1px solid var(--grey-light);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--black);
  white-space: nowrap;
}

/* ── Sidebar overlay (hidden on desktop) ──────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 149;
}

/* ════════════════════════════════════════════════════
   MOBILE  ≤ 768px
   ════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Helpers */
  .mobile-only { display: flex; }

  /* ── Header ──────────────────────────────────────── */
  .tagline { display: none; }
  #btn-manage-post { display: none; }
  .header-inner { gap: 8px; padding: 10px 14px; }
  .logo { font-size: 24px; }
  .btn-primary, .btn-secondary { padding: 7px 11px; font-size: 12px; }

  /* ── Ads ─────────────────────────────────────────── */
  .ad-leaderboard,
  .ad-footer-leaderboard { height: 60px; margin: 8px 12px; }
  .ad-rail { display: none; }

  /* ── Main layout ─────────────────────────────────── */
  main {
    grid-template-columns: 1fr;
    padding: 0 12px 40px;
    gap: 0;
  }

  /* ── Sidebar drawer ──────────────────────────────── */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100dvh;
    background: var(--white);
    border-right: 1px solid var(--grey-light);
    padding: 16px;
    overflow-y: auto;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    display: flex;
    flex-direction: column;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-close-btn { display: block; }

  #sidebar-overlay.active { display: block; }

  .btn-filter-toggle { display: flex; }

  /* ── Listings header ─────────────────────────────── */
  .listings-header {
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding-top: 12px;
  }

  .listings-header h2 { flex: 1; }

  #listings-count { order: 3; width: 100%; padding-top: 0; font-size: 11px; }

  /* ── Post cards ──────────────────────────────────── */
  .post-card { padding: 12px 14px; }
  .post-card-thumb { width: 56px; height: 44px; }
  .post-card-title { font-size: 14px; }

  /* ── Modals ──────────────────────────────────────── */
  .modal { padding: 12px; align-items: flex-start; }
  .modal-box { padding: 20px 16px; }
  .modal-box--narrow { max-width: 100%; }

  /* ── Forms ───────────────────────────────────────── */
  .form-row { grid-template-columns: 1fr; gap: 0; }

  /* ── Pagination ──────────────────────────────────── */
  .page-btn { min-width: 40px; height: 40px; font-size: 14px; }
}

/* ════════════════════════════════════════════════════
   SMALL PHONES  ≤ 420px
   ════════════════════════════════════════════════════ */
@media (max-width: 420px) {
  .header-inner { padding: 9px 12px; }
  .logo { font-size: 22px; }
  #btn-new-post { font-size: 11px; padding: 7px 9px; }
  #btn-theme { padding: 7px 9px; font-size: 13px; }
  .post-card-thumb { display: none; }
  .modal { padding: 8px; }
}
