/* Propizy Web — design tokens mirror the Flutter app theme (AppTheme). */
:root {
  --primary: #2A59C3;
  --primary-dark: #1F45A0;
  --secondary: #162A5C;
  --accent: #F4A261;
  --danger: #E76F51;
  --success: #2A9D8F;

  --bg: #F8F9FA;
  --surface: #FFFFFF;
  --surface-2: #F1F3F7;
  --border: #E5E7EB;
  --text: #1F2937;
  --text-muted: #6B7280;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .07);
  --radius: 14px;
  --radius-sm: 10px;
  --header-h: 62px;
}

:root[data-theme="dark"] {
  --primary: #6E93E8;
  --primary-dark: #4F79DC;
  --secondary: #C7D4F5;
  --bg: #121212;
  --surface: #1E1E1E;
  --surface-2: #262626;
  --border: #333333;
  --text: #ECEDEE;
  --text-muted: #AAAAAA;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: break-word;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
svg { width: 20px; height: 20px; fill: currentColor; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); font-size: 1.12rem; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 8px; }
.main-nav { display: flex; gap: 4px; margin-left: 14px; flex: 1; }
.main-nav a {
  padding: 8px 13px; border-radius: 999px; color: var(--text-muted); font-weight: 600; font-size: .95rem;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.main-nav a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-toggle { display: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 38px; padding: 0 9px;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: .82rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .ic-sun { display: none; }
:root:not([data-theme="dark"]) .ic-moon { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 11px; border: 1px solid transparent;
  font-weight: 650; cursor: pointer; background: var(--surface-2); color: var(--text);
}
.btn:hover { filter: brightness(.97); }
.btn-sm { padding: 8px 14px; font-size: .9rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-whatsapp { background: #25D366; color: #06301a; }
.btn-google { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 11px 18px; border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 650; cursor: pointer; }
.btn-google:hover { background: var(--surface-2); }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font-size: .88rem; }
.link-btn:hover { text-decoration: underline; }

.user-menu { position: relative; }
.avatar-btn { width: 38px; height: 38px; padding: 0; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; overflow: hidden; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.dropdown {
  position: absolute; right: 0; top: 46px; min-width: 220px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column;
}
.dropdown-head { display: flex; flex-direction: column; padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown a, .dropdown button {
  text-align: left; background: none; border: 0; color: var(--text);
  padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: .93rem;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Page furniture ---------- */
main { padding: 22px 0 56px; min-height: 60vh; }
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; margin: 4px 0 18px; }
.page-head h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; }
.result-count { color: var(--text-muted); font-size: .92rem; }

/* ---------- Filters ---------- */
.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.filters-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filters-top .search-field { flex: 1 1 220px; }
.adv-toggle { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filters-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.filters-row.secondary { margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; color: var(--text-muted); font-weight: 600; }
.field input, .field select {
  font: inherit; font-size: .95rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; border-color: var(--primary); }
.search-field { position: relative; }
.filters-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
  padding: 8px 14px; border-radius: 8px; font-weight: 650; font-size: .9rem;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: .88rem; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(16,24,40,.13); }
.card-media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-link { position: absolute; inset: 0; z-index: 1; }
.card-body { padding: 13px 14px 15px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-price { font-size: 1.12rem; font-weight: 800; color: var(--primary); letter-spacing: -.02em; }
.card-price small { font-weight: 600; color: var(--text-muted); font-size: .72rem; }
.card-title { font-size: .98rem; font-weight: 650; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-sub { color: var(--text-muted); font-size: .86rem; display: flex; align-items: center; gap: 5px; }
.card-specs { display: flex; flex-wrap: wrap; gap: 12px; color: var(--text-muted); font-size: .84rem; margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.card-specs span { display: inline-flex; align-items: center; gap: 5px; }
.card-specs svg { width: 15px; height: 15px; }

.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; z-index: 2; }
.badge {
  background: rgba(0,0,0,.68); color: #fff; padding: 4px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em; backdrop-filter: blur(4px);
}
.badge.rent { background: var(--success); }
.badge.sale { background: var(--primary); }
.badge.new { background: var(--accent); color: #3a2408; }
.fav-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.9); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.fav-btn:hover { background: #fff; }
.fav-btn[aria-pressed="true"] { color: var(--danger); }
.fav-btn[aria-pressed="true"] svg { fill: var(--danger); }

/* ---------- States ---------- */
.skeleton-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-media { aspect-ratio: 4/3; }
.skeleton-line { height: 12px; border-radius: 6px; margin: 12px 14px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state h2 { color: var(--text); margin: 0 0 8px; font-size: 1.15rem; }
.empty-state svg { width: 46px; height: 46px; opacity: .45; margin-bottom: 10px; }

/* ---------- Detail ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .9rem; margin-bottom: 14px; }
.detail { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 26px; align-items: start; }
/* Grid items default to min-width:auto, which lets the gallery and thumb strip
   push the column wider than the viewport on narrow screens. */
.detail > * { min-width: 0; }
.thumbs { min-width: 0; }
.gallery { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.gallery-main { aspect-ratio: 16 / 10; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center;
}
.gallery-nav.prev { left: 10px; } .gallery-nav.next { right: 10px; }
.gallery-count { position: absolute; right: 12px; bottom: 12px; background: rgba(0,0,0,.62); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: .78rem; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.thumbs button { flex: 0 0 84px; height: 62px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; padding: 0; cursor: pointer; background: var(--surface-2); }
.thumbs button[aria-current="true"] { border-color: var(--primary); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

.detail h1 { font-size: 1.5rem; margin: 18px 0 6px; letter-spacing: -.02em; line-height: 1.28; }
.detail-price { font-size: 1.75rem; font-weight: 800; color: var(--primary); margin: 10px 0; }
.detail-price small { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 18px 0; }
.spec {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center;
}
.spec strong { display: block; font-size: 1.05rem; }
.spec span { color: var(--text-muted); font-size: .8rem; }
.section { margin: 26px 0; }
.section h2 { font-size: 1.08rem; margin: 0 0 10px; }
.section p { white-space: pre-wrap; margin: 0; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 13px; font-size: .85rem; }
.map-embed { width: 100%; aspect-ratio: 16/9; border: 1px solid var(--border); border-radius: var(--radius-sm); }

.sidecard {
  position: sticky; top: calc(var(--header-h) + 16px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.owner { display: flex; align-items: center; gap: 12px; }
.owner img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.owner-name { font-weight: 700; }
.contact-actions { display: flex; flex-direction: column; gap: 9px; }
.rating { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 700; }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9, 14, 28, .55); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; z-index: 1; width: min(420px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; padding: 26px; box-shadow: 0 24px 60px rgba(0,0,0,.28);
  max-height: 92vh; overflow-y: auto; overflow-x: hidden;
}
.modal-card h2 { margin: 0 0 4px; font-size: 1.25rem; }
.modal-card > p { margin: 0 0 18px; }
.modal-close { position: absolute; top: 12px; right: 12px; border: 0; }
#auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
#auth-form .field span { font-size: .84rem; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: .82rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-error { color: var(--danger); font-size: .86rem; margin: 0; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--secondary); color: #fff; padding: 12px 20px; border-radius: 999px;
  z-index: 90; box-shadow: var(--shadow); font-size: .92rem; max-width: 90vw; text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .sidecard { position: static; }
}
@media (max-width: 720px) {
  .adv-toggle { display: inline-flex; }
  .adv { display: none; }
  .adv.open { display: block; }
  .nav-toggle { display: inline-flex; }
  .main-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 8px 16px 14px; margin: 0; gap: 2px; display: none; box-shadow: var(--shadow);
  }
  .main-nav.open { display: flex; }
  .brand span { display: none; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .page-head h1 { font-size: 1.35rem; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 26px 0; margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-inner p { margin: 4px 0 0; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: .88rem; }
.site-footer nav a { color: var(--text-muted); }

/* ================================================================
   Map
   ================================================================ */
.page-head-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.map-shell { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.map-canvas { width: 100%; height: min(68vh, 640px); background: var(--surface-2); }
.map-shell.picker .map-canvas { height: 320px; }
.detail-map { height: 300px; border-radius: var(--radius-sm); border: 1px solid var(--border); overflow: hidden; }
.map-locate {
  position: absolute; right: 12px; bottom: 26px; z-index: 500;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.map-locate:hover { background: var(--surface-2); }
.map-locate:disabled { opacity: .6; cursor: progress; }

.price-marker {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: .78rem; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); white-space: nowrap; border: 2px solid #fff;
}
.price-marker.rent { background: var(--success); }
.map-popup { display: block; width: 190px; color: var(--text); }
.map-popup:hover { text-decoration: none; }
.map-popup img { width: 100%; height: 108px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.map-popup strong { display: block; color: var(--primary); font-size: 1rem; }
.map-popup small { color: var(--text-muted); font-weight: 600; font-size: .72rem; }
.map-popup span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .85rem; }

.leaflet-container { font: inherit; background: var(--surface-2); }
:root[data-theme="dark"] .leaflet-tile { filter: brightness(.82) contrast(1.05); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper,
:root[data-theme="dark"] .leaflet-popup-tip,
:root[data-theme="dark"] .leaflet-control-zoom a,
:root[data-theme="dark"] .leaflet-control-attribution {
  background: var(--surface); color: var(--text);
}
:root[data-theme="dark"] .leaflet-control-zoom a { border-color: var(--border); }
:root[data-theme="dark"] .leaflet-control-attribution a { color: var(--primary); }

/* ================================================================
   Forms (add listing, settings)
   ================================================================ */
.listing-form { display: flex; flex-direction: column; gap: 18px; }
.form-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.form-card > h2 { font-size: 1.05rem; margin: 0; }
.form-card summary { cursor: pointer; }
.form-card summary::marker { color: var(--text-muted); }
.field-label { font-size: .82rem; color: var(--text-muted); font-weight: 600; }
.field textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; resize: vertical;
}
.field textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; border-color: var(--primary); }
.form-submit { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }

.photo-buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.photo-empty { margin: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-item { position: relative; margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.photo-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.photo-item .badge.cover { position: absolute; top: 8px; left: 8px; background: var(--primary); }
.photo-actions { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; }
.photo-actions button {
  width: 28px; height: 28px; border-radius: 8px; border: 0; cursor: pointer;
  background: rgba(0,0,0,.62); color: #fff; display: flex; align-items: center; justify-content: center;
}
.photo-actions button:disabled { opacity: .35; cursor: default; }
.photo-actions svg { width: 15px; height: 15px; }
.photo-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.25); }
.photo-progress span { display: block; height: 100%; width: 0; background: var(--success); transition: width .2s ease; }

/* ================================================================
   Settings
   ================================================================ */
.listing-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.listing-row {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
}
.listing-row.is-hidden { opacity: .6; }
.listing-row img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.listing-row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.listing-row-main a { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-row-actions { display: flex; gap: 6px; margin-left: auto; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-list a { font-size: .93rem; }
