/* ───────── RESET + ROOT ───────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #0a4f94;
  --gold: #c39a00;
  --gap: 1rem;
  --card-bg: #ffffff;
  --light-bg: #f8f9fa;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
  --radius: 8px;
  --transition: all 0.2s ease;
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.6;
}

html {
  font-size: 17px;
}
body {
  background: linear-gradient(180deg, #e6ecf3, #d8dee6);
}
img {
  display: block;
  width: 100%;
  height: auto;
}

/* ───────── GRID / CARDS ───────── */
body {
  padding: var(--gap);
}

.grid {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 1000px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.card {
  border: 1px solid #e0e0e0;
  border-radius: 0.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s;
  position: relative;
  background: var(--card-bg);
}

.card:hover {
  transform: translateY(-3px);
}

.thumb {
  height: 220px;
  object-fit: cover;
  background: #f5f5f5;
}

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

.title {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
  text-align: center;
}

.cta {
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.3s;
  display: inline-block;
}
.cta:hover {
  background: #083d73;
}
.card-text {
  font-size: 0.95rem;
  line-height: 1.4;
  color: #333;
  display: inline-block;
  vertical-align: middle;
}

.status-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  padding: 2px 12px;
  border-radius: 4px;
  text-transform: capitalize;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

/* Property details container */
.property-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.detail-icon {
  color: var(--accent);
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.flip-horizontal {
  transform: scaleX(-1);
}

.detail-text {
  flex: 1;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-top: 6px;
}

.detail-text.price {
  font-weight: 600;
  color: var(--accent);
}

/* ───────── CONTENT PANEL (white canvas) ───────── */

.content-panel{
  background:#fff;
  border-radius:12px;
  box-shadow:0 4px 24px rgba(0,0,0,.08);
  padding:0.2rem 1.0rem 1rem;
  margin:0 auto 2rem;
  max-width: 1200px;
}

.map-container,
.controls-container,
.grid {
  max-width: 1200px;
  margin: 2rem auto;
}

/* ───────── HEADER ───────── */
.modern-header {
  background: linear-gradient(135deg, #0a4f94 0%, #1e3c72 100%);
  padding: 1.2rem 0;
  box-shadow: 0 4px 20px rgba(10, 79, 148, 0.3);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #0a4f94;
}

.brand-title {
  font-size: 1.65rem;
  font-weight: 700;
  color: #fff;
}

/* ───────── MAP ───────── */
.map-container { max-width: 1200px; margin: 0 auto 1rem; }

#propertyMap {
  width: 100%;
  height: 580px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  background: #f8f9fa;
  position: relative;
}

/* ───────── MAP MARKERS & CLUSTERS ───────── */
.leaflet-marker-icon.marker-cluster {
  background: none !important;
}

.marker-cluster .cluster-inner {
  width: 36px;
  height: 36px;
  line-height: 36px;
  border-radius: 50%;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.marker-cluster.cluster-small .cluster-inner {
  background: #0a4f94;
}

.marker-cluster.cluster-medium .cluster-inner {
  background: #c39a00;
}

.marker-cluster.cluster-large .cluster-inner {
  background: #b30000;
}

/* ───────── CUSTOM PIN MARKERS ───────── */
.custom-pin-marker {
  background: transparent !important;
  border: none !important;
}

.custom-pin {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.1s ease;
}

.custom-pin:hover {
  transform: scale(1.05);
}

/* ───────── MAP POPUPS ───────── */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
}

.leaflet-popup-content {
  margin: 12px;
}

.property-popup-enhanced {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 320px;
  font-family: system-ui, sans-serif;
}

.popup-main-content {
  display: flex;
  gap: 12px;
}

.popup-thumb {
  flex-shrink: 0;
  width: 140px;
  height: 100px;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
}

.popup-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.popup-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.popup-title {
  font-size: 14px;
  margin: 0;
  line-height: 1.3;
  margin-bottom: 4px;
}

.popup-developer,
.popup-location,
.popup-price {
  font-size: 12px;
  font-weight: 600;
  color: #0a4f94;
  margin: 2px 0;
}

.leaflet-popup-content .popup-cta {
  background: var(--accent) !important;
  color: #fff !important;
  font-size: 11px !important;
  padding: 6px 12px !important;
  border-radius: 4px !important;
  text-decoration: none !important;
  display: block !important;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.leaflet-popup-content .popup-cta:hover {
  background: #083d73 !important;
  color: #fff !important;
}

/* ───────── SEARCH / FILTER BAR ───────── */
.controls-container {
  max-width: 1200px;
  margin: 1.8rem auto 1.2rem;
  padding: 0 1rem;
}

.controls-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.controls-left {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex: 1;
}

.search-wrapper {
  position: relative;
  flex: 0 1 300px;
}

.search-input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 3rem;
  border: 1px solid #ddd;
  border-radius: 30px;
  font-size: 1rem;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.25s;
}

.search-input:focus {
  outline: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  font-size: 1rem;
}

.filter-button {
  background: linear-gradient(135deg, #0a4f94, #1e3c72);
  color: #fff;
  border: none;
  padding:0.6rem 1.2rem;
  border-radius: 25px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.25s, opacity 0.25s;
}

.filter-button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.filter-button.has-filters {
  font-weight: 600;
}

.prop-counter{
  background: linear-gradient(135deg, #0a4f94, #1e3c72);
  color:#fff;
  padding:0.6rem 1.2rem;
  border-radius:25px;
  font-weight:500;
  font-size:0.9rem;
  box-shadow:0 2px 6px rgba(0,0,0,.15);
  white-space:nowrap;
}

/* ───────── ENHANCED FILTER PANEL - NARROWER WIDTH ───────── */
.filter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s;
}

.filter-overlay.active {
  opacity: 1;
  visibility: visible;
}

.filter-panel {
  position: fixed;
  top: 0;
  right: -480px; /* Narrower than 600px but not as narrow as 420px */
  width: 480px;
  height: 100vh;
  background: #fff;
  box-shadow: -6px 0 25px rgba(0, 0, 0, 0.1);
  transition: right 0.3s ease;
  overflow: hidden;
  z-index: 2002;
  display: flex;
  flex-direction: column;
}

.filter-panel.active {
  right: 0;
}

.filter-header {
  background: linear-gradient(135deg, #0a4f94, #1e3c72);
  color: #fff;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.filter-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.close-filter {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  transition: var(--transition);
}

.close-filter:hover {
  background: rgba(255,255,255,0.1);
}

/* ─── Scrollable Content ─── */
.filter-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* ─── PERMANENT SORT CONTROLS - ALWAYS VISIBLE ─── */
.sort-controls-permanent {
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 5;
}

.sort-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.sort-icon {
  font-size: 1rem;
  color: var(--accent);
}

.sort-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.sort-group {
  display: flex;
  align-items: center;
}

.sort-select {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: white;
  color: var(--text);
  font-weight: 500;
  transition: var(--transition);
}

.sort-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10, 79, 148, 0.1);
}

/* ─── Filter Sections - Original Style ─── */
.filter-section {
  border-bottom: 1px solid var(--border);
}

.section-header {
  background: var(--light-bg);
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  width: 100%;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
}

.section-header:hover {
  background: #e9ecef;
}

.section-icon {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.section-header[aria-expanded="true"] .section-icon {
  transform: rotate(180deg);
}

/* ─── SECTION CONTENT LAYOUT ─── */
.section-content {
  padding: 1.5rem;
  display: none;
  gap: 1.25rem;
}

.section-content.active {
  display: flex;
  flex-direction: column;
}

/* Default: 2 columns for most sections */
.section-content:not(.single-column):not(.status-layout) {
  display: none;
}

.section-content.active:not(.single-column):not(.status-layout) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Single column sections */
.section-content.single-column {
  display: none;
}

.section-content.single-column.active {
  display: block;
}

/* Status section - special layout for 3 items (2 + 1 centered) */
.section-content.status-layout {
  display: none;
}

.section-content.status-layout.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.section-content.status-layout.active .filter-group:last-child {
  grid-column: 1 / -1;
  max-width: 70%;
  margin: 0 auto;
}

/* Property Details - special layout for 4 items (2x2) */
.section-content.property-details {
  display: none;
}

.section-content.property-details.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Financial - special layout for 5 items (2+2+1 centered) */
.section-content.financial-layout {
  display: none;
}

.section-content.financial-layout.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.section-content.financial-layout.active .filter-group:last-child {
  grid-column: 1 / -1;
  max-width: 70%;
  margin: 0 auto;
}

/* ─── Custom Multi-Select Dropdown ─── */
.custom-multiselect {
  position: relative;
  width: 100%;
}

.multiselect-trigger {
  width: 100%;
  padding: 0.7rem 2.5rem 0.7rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
  min-height: 42px;
}

.multiselect-trigger:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(10, 79, 148, 0.1);
}

.multiselect-trigger.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10, 79, 148, 0.1);
}

