:root {
  --brand: #ff7100;
  --brand-dark: #e06200;
  --ink: #363636;
  --muted: #7a7a7a;
  --line: #e5e5e5;
  --bg: #f4f4f4;
  --card: #ffffff;
  --sale: #2a6f97;
  --rent: #6a994e;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Rubik', 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* header */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 28px; }
.logo { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 24px; }
.logo-mark { background: var(--brand); color: #fff; border-radius: 8px; padding: 0 8px; }
.logo-text { color: var(--brand); }
.main-nav { display: flex; gap: 20px; flex: 1; }
.main-nav a { padding: 6px 0; border-bottom: 3px solid transparent; font-weight: 500; }
.main-nav a.active, .main-nav a:hover { border-color: var(--brand); color: var(--brand); }
.nav-short { display: none; }
.badge { background: var(--brand); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }

/* buttons */
.btn { border: 0; border-radius: 6px; padding: 10px 18px; font: inherit; font-weight: 500; cursor: pointer; }
.btn-post { background: var(--brand); color: #fff; white-space: nowrap; }
.btn-post:hover, .btn-primary:hover, .btn-search:hover { background: var(--brand-dark); }
.btn-primary, .btn-search { background: var(--brand); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--brand); color: var(--brand); }
.btn-link { background: none; color: var(--brand); padding: 8px 0; }
.wide { width: 100%; margin-top: 10px; }

/* hero / search */
.hero { background: linear-gradient(135deg, #ff7100, #ff9a3c); color: #fff; margin: 0 -16px; padding: 28px 16px; border-radius: 0 0 16px 16px; }
.hero h1 { font-size: 28px; margin-bottom: 14px; }
.search { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 14px; box-shadow: 0 6px 20px #0002; }
.search-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; flex: 1; }
.field.grow { flex: 2; min-width: 180px; }
.field.small { min-width: 80px; flex: .6; }
.field span { font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; border: 1px solid #ccc; border-radius: 6px; padding: 9px 10px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #ffb27a; border-color: var(--brand); }
.btn-search { padding: 10px 28px; }
.deal-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.deal-tabs label { border: 1px solid var(--line); border-radius: 20px; padding: 6px 16px; cursor: pointer; }
.deal-tabs label.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.deal-tabs input { display: none; }

/* layout */
.layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; margin: 24px 0; }
.filters { background: #fff; border-radius: var(--radius); padding: 16px; align-self: start; position: sticky; top: 76px; }
.filters h3 { font-size: 15px; margin: 14px 0 6px; }
.filters h3:first-child { margin-top: 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.check input { width: auto; accent-color: var(--brand); }
.results-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.sort { display: flex; align-items: center; gap: 8px; }
.sort select { width: auto; }

/* cards */
.list { display: flex; flex-direction: column; gap: 12px; }
.card { display: grid; grid-template-columns: 240px 1fr 170px; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); transition: box-shadow .15s; }
.card:hover { box-shadow: 0 4px 16px #0001; }
.card-img { position: relative; aspect-ratio: 3 / 2; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.gallery-main { position: relative; }
.gallery-main > img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; }
/* Photo arrows and counter (cards and listing gallery) */
.photo-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); color: #222; font-size: 22px; line-height: 1; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; z-index: 2; opacity: .85; }
.photo-nav:hover { opacity: 1; }
.photo-nav.prev { right: 8px; }
.photo-nav.next { left: 8px; }
.gallery-main .photo-nav { width: 44px; height: 44px; font-size: 28px; }
.photo-count { position: absolute; bottom: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; z-index: 2; }
@media (hover: hover) { .card-img .photo-nav { opacity: 0; transition: opacity .15s; } .card:hover .card-img .photo-nav { opacity: .85; } }
.deal-chip { position: absolute; top: 10px; right: 10px; color: #fff; font-size: 12px; padding: 3px 10px; border-radius: 12px; }
.deal-chip.inline { position: static; display: inline-block; margin-bottom: 6px; }
.deal-chip.sale { background: var(--sale); }
.deal-chip.rent { background: var(--rent); }
.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-weight: 700; font-size: 17px; }
.card-sub { color: var(--muted); }
.card-specs { display: flex; gap: 18px; margin-top: 4px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.tag { background: #f1f1f1; border-radius: 4px; padding: 2px 8px; font-size: 12px; color: #555; }
.card-side { padding: 14px 16px; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; border-right: 1px solid var(--line); }
.card-price { font-weight: 700; font-size: 20px; }
.card-price small, .detail-price small { font-size: 13px; font-weight: 400; color: var(--muted); }
.card-meta { font-size: 12px; color: var(--muted); }
.agency { background: #fff3e8; color: var(--brand); border-radius: 4px; padding: 1px 6px; margin-left: 4px; }
.fav-btn { background: none; border: 0; font-size: 26px; cursor: pointer; color: #999; line-height: 1; padding: 0; }
.fav-btn.on { color: #e63946; }
.empty { background: #fff; border-radius: var(--radius); padding: 40px; text-align: center; color: var(--muted); }
.empty a { color: var(--brand); }

.pager { display: flex; gap: 6px; justify-content: center; margin: 20px 0; flex-wrap: wrap; }
.pager a { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; }
.pager a.current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager .gap { padding: 6px 4px; color: var(--muted, #888); }

/* detail */
.back { display: inline-block; margin: 18px 0 10px; color: var(--brand); }
.detail { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.detail-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: #fff; border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); }
.panel h2 { font-size: 18px; margin-bottom: 12px; }
.gallery { background: #fff; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.gallery > img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.thumbs { display: flex; gap: 8px; padding: 8px; overflow-x: auto; }
.thumbs img { flex: 0 0 auto; width: 100px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .6; border: 2px solid transparent; }
.thumbs img.active { opacity: 1; border-color: var(--brand); }
.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.detail-head h1 { font-size: 24px; }
.detail-price { font-size: 28px; font-weight: 700; color: var(--brand); }
.spec-row { display: flex; gap: 32px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.spec { display: flex; flex-direction: column; gap: 2px; }
.spec span { color: var(--muted); font-size: 13px; }
.spec b { font-size: 17px; }
.spec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.desc { line-height: 1.7; margin: 0; white-space: pre-line; }
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.feature { padding: 8px; border-radius: 6px; }
.feature.yes { background: #eef7ea; color: #386641; }
.feature.no { background: #f5f5f5; color: #aaa; text-decoration: line-through; }
.detail-side .contact { position: sticky; top: 76px; }
.contact-name { font-weight: 700; font-size: 17px; }
.phone { margin-top: 10px; text-align: center; font-size: 22px; font-weight: 700; color: var(--brand); padding: 8px; border: 1px dashed var(--brand); border-radius: 6px; direction: ltr; }
.section-title { margin: 28px 0 12px; font-size: 20px; }

/* new ad form */
.page-title { margin: 24px 0 16px; font-size: 24px; }
.new-form { display: flex; flex-direction: column; gap: 18px; margin-bottom: 30px; }
.new-form fieldset { border: 0; padding: 0; margin: 0; }
.new-form legend { font-weight: 700; margin-bottom: 10px; font-size: 16px; }
.new-form .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.new-form .grid legend { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.new-form > .btn { align-self: flex-start; padding: 12px 40px; font-size: 16px; }
.errors { background: #fdecea; color: #b3261e; border-radius: 6px; padding: 12px 16px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 20px; border-radius: 20px; z-index: 100; }
.footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; color: var(--muted); font-size: 13px; margin-top: 40px; text-align: center; }

@media (max-width: 900px) {
  .layout, .detail { grid-template-columns: 1fr; }
  .filters { position: static; }
  .card { grid-template-columns: 160px 1fr; }
  .card-side { grid-column: 1 / -1; flex-direction: row; align-items: center; border-right: 0; border-top: 1px solid var(--line); padding: 10px 16px; }
  .features { grid-template-columns: repeat(2, 1fr); }
  .spec-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; padding: 8px 12px; }
  .logo { font-size: 20px; }
  .main-nav {
    order: 3; flex: 1 1 100%; width: 100%; max-width: 100%;
    gap: 14px; overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; padding: 4px 2px 2px;
  }
  .main-nav a { white-space: nowrap; flex-shrink: 0; }
  .btn-post { padding: 8px 12px; font-size: 14px; }
  .nav-full { display: none; }
  .nav-short { display: inline; }
  .card { grid-template-columns: 1fr; }
  .card-specs { gap: 12px; }
  .hero h1 { font-size: 22px; }
}

/* ---------- map view ---------- */
.results-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.view-toggle { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle button {
  background: #fff; border: 0; border-left: 1px solid var(--line); padding: 7px 14px;
  font: inherit; font-weight: 500; cursor: pointer; color: var(--ink);
}
.view-toggle button:first-child { border-left: 0; }
.view-toggle button.active { background: var(--brand); color: #fff; }
.view-toggle button:hover:not(.active) { background: #fff3e8; }

.results-body {
  display: grid;
  gap: 12px;
  min-height: 520px;
}
@media (min-width: 901px) {
  .layout:has(.results-body.view-split) { grid-template-columns: 190px 1fr; }
}
.results-body.view-split {
  /* List gets a usable min width so Madlan-style compact cards aren't crushed */
  grid-template-columns: minmax(380px, 1.15fr) minmax(320px, 1fr);
}
.results-body.view-list .map-pane { display: none; }
.results-body.view-map .list-pane { display: none; }
.results-body.view-map { grid-template-columns: 1fr; min-height: 640px; }
.results-body.view-list { grid-template-columns: 1fr; min-height: 0; }

.list-pane { min-width: 0; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 220px); overflow: auto; }
.results-body.view-list .list-pane { max-height: none; overflow: visible; }

/* Compact Madlan-like cards in split: image on top, price always fully visible */
.results-body.view-split .card {
  display: flex;
  flex-direction: column;
  grid-template-columns: unset;
  overflow: hidden;
}
.results-body.view-split .card-img {
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 140px;
  flex: none;
}
.results-body.view-split .card-img img { width: 100%; height: 100%; object-fit: cover; }
.results-body.view-split .card-body {
  padding: 10px 12px 6px;
  min-width: 0;
  flex: 1;
}
.results-body.view-split .card-title { font-size: 15px; }
.results-body.view-split .card-specs { gap: 10px; flex-wrap: wrap; font-size: 13px; }
.results-body.view-split .card-tags { display: none; }
.results-body.view-split .card-side {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-right: 0;
  border-top: 1px solid var(--line);
  padding: 8px 12px 10px;
  width: 100%;
  box-sizing: border-box;
}
.results-body.view-split .card-price {
  font-size: 18px; white-space: nowrap; overflow: visible;
  margin-inline-start: auto;
}
.results-body.view-split .card-meta { white-space: nowrap; }
.results-body.view-split .fav-btn { font-size: 22px; flex-shrink: 0; }

.map-pane { position: relative; min-height: 520px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #e8eef3; }
.results-body.view-map .map-pane { min-height: 640px; }
.search-map, .detail-map { width: 100%; height: 100%; min-height: 520px; }
.detail-map { min-height: 280px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.map-missing { padding: 40px; text-align: center; color: var(--muted); background: #f8f8f8; }

.search-area-btn {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: #fff; color: var(--brand); border: 1px solid var(--brand); border-radius: 24px;
  padding: 8px 18px; font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 10px #0002;
}
.search-area-btn:hover { background: var(--brand); color: #fff; }

.card.highlight { box-shadow: 0 0 0 2px var(--brand); border-color: var(--brand); }

/* Madlan-style price pill markers */
.price-marker-wrap { background: transparent !important; border: 0 !important; }
.price-marker {
  display: inline-block; padding: 4px 10px; border-radius: 14px; font-weight: 700; font-size: 13px;
  color: #fff; white-space: nowrap; box-shadow: 0 2px 6px #0003; transform: translate(-50%, -100%);
  font-family: 'Rubik', 'Segoe UI', Arial, sans-serif; border: 2px solid #fff; position: relative;
  transition: transform .12s, box-shadow .12s;
}
.price-marker::after {
  content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: inherit;
}
.price-marker.sale { background: var(--sale); border-bottom-color: var(--sale); }
.price-marker.sale::after { border-top-color: var(--sale); }
.price-marker.rent { background: var(--rent); border-bottom-color: var(--rent); }
.price-marker.rent::after { border-top-color: var(--rent); }
.price-marker.highlighted {
  transform: translate(-50%, -100%) scale(1.12); box-shadow: 0 4px 12px #0004; z-index: 10;
  background: var(--brand);
}
.price-marker.highlighted::after { border-top-color: var(--brand); }

.yadshuk-cluster div {
  background: var(--brand) !important; color: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: 'Rubik', sans-serif; box-shadow: 0 2px 8px #0003;
  border: 3px solid #fff;
}
.marker-cluster-small.yadshuk-cluster { width: 36px !important; height: 36px !important; }
.marker-cluster-small.yadshuk-cluster div { width: 36px; height: 36px; font-size: 13px; }
.marker-cluster-medium.yadshuk-cluster { width: 44px !important; height: 44px !important; }
.marker-cluster-medium.yadshuk-cluster div { width: 44px; height: 44px; font-size: 14px; }
.marker-cluster-large.yadshuk-cluster { width: 52px !important; height: 52px !important; }
.marker-cluster-large.yadshuk-cluster div { width: 52px; height: 52px; font-size: 15px; }

.yadshuk-popup .leaflet-popup-content-wrapper {
  border-radius: 10px; padding: 0; overflow: hidden; box-shadow: 0 6px 20px #0003;
}
.yadshuk-popup .leaflet-popup-content { margin: 0; width: 220px !important; }
.yadshuk-popup .leaflet-popup-tip { background: #fff; }
.map-popup-card { display: block; color: inherit; }
.map-popup-card img { width: 100%; aspect-ratio: 3/2; object-fit: cover; }
.map-popup-body { padding: 10px 12px; }
.map-popup-price { font-weight: 700; font-size: 16px; color: var(--brand); }
.map-popup-specs { font-size: 13px; margin-top: 2px; }
.map-popup-addr { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Leaflet inside RTL page: keep map UI LTR for controls */
.search-map, .detail-map { direction: ltr; }
.search-map .leaflet-control, .detail-map .leaflet-control { direction: ltr; }

@media (max-width: 900px) {
  .results-body.view-split { grid-template-columns: 1fr; }
  .results-body.view-split .map-pane { min-height: 420px; }
  .list-pane { max-height: none; overflow: visible; }
  .results-body.view-map .map-pane, .results-body.view-map .search-map { min-height: 70vh; }
}

@media (max-width: 900px) {
  .view-toggle [data-view="split"] { display: none; }
}

/* ---------- compact search + collapsible filters ---------- */
.hero-compact { padding: 16px; margin: 0 -16px 0; }
.hero-compact .search-compact { padding: 12px; }
.search-compact .search-row { margin-top: 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.filter-chip {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink);
}
.filter-chip:hover, .filter-chip.open { border-color: var(--brand); color: var(--brand); background: #fff3e8; }
.filter-chip.clear { color: var(--brand); border-color: transparent; background: transparent; }
.filter-badge {
  display: inline-block; background: var(--brand); color: #fff; border-radius: 10px;
  padding: 0 6px; font-size: 11px; margin-inline-start: 4px;
}
.filter-panels {
  margin-top: 10px; background: #fafafa; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.filter-panel h4 { margin: 10px 0 6px; font-size: 14px; }
.filter-panel .panel-row { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-panel .panel-apply { margin-top: 12px; }
.checks.wrap { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.layout-filters-bar { grid-template-columns: 1fr; margin-top: 16px; }

.card-ppm { font-size: 12px; color: var(--muted); }
.private { background: #eef7ea; color: #386641; border-radius: 4px; padding: 1px 6px; margin-left: 4px; font-size: 12px; }
.muted-tag { background: #f5f5f5; color: #777; }

@media (max-width: 900px) {
  .hero-compact { border-radius: 0; padding: 12px; }
  .filter-panels {
    position: fixed; inset: auto 0 0 0; z-index: 40; max-height: 70vh; overflow: auto;
    border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px #0003; margin: 0; padding: 16px 16px 24px;
    background: #fff;
  }
  .filter-panels::before {
    content: ''; display: block; width: 40px; height: 4px; background: #ddd;
    border-radius: 2px; margin: 0 auto 12px;
  }
}
