@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400..800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600;700&display=swap');

:root {
  --paper: #EFEDE6;
  --paper-2: #E4E1D6;
  --ink: #15171A;
  --ink-soft: #52544F;
  --line: #D3CFC2;
  --card: #FBFAF6;
  --red: #E8432F;
  --red-ink: #FFFFFF;
  --teal: #0F6E63;
  --teal-soft: #E4F0EC;
  --radius: 14px;

  --src-olx: #A5D96A;
  --src-bazar: #5B8DEF;
  --src-targomax: #2563EB;
  --src-lot: #F2A93B;

  --topbar-bg: rgba(239,237,230,0.9);
}

/* Тъмна тема: същата палитра, обърната. Прилага се чрез data-theme="dark"
   на <html> (виж theme.js) - не чрез prefers-color-scheme само, за да може
   потребителят да я превключва ръчно и изборът да се помни. */
[data-theme="dark"] {
  --paper: #131417;
  --paper-2: #1C1E22;
  --ink: #ECEAE3;
  --ink-soft: #9A9C98;
  --line: #2E3137;
  --card: #1A1C20;
  --red: #FF5C45;
  --teal: #4FD1BC;
  --teal-soft: #16302C;

  --topbar-bg: rgba(19,20,23,0.9);
}

body, .topbar, .deal-card, .side-card, .admin-table, .post-card {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: 'Bricolage Grotesque', sans-serif; margin: 0; }

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

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 20px; flex-wrap: wrap;
}
.logo {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; font-size: 21px; letter-spacing: -0.5px;
}
.logo span { color: var(--red); }

.source-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.source-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease;
}
.source-chip:hover { transform: translateY(-1px); }
.source-chip.active { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.source-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Hero ---------- */
.hero { padding: 56px 20px 40px; text-align: center; }
.hero h1 {
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 700; line-height: 1.08; letter-spacing: -1px;
}
.hero-sub {
  max-width: 520px; margin: 16px auto 0;
  color: var(--ink-soft); font-size: 15.5px; line-height: 1.5;
}
.hero-search { max-width: 560px; margin: 28px auto 0; }
#searchInput {
  width: 100%; padding: 17px 22px;
  border-radius: 999px; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink);
  font-size: 16px; font-family: 'Inter', sans-serif;
  box-shadow: 4px 4px 0 var(--ink);
}
#searchInput:focus { outline: none; box-shadow: 2px 2px 0 var(--ink); }
#searchInput::placeholder { color: #9B9A90; }

.hero-stats {
  margin-top: 20px; font-size: 13.5px; color: var(--ink-soft);
  display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.hero-stats strong { font-family: 'JetBrains Mono', monospace; color: var(--ink); font-weight: 700; }
.hero-stats .dot { opacity: .5; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; padding: 20px 20px 60px; }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } }

.filter-block { margin-bottom: 22px; }
.filter-block h3 {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 10px; font-weight: 600;
  font-family: 'Inter', sans-serif;
}

.pill-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.pill-list li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 14px; display: flex; justify-content: space-between;
}
.pill-list li:hover { background: var(--paper-2); }
.pill-list li.active { background: var(--ink); color: var(--paper); font-weight: 600; }
.pill-list .count { color: var(--ink-soft); font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.pill-list li.active .count { color: var(--paper); opacity: .7; }

#citySelect, #conditionSelect, #sortSelect {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink); font-family: 'Inter', sans-serif; font-size: 14px;
}

.price-filter { display: flex; gap: 6px; }
.price-filter input {
  width: 0; flex: 1; padding: 9px 10px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--card);
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
}

.apply-btn {
  width: 100%; padding: 11px; border-radius: 8px; border: none;
  background: var(--red); color: #fff; font-weight: 700; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 14px;
}
.apply-btn:hover { filter: brightness(1.05); }

/* ---------- Deals grid ---------- */
.deals-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
#resultCount { color: var(--ink-soft); font-family: 'JetBrains Mono', monospace; font-size: 13px; }
#sortSelect { width: auto; }

.deals-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px;
}