.trigger-text {
  flex: 1;
  text-align: left;
  color: var(--text);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.trigger-text.placeholder {
  color: var(--text-muted);
}

.trigger-count {
  background: var(--accent);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.trigger-arrow {
  position: absolute;
  right: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  pointer-events: none;
  flex-shrink: 0;
}

.multiselect-trigger.active .trigger-arrow {
  transform: rotate(180deg);
}

/* ─── Dropdown Menu ─── */
.multiselect-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.multiselect-dropdown.active {
  display: block;
}

.dropdown-option {
  padding: 0.65rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid #f8f9fa;
  font-size: 0.85rem;
}

.dropdown-option:last-child {
  border-bottom: none;
}

.dropdown-option:hover {
  background: var(--light-bg);
}

.dropdown-option.selected {
  background: rgba(10, 79, 148, 0.05);
}

.option-checkbox {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-radius: 3px;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}

.option-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.option-checkbox.checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 10px;
  font-weight: 600;
}

.option-text {
  flex: 1;
  font-size: 0.85rem;
  text-transform: capitalize;
}

/* ─── Facilities Match Toggle ─── */
.facilities-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.match-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.match-toggle {
  position: relative;
  width: 36px;
  height: 18px;
  background: #ccc;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.3s;
}

.match-toggle.active {
  background: var(--accent);
}

.match-toggle::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.match-toggle.active::before {
  transform: translateX(18px);
}

.match-toggle-label {
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 500;
}

/* ─── Regular Form Controls ─── */
.filter-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.filter-input, .filter-select {
  width: 100%;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: var(--transition);
}

.filter-input:focus, .filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10, 79, 148, 0.1);
}

