/* ===================== PROPERTY CARD ===================== */
.property-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.property-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.property-card-img {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 2.8;
  background: var(--border);
}

.property-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.property-card:hover .property-card-img img {
  transform: scale(1.04);
}

.card-badge-top {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  gap: 0.4rem;
  z-index: 1;
}

.card-actions-top {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.4rem;
  z-index: 1;
}

.card-icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-secondary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.card-icon-btn:hover { background: #fff; transform: scale(1.1); }
.card-icon-btn.favorited { color: var(--danger); }
.card-icon-btn.compare-active { color: var(--accent); }

.property-card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; }

.property-price {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.property-price-sub { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); }

.property-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0.35rem 0 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.property-location {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.property-specs {
  display: flex;
  gap: 0.75rem;
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.spec-item svg { color: var(--text-muted); flex-shrink: 0; }

.property-card-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
}
.agent-mini {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.agent-mini-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.agent-mini-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.card-posted { font-size: 0.72rem; color: var(--text-muted); }

/* List view variant */
.property-card.list-view {
  flex-direction: row;
  max-height: 200px;
}
.property-card.list-view .property-card-img {
  width: 260px;
  min-width: 260px;
  aspect-ratio: unset;
  height: 200px;
}
.property-card.list-view .property-card-body {
  padding: 1rem 1.25rem;
}
.property-card.list-view .property-card-footer {
  display: none;
}

/* ===================== SEARCH PAGE ===================== */
.search-page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.5rem;
  min-height: calc(100vh - var(--navbar-h));
  align-items: start;
}

.filter-sidebar {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: sticky;
  top: calc(var(--navbar-h) + 1.5rem);
  max-height: calc(100vh - var(--navbar-h) - 3rem);
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.filter-sidebar::-webkit-scrollbar { width: 4px; }
.filter-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.filter-section { margin-bottom: 1.5rem; }
.filter-section:last-child { margin-bottom: 0; }

.filter-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-chip {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-secondary);
  background: var(--bg-card);
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }

.price-range-inputs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.price-range-inputs input { width: 100%; padding: 0.4rem 0.6rem; font-size: 0.8rem; }

.filter-clear-btn {
  font-size: 0.78rem;
  color: var(--primary);
  cursor: pointer;
  float: right;
  margin-top: -1.5rem;
  font-weight: 600;
}

/* Results area */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.results-count { font-size: 0.9rem; color: var(--text-secondary); }
.results-count strong { color: var(--text-primary); font-weight: 700; }

.view-toggle { display: flex; gap: 0.25rem; }
.view-toggle-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  transition: all 0.15s ease;
}
.view-toggle-btn:hover { color: var(--primary); border-color: var(--primary); }
.view-toggle-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.sort-select { min-width: 160px; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.results-list { display: flex; flex-direction: column; gap: 1rem; }

/* Map container */
.map-results-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1rem;
  height: calc(100vh - var(--navbar-h) - 4rem);
}
.map-listing-panel {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.map-listing-panel::-webkit-scrollbar { width: 4px; }
.map-listing-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#map-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  padding: 0 !important;
  overflow: hidden;
}
.map-popup-card { padding: 0.75rem; min-width: 200px; max-width: 240px; }
.map-popup-img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 0.5rem; }
.map-popup-price { font-size: 1rem; font-weight: 700; color: var(--primary); }
.map-popup-title { font-size: 0.82rem; font-weight: 600; margin: 0.2rem 0; }
.map-popup-loc { font-size: 0.75rem; color: var(--text-muted); }
.map-popup-link { display: block; margin-top: 0.5rem; text-align: center; font-size: 0.78rem; font-weight: 600; color: var(--primary); }

/* Mobile filter button */
.mobile-filter-btn {
  display: none;
  position: fixed;
  bottom: 5.5rem;
  right: 1.25rem;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

/* ===================== PROPERTY DETAIL ===================== */
.property-detail-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 2rem;
  align-items: start;
  padding: 2rem 0;
}