.deal-card {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: visible;
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.deal-card:hover { transform: translateY(-3px); box-shadow: 5px 5px 0 var(--ink); }

.fav-heart {
  position: absolute; top: 10px; left: 10px; z-index: 4;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(251,250,246,0.9);
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.fav-heart:hover { transform: scale(1.1); }
#favToggle.active { border-color: var(--red); color: var(--red); }

.top-badge {
  position: absolute; top: -10px; left: -10px; z-index: 5;
  background: linear-gradient(135deg, #F2C230, #E8432F);
  color: #fff; font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700; padding: 4px 9px;
  border-radius: 999px; box-shadow: 0 2px 4px rgba(0,0,0,.25);
  text-transform: uppercase; letter-spacing: .03em;
}
.deal-card.featured { border-color: #F2C230; box-shadow: 0 0 0 2px rgba(242,194,48,0.3); }

/* Signature element: rotated "stamp" badge showing the source marketplace */
.source-stamp {
  position: absolute;
  top: -10px; right: 12px;
  padding: 4px 10px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px; font-weight: 700;
  color: #fff;
  transform: rotate(-6deg);
  box-shadow: 2px 2px 0 rgba(0,0,0,.2);
  z-index: 3;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.deal-card .thumb {
  position: relative; aspect-ratio: 4/3; border-radius: 12px 12px 0 0;
  overflow: hidden; background: var(--paper-2);
}
.deal-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.discount-badge {
  position: absolute; bottom: 10px; left: 10px;
  background: var(--red); color: #fff;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 12px;
  padding: 4px 8px; border-radius: 6px;
}

.deal-body { padding: 16px; display: flex; flex-direction: column; gap: 7px; flex: 1; }

.deal-meta { display: flex; gap: 8px; font-size: 12px; color: var(--ink-soft); flex-wrap: wrap; }
.deal-meta .tag {
  background: var(--teal-soft); color: var(--teal);
  padding: 2px 8px; border-radius: 999px; font-weight: 600;
}

.deal-title { font-size: 15px; font-weight: 600; line-height: 1.3; }

.compare-hint { display: block; font-size: 11.5px; color: var(--teal); font-weight: 600; }
.social-proof { display: block; font-size: 11.5px; color: var(--red); font-weight: 600; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.deal-location { font-size: 12.5px; color: var(--ink-soft); }

.deal-prices { margin-top: auto; display: flex; align-items: baseline; gap: 8px; padding-top: 6px; }
.price-now { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 19px; color: var(--ink); }
.price-old { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--ink-soft); text-decoration: line-through; }

.deal-cta {
  display: block; text-align: center; margin-top: 8px;
  background: var(--ink); color: var(--paper);
  font-weight: 700; padding: 10px; border-radius: 8px; font-size: 13.5px;
}
.deal-cta:hover { background: var(--red); }

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

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 36px; }
.pagination button {
  background: var(--card); border: 1.5px solid var(--line); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; font-family: 'Inter', sans-serif;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
#pageInfo { font-family: 'JetBrains Mono', monospace; color: var(--ink-soft); font-size: 13px; }

.footer { border-top: 1px solid var(--line); padding: 24px 20px; color: var(--ink-soft); font-size: 13px; margin-top: 20px; }

@media (prefers-reduced-motion: reduce) {
  .deal-card, .source-chip { transition: none; }
}

/* ---------- Превключвател на тема ---------- */
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--line); background: var(--card);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--ink); }

/* ---------- Countdown таймер ---------- */
.countdown {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: 'JetBrains Mono', monospace; font-size: 11.5px; font-weight: 600;
  color: var(--ink-soft);
}
.countdown.urgent { color: var(--red); }
.countdown-box {
  background: var(--paper-2); padding: 1px 5px; border-radius: 4px;
  min-width: 22px; text-align: center;
}
.countdown.urgent .countdown-box { background: rgba(232,67,47,.12); }

/* ---------- Долна мобилна навигация ---------- */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--card); border-top: 1.5px solid var(--line);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
  }
  .bottom-nav a, .bottom-nav button {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-family: 'Inter', sans-serif; font-size: 10.5px; font-weight: 600;
    color: var(--ink-soft); padding: 4px 10px; border-radius: 10px;
    position: relative; text-decoration: none; min-width: 62px;
  }
  .bottom-nav .icon { font-size: 19px; line-height: 1; }
  .bottom-nav .active { color: var(--ink); }
  .bottom-nav .badge {
    position: absolute; top: 0; right: 8px;
    background: var(--red); color: #fff;
    font-size: 9.5px; font-family: 'JetBrains Mono', monospace;
    min-width: 15px; height: 15px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; padding: 0 4px;
  }
  body { padding-bottom: 68px; }
  .topbar .source-chips { display: none; }
}

/* ---------- Филтърен модал (мобилно) ---------- */
.filter-modal {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.5); align-items: flex-end;
}
.filter-modal.open { display: flex; }
.filter-modal-inner {
  background: var(--card); width: 100%;
  border-radius: 20px 20px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  max-height: 85vh; overflow-y: auto;
}
.filter-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.filter-modal-head h2 { font-size: 20px; }
.filter-close {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--paper-2); color: var(--ink); font-size: 17px; cursor: pointer;
}
.cat-pills { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.cat-pill {
  padding: 13px 10px; border-radius: 999px; border: 1.5px solid var(--line);
  background: transparent; color: var(--ink); cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 500;
}
.cat-pill.active { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.filter-apply {
  width: 100%; padding: 15px; border-radius: 999px; border: none;
  background: var(--red); color: #fff; font-weight: 700; font-size: 16px;
  cursor: pointer; font-family: 'Inter', sans-serif; margin-top: 4px;
}

/* ---------- SEO съдържателен блок ---------- */
.seo-content {
  max-width: 820px;
  margin: 20px auto 40px;
  padding: 32px 20px 0;
  border-top: 1.5px solid var(--line);
}
.seo-content h2 {
  font-size: 21px;
  margin: 28px 0 10px;
  letter-spacing: -0.3px;
}
.seo-content h2:first-of-type { margin-top: 0; }
.seo-content p {
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 15.5px;
  margin: 0 0 14px;
}
.seo-content ul { color: var(--ink-soft); line-height: 1.7; font-size: 15.5px; padding-left: 20px; margin: 0 0 14px; }
.seo-content li { margin-bottom: 8px; }
.seo-content strong { color: var(--ink); font-weight: 600; }
