/*
Theme Name: REM Theme
Description: قالب خفيف لواجهة المنصة العقارية.
Version: 0.1.2
Requires PHP: 8.1
Text Domain: rem
*/

:root {
  --ink: #1d2733;
  --muted: #667180;
  --line: #e2e6eb;
  --bg: #f4f6f8;
  --surface: #fff;
  --brand: #0f6c6e;
  --brand-dark: #0b5456;
  --brand-tint: #e5f2f2;
  --accent: #c8671f;
  --danger: #b3261e;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 Tahoma, "Segoe UI", Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }

.wrap { width: min(1160px, 100%); margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1001; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo { flex: none; display: flex; align-items: center; gap: 9px; }
.logo img { height: 40px; width: auto; }
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-text b { font-size: 22px; font-weight: 800; color: var(--brand-dark); }
.logo-text small { font-size: 11.5px; font-weight: 700; letter-spacing: .4px; color: #c8671f; text-align: right; }
.header-actions { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.site-nav { display: flex; gap: 6px; align-items: center; }
.site-nav a, .add-link { white-space: nowrap; padding: 7px 11px; border-radius: var(--radius); }
.site-nav a:hover { background: var(--bg); }
.site-nav a[aria-current] { color: var(--brand-dark); font-weight: 700; }
.add-link { background: var(--brand); color: #fff; }
.add-link:hover { background: var(--brand-dark); }
.nav-toggle { display: none; }
.nav-toggle svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-toggle .icon-close, .nav-toggle[aria-expanded="true"] .icon-menu { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

main { padding: 16px 0 40px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 14px; color: var(--brand-dark); white-space: nowrap; cursor: pointer; }
.chip.active, .chip:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.search { font: inherit; font-size: 14px; color: var(--accent); border-color: var(--accent); }
.chip.search:hover { background: var(--accent); color: #fff; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.crumbs a { color: var(--brand-dark); }
.crumbs span + span::before, .crumbs a + a::before, .crumbs a + span::before { content: "‹ "; color: var(--muted); }

.page-title { font-size: 21px; font-weight: 700; margin-bottom: 2px; }
.result-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 12px; color: var(--muted); font-size: 14px; }
.result-bar select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.locations { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.locations a { padding: 4px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; color: var(--brand-dark); }
.locations a small { color: var(--muted); font-size: 13px; }

.featured { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 260px); gap: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; margin-bottom: 12px; }
.featured::-webkit-scrollbar { display: none; }
.featured-card { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--ink); color: #fff; aspect-ratio: 4/3; }
.featured-card .thumb { height: 100%; }
.featured-card .thumb img { height: 100%; width: 100%; object-fit: cover; }
.featured-card .overlay { position: absolute; inset: auto 0 0 0; padding: 26px 11px 9px; background: linear-gradient(transparent, rgba(0, 0, 0, .78)); font-size: 13px; }
.featured-card strong { display: block; font-size: 16px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 5px; font-size: 12px; font-weight: 700; background: #fff; color: var(--accent); }
.featured-card .badge { position: absolute; top: 8px; inset-inline-start: 8px; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.card { display: grid; grid-template-columns: 1fr 230px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 168px; }
.card:hover { border-color: #b9c2cc; }
.card .thumb { order: 2; background: var(--brand-tint); }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.card h2 { font-size: 15.5px; font-weight: 700; }
.price { color: var(--brand); font-weight: 700; font-size: 17px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13.5px; }
.excerpt { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fresh { margin-top: auto; font-size: 12.5px; color: var(--muted); }

.placeholder { width: 100%; height: 100%; min-height: 120px; display: grid; place-items: center; color: var(--brand); background: var(--brand-tint); font-size: 14px; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 18px; }
.pagination a, .pagination span { min-width: 36px; padding: 6px 10px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }

.empty { padding: 40px 16px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); }

.not-found { max-width: 560px; margin: 24px auto; padding: 36px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.not-found-art { margin: 0 auto 14px; fill: none; stroke: var(--brand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.not-found-art circle { fill: #fff4e5; stroke: var(--accent); }
.not-found-art path:last-child { stroke: var(--accent); stroke-width: 3.5; }
.not-found p { margin: 10px auto 0; max-width: 420px; color: var(--muted); }
.not-found-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.not-found-actions .btn { min-width: 150px; }

/* A phone user is already on the device the code would open, so it shows on larger screens only. */
.qr-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 16px; padding: 14px 16px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.qr-panel p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.empty .qr-panel { padding: 0; border: 0; color: var(--ink); }
.qr-code { flex: none; width: 112px; height: 112px; background: #fff; }
.qr-code svg { display: block; width: 100%; height: 100%; }
@media (max-width: 860px) { .qr-panel { display: none; } }

/* Filter drawer */
.drawer { position: fixed; inset: 0; z-index: 2000; visibility: hidden; }
.drawer.open { visibility: visible; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 32, .45); }
.drawer-panel { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(390px, 100%); background: var(--surface); display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.drawer-head button { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--line); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field > .label { font-size: 13.5px; font-weight: 700; }
.field input[type=text], .field input[type=password], .field input[type=tel], .field input[type=number], .field input[type=date], .field select, .field textarea {
  width: 100%; padding: 9px 11px; font: inherit; border: 1px solid #cfd5dc; border-radius: var(--radius); background: #fff; color: var(--ink);
}
.field :focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.field .error, .form-error { color: var(--danger); font-size: 13px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span { display: block; min-width: 40px; padding: 6px 10px; text-align: center; border: 1px solid #cfd5dc; border-radius: var(--radius); font-size: 14px; }
.seg input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn { display: inline-block; padding: 10px 16px; border: 1px solid var(--brand); border-radius: var(--radius); background: var(--brand); color: #fff; font: inherit; font-weight: 700; text-align: center; cursor: pointer; }
.btn:hover { background: var(--brand-dark); }
.btn.block { display: block; width: 100%; }
.btn.ghost { background: var(--surface); color: var(--brand-dark); }
.btn.ghost:hover { background: var(--brand-tint); }
.btn.small { padding: 5px 11px; font-size: 13.5px; font-weight: 400; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }

/* Listing page */
.listing-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 16px; margin-bottom: 10px; }
.gallery-main { background: var(--ink); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/10; margin-bottom: 8px; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumbs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.gallery-thumbs button { flex: none; width: 76px; height: 56px; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; background: none; }
.gallery-thumbs button.active { border-color: var(--brand); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.listing-title { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.description { white-space: pre-line; }
.spec { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
.spec div { background: var(--bg); border-radius: 6px; padding: 8px 10px; }
.spec dt { color: var(--muted); font-size: 12.5px; }
.spec dd { margin: 0; font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { padding: 3px 10px; border-radius: 5px; background: var(--brand-tint); color: var(--brand-dark); font-size: 13.5px; }
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th, .kv td { padding: 7px 0; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.kv th { color: var(--muted); font-weight: 400; width: 46%; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }
.sticky { position: sticky; top: 76px; }
.contact-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.mini-map { height: 240px; border-radius: 6px; z-index: 1; }
.alert { padding: 10px 13px; border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; background: #fff4e5; border: 1px solid #f2cf9e; color: #7a4a00; }
.alert.ok { background: var(--brand-tint); border-color: #b6d9d9; color: var(--brand-dark); }
.alert.bad { background: #fdecea; border-color: #f3c0bb; color: var(--danger); }
details summary { cursor: pointer; font-weight: 700; }

/* Forms */
.narrow { max-width: 430px; margin: 26px auto; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-card h1 { font-size: 21px; }
.phone-input { display: flex; direction: ltr; }
.phone-input span { padding: 9px 11px; background: var(--bg); border: 1px solid #cfd5dc; border-inline-end: 0; border-radius: 8px 0 0 8px; }
.phone-input input { border-radius: 0 8px 8px 0 !important; text-align: left; }
.steps { display: flex; gap: 8px; margin-bottom: 14px; }
.steps li { flex: 1; padding-top: 7px; border-top: 3px solid var(--line); color: var(--muted); font-size: 13.5px; list-style: none; }
.steps li.done { border-color: var(--brand); color: var(--ink); font-weight: 700; }
.steps { padding: 0; }
.step { display: none; flex-direction: column; gap: 14px; }
.step.active { display: flex; }
.step-actions { display: flex; justify-content: space-between; gap: 8px; }
.picker-map { height: 300px; border-radius: var(--radius); z-index: 1; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 6px; }
.check-grid label { font-size: 14px; display: flex; gap: 6px; align-items: center; font-weight: 400; }

.account-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.account-row:last-child { border-bottom: 0; }
.account-row .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: start; }
.status { font-size: 12.5px; padding: 1px 8px; border-radius: 5px; background: var(--bg); }
.status.published { background: var(--brand-tint); color: var(--brand-dark); }
.status.rejected { background: #fdecea; color: var(--danger); }
.status.pending { background: #fff4e5; color: #7a4a00; }

/* Map page */
.map-page { height: calc(100vh - 61px); position: relative; }
.map-page #map { position: absolute; inset: 0; z-index: 1; }
.map-bar { position: absolute; top: 10px; inset-inline: 10px; z-index: 1000; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.map-bar .chip { box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
.map-status { position: absolute; bottom: 14px; inset-inline-start: 50%; transform: translateX(50%); z-index: 1000; background: var(--surface); padding: 4px 12px; border-radius: 16px; font-size: 13px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.leaflet-marker-icon.cluster-pin { display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.price-pin { width: max-content !important; height: auto !important; padding: 2px 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--brand); color: var(--brand-dark); font-weight: 700; font-size: 12px; white-space: nowrap; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.leaflet-container { font: inherit; }

.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 22px 0; font-size: 14px; color: var(--muted); }
.site-footer .wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 6px; }
.footer-rights { color: var(--ink); font-weight: 700; }
.footer-contact a { color: var(--brand-dark); }

.pledge { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; background: #fff4e5; border: 1px solid #f2cf9e; border-radius: var(--radius); font-size: 14px; }
.pledge input { margin-top: 4px; flex: none; }
.pledge a, .guide-list a, .hint-line a { color: var(--brand-dark); font-weight: 700; }
.guide-list { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; }
.office-actions { display: flex; gap: 8px; margin-top: 10px; }
.office-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.office-card { margin: 0; display: block; }
.office-card:hover { border-color: #b9c2cc; }
.site-footer a:hover { color: var(--brand); }

@media (max-width: 860px) {
  .listing-layout { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  /* The main action stays in reach on phones instead of sitting at the page end. */
  .listing-layout { padding-bottom: 62px; }
  .contact-actions { position: fixed; inset-inline: 0; bottom: 0; z-index: 1000; margin: 0; padding: 9px 16px; background: var(--surface); border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .card { grid-template-columns: 1fr 118px; min-height: 124px; }
  .card .body { padding: 10px; gap: 3px; }
  .card h2 { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .excerpt { display: none; }
  .price { font-size: 15px; }
  /* Phones: logo, the add button and a menu button; the links open in a panel under the bar. */
  .site-header .wrap { gap: 10px; min-height: 56px; }
  .logo { gap: 7px; min-width: 0; }
  .logo img { height: 32px; }
  /* Android's Arabic fonts reach further below the line than Tahoma, so the name gets room
     before the address line. */
  .logo-text { line-height: 1.3; gap: 4px; }
  .logo-text b { font-size: 17px; }
  .logo-text small { font-size: 10.5px; line-height: 1.2; letter-spacing: .2px; }
  .header-actions { gap: 8px; }
  .add-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 13px; font-size: 14px; font-weight: 700; }
  .nav-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; }
  .nav-toggle[aria-expanded="true"] { background: var(--brand-tint); border-color: var(--brand-tint); color: var(--brand-dark); }
  .site-nav { display: none; position: absolute; top: 100%; inset-inline: 0; flex-direction: column; align-items: stretch; gap: 0; padding: 4px 16px 10px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 10px 18px rgba(29, 39, 51, .1); }
  .site-header.nav-open .site-nav { display: flex; }
  .site-nav a { padding: 13px 4px; font-size: 16px; border-radius: 0; border-bottom: 1px solid var(--line); }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav a:hover { background: none; color: var(--brand); }
  .account-row { grid-template-columns: 1fr; }
  .account-row .actions { justify-content: flex-start; }
}
