/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: #F8FAFC;
  color: #1E293B;
}
a { color: #1D4ED8; text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ── CSS Variables ───────────────────────────────────────────────────────── */
:root {
  --navy:    #0D1B2A;
  --slate:   #334155;
  --mid:     #64748B;
  --light:   #CBD5E1;
  --offwhite:#F8FAFC;
  --white:   #FFFFFF;
  --accent:  #1D4ED8;
  --accent-light: #EFF6FF;
  --success: #16A34A;
  --danger:  #DC2626;
  --warn:    #D97706;
  --border:  #E2E8F0;
  --shadow:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --sidebar-w: 220px;
}

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* Auth views need flex when active — use higher specificity */
#view-login.active, #view-register.active { display: flex; }

/* ── Login / Register ────────────────────────────────────────────────────── */
#view-login, #view-register {
  align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0D1B2A 0%, #1E3A5F 100%);
}
.login-wrap {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 20px; font-weight: 500;
  color: var(--navy); margin-bottom: 24px;
}
.brand-icon { font-size: 22px; color: var(--accent); }
.brand-name { font-family: 'DM Serif Display', serif; }
.login-title { font-size: 22px; font-weight: 500; margin-bottom: 4px; }
.login-sub { color: var(--mid); margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-footer { margin-top: 20px; text-align: center; color: var(--mid); font-size: 13px; }
.form-error {
  background: #FEF2F2; border: 1px solid #FECACA;
  color: var(--danger); border-radius: 6px;
  padding: 8px 12px; font-size: 13px;
}

/* ── Form fields ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 500; color: var(--slate); }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--navy);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.12);
}
textarea { resize: vertical; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: #1E40AF; }
.btn-secondary { background: var(--white); color: var(--slate); border-color: var(--border); }
.btn-secondary:hover { background: var(--offwhite); }
.btn-ghost { background: transparent; color: var(--mid); }
.btn-ghost:hover { background: var(--offwhite); color: var(--slate); }
.btn-danger { background: #FEF2F2; color: var(--danger); border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── App shell layout ────────────────────────────────────────────────────── */
#view-app {
  display: flex; height: 100vh; overflow: hidden;
}
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--navy); color: var(--white);
  display: flex; flex-direction: column;
  padding: 20px 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px 20px;
  font-size: 16px; font-weight: 500;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-nav { flex: 1; padding: 16px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.65); font-size: 13px; font-weight: 500;
  transition: all 0.15s; cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--white); }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 16px 12px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--white); }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }
#logout-btn { color: rgba(255,255,255,0.5); font-size: 12px; }
#logout-btn:hover { color: var(--white); background: rgba(255,255,255,0.08); }

/* ── Main content ────────────────────────────────────────────────────────── */
#main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.page { display: none; flex: 1; padding: 28px 32px; }
.page.active { display: flex; flex-direction: column; gap: 20px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-title { font-family: 'DM Serif Display', serif; font-size: 22px; font-weight: 400; color: var(--navy); }
.page-sub { font-size: 13px; color: var(--mid); margin-top: 3px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 140px; }
.filter-group label { font-size: 12px; font-weight: 500; color: var(--mid); text-transform: uppercase; letter-spacing: 0.04em; }
.location-wrap, .range-wrap { display: flex; gap: 6px; }
.location-wrap input { flex: 1; }
.location-wrap select { width: 90px; }
.range-sep { align-self: center; color: var(--mid); }
.range-wrap input { width: 90px; }
.filter-group-actions { flex-direction: row; gap: 8px; margin-top: 8px; }

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-meta { font-size: 13px; color: var(--mid); }
.results-sort-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sort-label { font-size: 12px; color: var(--mid); }
.sort-btn {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--white); color: var(--slate); font-size: 12px; cursor: pointer;
  transition: all 0.12s;
}
.sort-btn.active, .sort-btn:hover { background: var(--navy); color: var(--white); border-color: var(--navy); }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ── Property card ───────────────────────────────────────────────────────── */
.prop-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
}
.prop-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-1px); }
.card-accent { height: 3px; }
.card-body { padding: 14px 16px; flex: 1; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.card-price { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--navy); }
.type-badge {
  font-size: 11px; padding: 3px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap;
}
.card-name { font-size: 13px; font-weight: 500; color: var(--navy); margin-bottom: 3px; }
.card-loc { font-size: 12px; color: var(--mid); margin-bottom: 12px; display: flex; align-items: center; gap: 4px; }
.card-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.metric-label { font-size: 11px; color: var(--mid); }
.metric-val { font-size: 13px; font-weight: 500; color: var(--slate); }
.card-desc { font-size: 12px; color: var(--mid); line-height: 1.5; }
.card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.card-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; transition: all 0.12s; color: var(--mid);
}
.icon-btn:hover { background: var(--offwhite); color: var(--navy); border-color: var(--accent); }
.icon-btn.bookmarked { background: #EFF6FF; color: var(--accent); border-color: var(--accent); }

/* ── States ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.empty-state, .loading-state, .placeholder-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; gap: 12px; text-align: center;
}
.empty-icon, .placeholder-icon { font-size: 36px; color: var(--light); }
.empty-msg, .placeholder-msg { color: var(--mid); max-width: 300px; }
.spinner {
  width: 28px; height: 28px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Map ─────────────────────────────────────────────────────────────────── */
.map-layout {
  display: flex; gap: 16px; flex: 1; min-height: 0; height: calc(100vh - 120px);
}
#map-container { flex: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
#map-sidebar {
  width: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding-right: 4px;
}
.map-list-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; cursor: pointer; transition: all 0.12s;
}
.map-list-card:hover, .map-list-card.highlighted {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(29,78,216,0.15);
}
.map-card-price { font-size: 15px; font-weight: 500; color: var(--navy); }
.map-card-name { font-size: 12px; color: var(--slate); }
.map-card-loc { font-size: 11px; color: var(--mid); }

