/* =========================
   Global + Layout
========================= */
:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --ink: #0f172a;
  --sub: #64748b;
  --brand: #0ea5e9;
  --brand-ink: #0b7fab;
  --line: #e5e7eb;
  --shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  --radius-lg: 12px;
  --radius-xl: 30px;
  --radius-xxl: 999px;
  --font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  color: var(--ink);
  background: var(--bg);
}

/* 通用隐藏 */
.hidden {
  display: none;
}

/* =========================
   Top Bar + Search
========================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topwrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.brand {
  font-weight: 700;
}

/* 搜索条：Destination + Button */
.searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 8px;
  padding: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xxl);
  box-shadow: var(--shadow);
  align-items: center;
}

.field {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-xxl);
  background: transparent;
}

.field-label {
  font-size: 12px;
  color: var(--sub);
  line-height: 1;
  white-space: nowrap;
}

.field input,
.field select {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  width: 100%;
}

.field label {
  font-size: 12px;
  color: var(--sub);
}

/* Buttons */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-xxl);
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-ink);
}

.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-ghost:hover {
  background: var(--card);
}

/* =========================
   Generic Containers
========================= */
.wrap {
  max-width: 1200px;
  margin: 18px auto;
  padding: 0 20px 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

/* =========================
   Main Grid
========================= */
#mainGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* 默认：只显示列表那一列 */
  gap: 20px;
  transition: 0.3s ease;
}

/* 地图模式：只显示地图这一列 */
#mainGrid.map-open {
  grid-template-columns: 1fr;
}

/* =========================
   Toolbar
========================= */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0 10px;
}

.stats {
  color: var(--sub);
  font-size: 14px;
}

/* =========================
   Hero banner (初始大图)
========================= */
.hero-banner {
  width: 100%;
  height: 360px;
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  margin-top: 12px;
  margin-bottom: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  background-image: url("https://images.pexels.com/photos/259588/pexels-photo-259588.jpeg");
}

/* =========================
   Results list + cards
========================= */
.results {
  padding: 16px 18px 20px;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 16px;
}

/* 卡片 */
.home-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  border: 1px solid #e5e7eb;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.home-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}

.home-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.home-body {
  padding: 10px 12px 12px;
}

.home-price {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

.home-addr {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.home-meta {
  font-size: 13px;
  color: #6b7280;
}

.muted {
  color: var(--sub);
  font-size: 14px;
  text-align: center;
  padding: 32px 0;
}

/* =========================
   Map
========================= */
#mapPanel {
  padding: 5px;
  display: none; /* 默认不展示地图 */
}

/* 进入地图模式时：隐藏左侧 section，只保留 mapPanel */
#mainGrid.map-open > section {
  display: none;
}

/* 地图模式下显示 mapPanel */
#mainGrid.map-open #mapPanel {
  display: block;
}

/* 地图基础样式 */
.mapBox {
  height: 520px;
  width: 100%;
  border-radius: 18px;
  background: repeating-linear-gradient(
    45deg,
    #f3f4f6,
    #f3f4f6 12px,
    #eef2f7 12px,
    #eef2f7 24px
  );
  border: 1px solid var(--line);
}

/* 地图全屏铺满视口（减掉顶部导航高度） */
#mainGrid.map-open .mapBox {
  width: 100%;
  height: calc(100vh - 120px); /* 120 可以按你导航条实际高度微调 */
  border-radius: 16px;          /* 想要完全贴边就改成 0 */
}

/* =========================
   Advanced filters
========================= */
#advWrap .card {
  margin-bottom: 8px;
}

.adv {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}

.adv .field {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.adv-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

/* =========================
   Empty / loading
========================= */
.empty {
  padding: 40px 0 24px;
  text-align: center;
  color: var(--sub);
  font-size: 14px;
}

.loading {
  padding: 24px 0;
  text-align: center;
  color: var(--sub);
  font-size: 14px;
}

/* =========================
   Modal
========================= */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 300;
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: 90%;
  max-width: 900px;
  background: white;
  padding: 20px;
  border-radius: 18px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 8px;
  font-size: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
}

/* =========================
   Responsive
========================= */
@media (max-width: 1100px) {
  /* 地图模式在中屏依然是单列 */
  #mainGrid.map-open {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .topwrap {
    grid-template-columns: 1fr;
    row-gap: 12px;
  }

  .searchbar {
    grid-template-columns: 1fr;
  }

  #mainGrid,
  #mainGrid.map-open {
    grid-template-columns: 1fr;
  }

  /* 小屏时地图高度保持全屏效果 */
  #mainGrid.map-open .mapBox {
    height: calc(100vh - 120px);
  }

  #mapPanel {
    height: auto;
    min-height: 0;
  }

  #map {
    width: 100%;
    height: 100%;
  }

  .result-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .result-list {
    grid-template-columns: 1fr;
  }
  .hero-banner {
    height: 260px;
  }
  .adv {
    grid-template-columns: 1fr;
  }
}