/* ─── Action Buttons ─── */
.filter-actions {
  padding: 1.25rem;
  background: white;
  border-top: 2px solid var(--border);
  display: flex;
  gap: 0.75rem;
  position: sticky;
  bottom: 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

.apply-filters,
.clear-filters {
  flex: 1;
  cursor: pointer;
  transition: opacity 0.25s, transform 0.25s;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
}

.apply-filters {
  background: var(--accent);
  color: #fff;
}

.apply-filters:hover {
  background: #083d73;
  transform: translateY(-1px);
}

.clear-filters {
  background: #6c757d;
  color: #fff;
}

.clear-filters:hover {
  background: #5a6268;
  transform: translateY(-1px);
}

/* Filter tags display - Individual tags */
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  background: #e8eaed;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  max-width: 1200px;
  margin: 1.2rem auto 2rem;
  align-items: center;
  justify-content: flex-start;
}

.filter-tag,
.clear-all-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.filter-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.filter-tag span,
.clear-all-filters span {
  font-size: 0.75rem;
}

.remove-tag {
  background: none;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 0.2rem;
  opacity: 0.8;
  transition: opacity 0.2s ease, color 0.2s ease;
  font-weight: bold;
}

.remove-tag:hover {
  opacity: 1;
  color: #ffc107;
}

.clear-all-filters {
  background: #b30000;
  margin-right: 0.5rem;
}
.clear-all-filters:hover {
  background: #990000;
  transform: translateY(-1px);
}

/* Empty state */
.empty-state {
  max-width: 400px;
  margin: 3rem auto;
  text-align: center;
  padding: 2rem;
}

.empty-content {
  background: white;
  border-radius: 12px;
  padding: 3rem 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.empty-icon {
  font-size: 3rem;
  margin: 0;
  opacity: 0.5;
}

.empty-state h3 {
  color: var(--accent);
  margin: 1rem 0 0.5rem;
}

.empty-state p {
  color: #666;
  margin: 0;
}

/* ───────── RESPONSIVE ───────── */
@media (max-width: 768px) {
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .controls-left {
    width: 100%;
  }
  
  .filter-button,
  .prop-counter {
    width: 100%;
    text-align: center;
  }
  
  .filter-panel {
    width: 100%;
    right: -100%;
  }
  
  /* All sections become single column on mobile */
  .section-content.active:not(.single-column) {
    display: flex !important;
    flex-direction: column;
  }
  
  .section-content.status-layout.active .filter-group:last-child,
  .section-content.financial-layout.active .filter-group:last-child {
    max-width: 100%;
    margin: 0;
  }
  
  .filter-tags {
    gap: 0.3rem;
    padding: 0.75rem;
  }
  
  .filter-tag {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}

@media (max-width: 640px) {
  .filter-panel {
    width: 100vw;
    border-radius: 0;
  }
}