/* ── Saved searches ──────────────────────────────────────────────────────── */
#saved-list { display: flex; flex-direction: column; gap: 12px; }
.saved-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.saved-info { flex: 1; }
.saved-name { font-weight: 500; color: var(--navy); margin-bottom: 3px; }
.saved-params { font-size: 12px; color: var(--mid); }
.saved-alert { font-size: 12px; color: var(--success); margin-top: 3px; }
.saved-actions { display: flex; gap: 8px; }

/* ── Notes ───────────────────────────────────────────────────────────────── */
#notes-list { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px;
}
.note-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.note-property { font-weight: 500; color: var(--navy); }
.note-meta { font-size: 12px; color: var(--mid); }
.note-text { font-size: 13px; color: var(--slate); line-height: 1.6; }
.note-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--white); border-radius: 12px;
  width: 100%; max-width: 680px; max-height: 90vh;
  overflow-y: auto; padding: 28px; position: relative;
}
.modal-sm { max-width: 420px; }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 16px;
  cursor: pointer; color: var(--mid); padding: 4px;
}
.modal-close:hover { color: var(--navy); }
.modal-title { font-size: 16px; font-weight: 500; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── Property detail (inside modal) ─────────────────────────────────────── */
.detail-header { margin-bottom: 20px; }
.detail-price { font-family: 'DM Serif Display', serif; font-size: 28px; color: var(--navy); }
.detail-name { font-size: 18px; font-weight: 500; margin: 4px 0; }
.detail-loc { color: var(--mid); font-size: 14px; }
.detail-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0;
}
.detail-metric {
  background: var(--offwhite); border-radius: 8px; padding: 12px;
}
.detail-metric-label { font-size: 11px; color: var(--mid); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-metric-val { font-size: 16px; font-weight: 500; margin-top: 2px; }
.detail-section { margin-bottom: 18px; }
.detail-section-title { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mid); margin-bottom: 8px; }
.detail-highlights { display: flex; flex-direction: column; gap: 5px; }
.detail-highlight { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--slate); }
.detail-highlight::before { content: "•"; color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--white);
  padding: 10px 20px; border-radius: 8px; font-size: 14px;
  z-index: 9999; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: fadeInUp 0.2s ease;
}
.toast.success { background: #166534; }
.toast.error { background: #991B1B; }
@keyframes fadeInUp { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Type colors ─────────────────────────────────────────────────────────── */
.accent-office    { background: #1D4ED8; }
.accent-retail    { background: #9A3412; }
.accent-multi     { background: #5B21B6; }
.accent-mixed     { background: #0F766E; }
.accent-land      { background: #166534; }
.accent-food      { background: #92400E; }
.accent-industrial{ background: #1E3A5F; }
.accent-default   { background: #64748B; }

.badge-office     { background: #DBEAFE; color: #1E40AF; }
.badge-retail     { background: #FFEDD5; color: #9A3412; }
.badge-multi      { background: #EDE9FE; color: #5B21B6; }
.badge-mixed      { background: #CCFBF1; color: #0F766E; }
.badge-land       { background: #DCFCE7; color: #166534; }
.badge-food       { background: #FEF3C7; color: #92400E; }
.badge-industrial { background: #E0E7FF; color: #1E3A5F; }
.badge-default    { background: #F1F5F9; color: #64748B; }