.detail-sticky { position: sticky; top: calc(var(--navbar-h) + 1.5rem); }

/* Gallery */
.gallery-main {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--border);
  cursor: pointer;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease;
  z-index: 2;
}
.gallery-nav:hover { background: #fff; }
.gallery-nav.prev { left: 0.75rem; }
.gallery-nav.next { right: 0.75rem; }
.gallery-count {
  position: absolute;
  bottom: 0.75rem; right: 0.75rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}

.gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  overflow-x: auto;
}
.gallery-thumb {
  width: 70px; height: 50px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s ease;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb.active { border-color: var(--primary); }

/* Detail info */
.detail-price-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.detail-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-heading);
}
.detail-price-tag { font-size: 0.85rem; color: var(--text-muted); }

.detail-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.4rem; }
.detail-location { font-size: 0.9rem; color: var(--text-secondary); display: flex; align-items: center; gap: 0.35rem; margin-bottom: 1rem; }

.detail-specs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0;
}
.detail-spec {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
}
.detail-spec-value { font-weight: 700; font-size: 1.05rem; font-family: var(--font-heading); }
.detail-spec-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

.detail-description { line-height: 1.8; color: var(--text-secondary); font-size: 0.9rem; }

.amenities-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.amenity-tag {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Detail sidebar card */
.detail-sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.agent-card-header { padding: 1.25rem; }
.agent-card-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.agent-card-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.agent-card-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.agent-card-name { font-weight: 700; font-size: 0.95rem; }
.agent-card-agency { font-size: 0.8rem; color: var(--text-muted); }
.agent-card-rating { display: flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; margin-top: 0.25rem; }
.stars { color: var(--warning); letter-spacing: -1px; }

.enquiry-form { padding: 1.25rem; border-top: 1px solid var(--border); }
.enquiry-form-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.85rem; }

.emi-widget {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}
.emi-widget-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.85rem; display: flex; align-items: center; gap: 0.4rem; }
.emi-result {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  text-align: center;
}
.emi-amount { font-size: 1.35rem; font-weight: 700; color: var(--primary); font-family: var(--font-heading); }
.emi-label { font-size: 0.75rem; color: var(--text-muted); }

/* ===================== PHOTO LIGHTBOX ===================== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: var(--radius-sm); }
.lightbox-close {
  position: absolute;
  top: 1.25rem; right: 1.5rem;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  padding: 0.5rem;
  user-select: none;
}
.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

/* ===================== COMPARISON PAGE ===================== */
.compare-page { padding: 2rem 0; }
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th, .compare-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
  font-size: 0.875rem;
}
.compare-table th { background: var(--bg); font-weight: 600; }
.compare-table .row-label { font-weight: 600; color: var(--text-secondary); background: var(--bg); width: 160px; }
.compare-table .best { background: #E8F8F5; color: var(--success); font-weight: 700; }
.compare-prop-header { text-align: center; }
.compare-prop-img { width: 100%; height: 160px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 0.5rem; }
.compare-remove-prop { cursor: pointer; color: var(--danger); font-size: 0.8rem; font-weight: 600; }

/* ===================== STAR RATING ===================== */
.star-rating { display: flex; gap: 2px; cursor: pointer; }
.star-rating .star {
  font-size: 1.4rem;
  color: var(--border);
  transition: color 0.15s ease;
  user-select: none;
}
.star-rating .star.filled,
.star-rating .star:hover ~ .star { color: var(--warning); }
.star-rating:hover .star { color: var(--warning); }
.star-rating .star:hover ~ .star { color: var(--border); }

/* ===================== TOOLS PAGE ===================== */
.tools-page { padding: 2.5rem 0; }
.tools-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.tool-nav-btn {
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.15s ease;
}
.tool-nav-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.calculator-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.calc-result-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  color: #fff;
  text-align: center;
}
.calc-result-main { font-size: 2.5rem; font-weight: 700; font-family: var(--font-heading); line-height: 1; }
.calc-result-label { font-size: 0.875rem; opacity: 0.85; margin-top: 0.4rem; }
.calc-result-sub { font-size: 0.85rem; opacity: 0.75; margin-top: 0.75rem; }

