/* Dubai Rentals — "Clean & calm" theme
   Light, airy, soft borders, indigo accent, Plus Jakarta Sans. */

:root {
  --bg: #f3f4fa;            /* faint indigo-tinted page */
  --card: #fdfdff;          /* never pure white */
  --ink: #1a1b26;           /* near-black, slight indigo cast */
  --ink-2: #3b4150;
  --muted: #565d6b;         /* AA on card (~6:1) */
  --faint: #6b7280;         /* AA on card (~4.6:1), one step lighter */
  --line: #e6e7f0;          /* tinted hairline */
  --line-2: #d9dbe7;

  --accent: #4f46e5;        /* indigo-600 */
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;

  --gold: #f5a623;          /* rating stars — the one warm hit */
  --rose: #bf5c7c;          /* shortlist heart — muted, doesn't fight gold */
  --new: #16a34a;
  --price: #7c3aed;
  --gone: #98a2b3;
  --agree: #0d9488;

  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-hover: 0 4px 12px rgba(16,24,40,.10), 0 2px 4px rgba(16,24,40,.06);
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.error { color: #c0392b; font-size: .95rem; }
button { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
* { tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-card {
  background: var(--card); border-radius: var(--r-xl); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 32px 26px; width: 100%; max-width: 360px; text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.login-card form { display: grid; gap: 12px; margin-top: 20px; }
.login-card input {
  padding: 14px; font-size: 1.05rem; border: 1px solid var(--line-2);
  border-radius: var(--r); text-align: center; transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.login-card button {
  padding: 14px; font-size: 1.05rem; border: 0; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
  transition: background .15s, transform .1s;
}
.login-card button:hover { background: var(--accent-hover); }
.login-card button:active { transform: scale(.98); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.who { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.who-btn {
  border: 1px solid var(--line-2); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 7px 13px; cursor: pointer; font-weight: 600; font-size: .85rem;
  transition: all .15s;
}
.who-btn:hover { border-color: var(--accent); color: var(--accent); }
.who-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .82rem; text-decoration: underline; padding: 6px; }
.link-btn:hover { color: var(--ink); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-top: 12px; background: #eceef3; padding: 4px; border-radius: var(--r); }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  border-radius: var(--r-sm); padding: 9px; cursor: pointer; font-weight: 600; font-size: .92rem;
  transition: all .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- controls ---------- */
.controls { display: flex; gap: 8px; margin-top: 12px; }
#search {
  flex: 1; padding: 11px 14px; border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 1rem; background: #fff; transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
#sort {
  padding: 11px 12px; border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: .92rem; background: #fff; cursor: pointer; max-width: 42%;
}
.ghost-btn {
  border: 1px solid var(--line-2); background: #fff; border-radius: var(--r);
  padding: 11px 14px; cursor: pointer; font-size: .92rem; font-weight: 600; white-space: nowrap;
  color: var(--ink-2); transition: all .15s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.filters { display: flex; gap: 7px; overflow-x: auto; padding: 12px 0 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: .87rem; font-weight: 500; white-space: nowrap;
  transition: all .15s; min-height: 38px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- filter drawer ---------- */
.filter-drawer {
  margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px; display: grid; gap: 18px; box-shadow: var(--shadow);
}
.fgroup { display: grid; gap: 9px; }
.fgroup-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: .9rem; }
.fgroup input[type=range] { width: 100%; accent-color: var(--accent); height: 24px; }
.frow { font-size: .85rem; color: var(--muted); }
.frow strong { color: var(--ink); }
.boost-btn {
  border: 1px solid var(--accent); color: var(--accent); background: #fff;
  border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 600; cursor: pointer; transition: all .15s;
}
.boost-btn:hover { background: var(--accent-soft); }
.boost-btn.on { background: var(--accent); color: #fff; }
.boxset { display: flex; flex-wrap: wrap; gap: 8px; }
.box {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2);
  border-radius: 999px; padding: 8px 13px; font-size: .87rem; cursor: pointer; background: #fff;
  min-height: 38px; transition: all .15s;
}
.box:hover { border-color: var(--accent); }
.box:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.box input { accent-color: var(--accent); width: 16px; height: 16px; }
#agent-filter {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 16px; background: #fff; cursor: pointer; color: var(--ink);
}
#agent-filter:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: .9rem; cursor: pointer; }
.check-row input { accent-color: var(--accent); width: 18px; height: 18px; }

/* ---------- grid + cards ---------- */
main { padding: 16px; max-width: 1240px; margin: 0 auto; }
.count { margin: 2px 2px 14px; font-size: .85rem; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.empty { text-align: center; color: var(--muted); margin-top: 48px; }

.card {
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.card-img { position: relative; aspect-ratio: 16 / 10; background: #eceef3; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge {
  position: absolute; top: 10px; left: 10px; font-size: .72rem; font-weight: 700;
  color: #fff; padding: 4px 10px; border-radius: 999px; letter-spacing: .01em;
}
.badge.new { background: var(--new); }
.badge.price { background: var(--price); }
.badge.gone { background: var(--gone); }
.badge.live { display: none; }
.agree-pill {
  display: inline-block; vertical-align: 2px; margin-left: 8px;
  background: #d3f3ec; color: #0a6a59; font-size: .68rem; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; letter-spacing: .02em;
}

/* image placeholder when no photo or it fails to load */
.img-ph { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; color: #b8bdcc; }
.card-img.noimg img { display: none; }
.card-img.noimg .img-ph { display: flex; }

/* loading skeleton */
.card.skel { pointer-events: none; }
.skel-box { background: #eceef5; }
.skel-line { height: 12px; border-radius: 6px; background: #eceef5; margin: 8px 0; }
.skel-line.w35 { width: 35%; } .skel-line.w50 { width: 50%; } .skel-line.w80 { width: 80%; }
.skel-box, .skel-line { position: relative; overflow: hidden; }
.skel-box::after, .skel-line::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel-box::after, .skel-line::after { display: none; } }

.state-msg {
  grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 16px;
  display: grid; gap: 14px; justify-items: center;
}
.state-msg p { margin: 0; max-width: 32ch; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 9px; }
.rent { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.rent small { font-weight: 500; color: var(--faint); font-size: .78rem; }
.rent .old { color: var(--faint); text-decoration: line-through; font-weight: 500; font-size: .85rem; margin-left: 6px; }
.title { font-size: .95rem; line-height: 1.4; margin: 0; font-weight: 500; }
.title a { color: var(--ink); text-decoration: none; }
.title a:hover { color: var(--accent); text-decoration: underline; }
.meta { font-size: .82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.meta span { background: #f3f5f8; padding: 3px 9px; border-radius: var(--r-sm); }
.seen { font-size: .74rem; color: var(--faint); margin-top: 2px; }

.bldg { display: inline-block; font-size: .8rem; color: var(--muted); }
.bldg.ruled { color: var(--gone); font-weight: 600; }
.bldg.interested { color: var(--new); font-weight: 600; }

/* per-person opinions */
.people { display: grid; gap: 5px; padding: 4px 0; border-top: 1px solid var(--line); margin-top: 2px; padding-top: 10px; }
.person { display: flex; align-items: center; gap: 10px; padding: 3px 7px; border-radius: var(--r-sm); margin: 0 -7px; }
.person.mine { background: var(--accent-soft); }
.pname { font-size: .8rem; font-weight: 700; width: 30px; color: var(--faint); }
.person.mine .pname { color: var(--accent); }
.heart {
  border: 0; background: none; font-size: 1.2rem; color: var(--line-2); cursor: pointer;
  padding: 4px; line-height: 1; transition: transform .1s, color .15s;
}
.heart.on { color: var(--rose); }
.heart:not(:disabled):hover { color: var(--rose); }
.heart:not(:disabled):active { transform: scale(1.2); }
.heart:disabled { cursor: default; opacity: .85; }
.stars { display: inline-flex; gap: 1px; }
.stars button { border: 0; background: none; cursor: pointer; font-size: 1.3rem; color: var(--line-2); padding: 3px 1px; line-height: 1; transition: color .12s, transform .1s; }
.stars button.lit { color: var(--gold); }
.stars button:not(:disabled):hover { color: var(--gold); }
.stars button:not(:disabled):active { transform: scale(1.15); }
.stars button:disabled { cursor: default; }

.visited {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: .87rem; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 9px 12px; background: #fff; font-weight: 600;
  color: var(--ink-2); min-height: 40px; transition: all .15s;
}
.visited:hover { border-color: var(--new); color: var(--new); }
.visited.on { background: #ecfdf3; border-color: var(--new); color: #087443; }

.notes {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px;
  font-size: .9rem; font-family: inherit; resize: vertical; min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
.notes:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.other-note { font-size: .82rem; color: var(--ink-2); background: #f7f8fa; border-radius: var(--r-sm); padding: 7px 10px; }

.card.is-gone { opacity: .6; }
.card.is-ruled { opacity: .5; }

/* ---------- buildings view ---------- */
.buildings { display: grid; gap: 12px; max-width: 820px; margin: 0 auto; }
.bcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  transition: box-shadow .2s;
}
.bcard:hover { box-shadow: var(--shadow-hover); }
.bcard.status-ruled_out { opacity: .62; }
.bcard.status-interested { border-color: var(--new); border-width: 1.5px; }
.binfo { display: grid; gap: 4px; }
.binfo strong { font-size: 1rem; font-weight: 600; }
.binfo .muted { font-size: .84rem; }
.bstatus { font-size: .74rem; font-weight: 700; width: fit-content; padding: 3px 9px; border-radius: 999px; }
.bstatus.ruled_out { background: #f1f2f4; color: var(--gone); }
.bstatus.interested { background: #ecfdf3; color: #087443; }
.bbtns { display: flex; gap: 7px; flex: 0 0 auto; }
.bbtns button {
  border: 1px solid var(--line-2); background: #fff; border-radius: var(--r-sm); padding: 9px 12px;
  font-size: .83rem; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink-2);
  min-height: 40px; transition: all .15s;
}
.btn-interested:hover { border-color: var(--new); color: var(--new); }
.btn-ruled:hover { border-color: var(--gone); color: var(--gone); }
.btn-interested.active { background: var(--new); color: #fff; border-color: var(--new); }
.btn-ruled.active { background: var(--gone); color: #fff; border-color: var(--gone); }

@media (max-width: 560px) {
  .bcard { flex-direction: column; align-items: stretch; }
  .bbtns button { flex: 1; }
}

/* ---------- Map view ---------- */
.mapwrap { margin-top: 4px; }
#map {
  height: 70vh; min-height: 420px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden; background: #e8eaf2;
}
.map-legend {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  margin-top: 12px; font-size: .85rem; color: var(--ink-2);
}
.map-legend .dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  margin-right: 5px; vertical-align: -1px; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line-2);
}
.map-legend .dot.interested { background: var(--agree); }
.map-legend .dot.none       { background: var(--accent); }
.map-legend .dot.ruled      { background: var(--rose); }

/* count label sitting inside each marker */
.map-count {
  background: transparent; border: 0; box-shadow: none;
  color: #fff; font-weight: 700; font-size: .78rem;
}
.map-count::before { display: none; }

/* popup contents */
.map-popup .mp-head { margin-bottom: 8px; }
.map-popup .mp-head strong { display: block; font-size: .98rem; color: var(--ink); }
.map-popup .mp-sub { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.map-popup .mp-status {
  display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
}
.map-popup .mp-status.interested { background: #d1fae5; color: #065f46; }
.map-popup .mp-status.ruled_out  { background: #fbe3ec; color: #9d2c52; }
.map-popup .mp-list { display: flex; flex-direction: column; }
.map-popup .mp-item {
  display: block; padding: 7px 0; border-top: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.map-popup .mp-item:hover .mp-rent { color: var(--accent); }
.map-popup .mp-rent { display: block; font-weight: 600; font-size: .9rem; }
.map-popup .mp-meta { display: block; color: var(--muted); font-size: .8rem; }
.map-popup .mp-more { padding-top: 7px; color: var(--muted); font-size: .8rem; }

/* ---------- Mobile / touch refinements ---------- */
@media (max-width: 640px) {
  /* 16px on form controls stops iOS Safari auto-zooming the page on focus */
  #sort, .notes, #search { font-size: 16px; }

  /* let the search box take the full width, sort + filters drop below it */
  .controls { flex-wrap: wrap; }
  #search { flex: 1 1 100%; }
  #sort { max-width: none; flex: 1 1 auto; }

  /* slightly bigger stars/hearts for fingertips */
  .stars button { font-size: 1.5rem; padding: 4px 2px; }
  .heart { font-size: 1.4rem; padding: 6px; }
}