.chart-container { position: relative; max-width: 300px; margin: 0 auto; }

.amort-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.amort-table th { background: var(--bg); padding: 0.5rem 0.75rem; text-align: right; font-weight: 600; color: var(--text-secondary); }
.amort-table th:first-child { text-align: left; }
.amort-table td { padding: 0.5rem 0.75rem; border-top: 1px solid var(--border-light); text-align: right; }
.amort-table td:first-child { text-align: left; font-weight: 600; }
.amort-table tr:hover td { background: var(--bg); }

.commission-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
}
.commission-row:last-child { border-bottom: none; }
.commission-row .value { font-weight: 700; }
.commission-row.total { font-weight: 700; font-size: 1rem; padding-top: 1rem; }
.commission-row.highlight .value { color: var(--success); }

/* ===================== PROFILE PAGE ===================== */
.profile-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  padding: 2rem 0;
  align-items: start;
}

.profile-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  position: sticky;
  top: calc(var(--navbar-h) + 1.5rem);
  box-shadow: var(--shadow-card);
}

.profile-avatar-section { text-align: center; margin-bottom: 1.25rem; }
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
  margin: 0 auto 0.75rem;
  overflow: hidden;
  border: 3px solid var(--primary-light);
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-weight: 700; font-size: 1rem; }
.profile-role { font-size: 0.8rem; color: var(--text-muted); }
.profile-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.profile-nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}
.profile-nav-item:hover { background: var(--bg); color: var(--primary); }
.profile-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.profile-content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

/* ===================== AUTH PAGES ===================== */
.auth-page {
  min-height: calc(100vh - var(--navbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #F0F4F8 0%, #EEF2FF 100%);
}

[data-theme="dark"] .auth-page { background: var(--bg); }

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.auth-logo { text-align: center; margin-bottom: 1.75rem; }
.auth-logo a { font-family: var(--font-heading); font-weight: 700; font-size: 1.5rem; color: var(--primary); }
.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 0.4rem; }
.auth-subtitle { text-align: center; color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.75rem; }
.auth-footer-text { text-align: center; font-size: 0.875rem; color: var(--text-muted); margin-top: 1.5rem; }
.auth-footer-text a { color: var(--primary); font-weight: 600; }

.role-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.role-option {
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.role-option:hover { border-color: var(--primary); }
.role-option.selected { border-color: var(--primary); background: var(--primary-light); }
.role-option-icon { font-size: 1.5rem; margin-bottom: 0.3rem; }
.role-option-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.role-option.selected .role-option-label { color: var(--primary); }

.password-wrapper { position: relative; }
.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--text-muted);
}

/* ===================== RESPONSIVE OVERRIDES ===================== */
@media (max-width: 1024px) {
  .search-page-layout { grid-template-columns: 1fr; }
  .filter-sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 300px;
    height: 100vh;
    border-radius: 0;
    z-index: 2000;
    max-height: 100vh;
  }
  .filter-sidebar.open { display: block; }
  .mobile-filter-btn { display: flex; }
  .property-detail-layout { grid-template-columns: 1fr; }
  .detail-sticky { position: static; }
}

@media (max-width: 768px) {
  .profile-layout { grid-template-columns: 1fr; }
  .profile-sidebar { position: static; }
  .detail-specs { grid-template-columns: repeat(2, 1fr); }
  .map-results-layout { grid-template-columns: 1fr; height: auto; }
  .map-listing-panel { max-height: 40vh; }
  .property-card.list-view { flex-direction: column; max-height: none; }
  .property-card.list-view .property-card-img { width: 100%; height: 200px; }
  .role-selector { grid-template-columns: repeat(3, 1fr); }
  .auth-card { padding: 1.75rem; }
}
