/* ============================================================
   北京公园打卡地图 —— 样式（含春夏秋冬四季主题）
   ============================================================ */

/* —— 主题变量 —— */
:root {
  --panel: rgba(255, 255, 255, 0.80);
  --panel-solid: rgba(255, 255, 255, 0.88);
  --ink: #1f2329;
  --muted: #8a909a;
  --line: #e8eaed;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 18px rgba(0, 0, 0, 0.05);
}
/* 四季主题：实拍俯视底图 + 半透明柔和罩（保证文字可读），UI 配色随季节变化 */
body[data-theme="spring"] {
  --accent: #e8728c; --accent-soft: rgba(232, 114, 140, 0.20); --accent-deep: #c64f6b;
  --bg-base: #fdeef2; --bg-tint: rgba(255, 244, 248, 0.34); --bg-image: url(../assets/bg/spring.jpg);
}
body[data-theme="summer"] {
  --accent: #2f9e5e; --accent-soft: rgba(47, 158, 94, 0.20); --accent-deep: #1f7a45;
  --bg-base: #eef7ee; --bg-tint: rgba(243, 251, 243, 0.34); --bg-image: url(../assets/bg/summer.jpg);
}
body[data-theme="autumn"] {
  --accent: #d9772b; --accent-soft: rgba(217, 119, 43, 0.20); --accent-deep: #b35e16;
  --bg-base: #fbf2e6; --bg-tint: rgba(250, 242, 230, 0.38); --bg-image: url(../assets/bg/autumn.jpg);
}
body[data-theme="winter"] {
  --accent: #3b7fb5; --accent-soft: rgba(59, 127, 181, 0.20); --accent-deep: #2b6193;
  --bg-base: #eef4f8; --bg-tint: rgba(243, 249, 252, 0.05); --bg-image: url(../assets/bg/winter.jpg);
}
/* 经典白：初始纯白背景，无底图 */
body[data-theme="white"] {
  --accent: #4a90d9; --accent-soft: rgba(74, 144, 217, 0.18); --accent-deep: #2f6fb0;
  --bg-base: #f4f6f8; --bg-tint: rgba(255, 255, 255, 0.0); --bg-image: none;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
}
body {
  background-color: var(--bg-base);
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.4s ease;
}
/* 季节底图上的半透明罩，保证文字可读 */
body::before {
  content: "";
  position: fixed; inset: 0;
  background: var(--bg-tint);
  z-index: 0;
  pointer-events: none;
  transition: background 0.4s ease;
}

/* —— 顶部应用栏 —— */
.appbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.appbar-title {
  font-size: 17px; font-weight: 700; white-space: nowrap; letter-spacing: 0.4px;
}
.search-box { position: relative; flex: 1; max-width: 560px; }
.search-box input {
  width: 100%; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 14px; outline: none; background: #fff;
  transition: border-color 0.15s ease;
}
.search-box input:focus { border-color: var(--accent); }
.search-results {
  list-style: none; margin: 6px 0 0; padding: 0;
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-solid); box-shadow: var(--shadow);
  position: absolute; left: 0; right: 0; z-index: 30;
}
.search-results li {
  padding: 9px 14px; font-size: 14px; cursor: pointer;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: #fafbfc; }
.search-results li .s-cat { font-size: 11px; color: var(--muted); }
.search-results li .s-lit { color: var(--accent); font-size: 11px; font-weight: 700; }
.search-results .s-empty { padding: 10px 14px; color: var(--muted); font-size: 12px; }

.icon-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 18px; line-height: 1; cursor: pointer; flex: none;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* —— 主布局：PC 左地图 + 右列表 —— */
.layout { position: relative; z-index: 1; flex: 1; display: flex; min-height: 0; }
.map-wrap { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#map { width: 100%; height: 100%; }

.legend {
  position: absolute; left: 14px; bottom: 14px; z-index: 500;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 12px; color: #5a6068;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-hint { color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.demo-unlit { background: #cfd8dc; border: 2px solid #90a4ae; }
.demo-lit { background: var(--accent); border: 2px solid var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 底图淡化：弱化高德注记，突出公园点位 */
.leaflet-container .leaflet-tile-pane {
  filter: brightness(1.1) contrast(0.82) saturate(0.7);
  opacity: 0.72;
}

/* 标记 */
.park-marker {
  background: transparent; border: none; overflow: visible;
  display: flex; align-items: center; justify-content: center; z-index: 700;
}
.park-marker .pin {
  width: 17px; height: 17px; border-radius: 50%;
  background: #d3dade; border: 2px solid #9aa7b1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  transition: all 0.2s ease;
}
.park-marker:hover .pin { transform: scale(1.15); }
.park-marker.lit .pin {
  width: 20px; height: 20px; background: var(--accent); border-color: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4), 0 0 0 3px var(--accent-soft), 0 0 14px var(--accent);
}
.park-marker .mlabel {
  position: absolute; left: 26px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; font-size: 11.5px; line-height: 18px; font-weight: 600;
  color: #262b31; background: rgba(255, 255, 255, 0.97);
  border: 1px solid #c4cad2; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  padding: 1px 6px; border-radius: 5px; pointer-events: none;
}
.park-marker.lit .mlabel { color: #fff; background: var(--accent); border-color: var(--accent-deep); box-shadow: 0 1px 4px var(--accent-deep); }

/* —— 侧栏 / 列表页通用 —— */
.sidebar {
  width: 340px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px; overflow: hidden;
}
.stats {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.stats-num { font-size: 24px; font-weight: 700; display: flex; align-items: baseline; gap: 4px; }
.stats-num .sep { color: var(--muted); font-weight: 400; }
.stats-num .unit { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.progress { margin-top: 10px; height: 8px; background: #eceef1; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #ff9a76, var(--accent)); border-radius: 99px; transition: width 0.4s ease; }
.stats-pct { margin-top: 6px; font-size: 13px; color: var(--muted); }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #5a6068; margin-bottom: 12px; cursor: pointer; user-select: none; }
.toggle input { width: 15px; height: 15px; accent-color: var(--accent); }

/* 日历热力图（默认隐藏，移动端显示） */
.calendar { display: none; margin-bottom: 12px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 14px; font-weight: 600; }
.cal-nav { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; font-size: 16px; color: var(--ink); }
.cal-nav:hover { border-color: var(--accent); color: var(--accent); }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 7px; background: #eef1f4;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #8a909a;
}
.cal-cell.empty { background: transparent; }
.cal-cell.visited { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; border: 1px solid var(--accent); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }

.list-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  flex: 1; background: #f1f3f5; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 6px; font-size: 13px; font-weight: 600; color: #5a6068; cursor: pointer; transition: all 0.15s ease;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 10px; background: rgba(0, 0, 0, 0.12); font-size: 12px; }
.tab:not(.active) .tab-badge { background: #e3e6ea; color: #5a6068; }

.list-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.filter-select { flex: 1; padding: 7px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #333; }
.filter-check { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #5a6068; white-space: nowrap; cursor: pointer; }

#allPanel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.park-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.park-list .empty { color: var(--muted); font-size: 13px; padding: 12px 4px; line-height: 1.6; }
.list-group-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 12px 2px 6px; letter-spacing: 0.5px; }
.aitem {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: space-between; transition: all 0.15s ease; background: var(--panel-solid);
}
.aitem:hover { border-color: #cfd3d9; background: #fafbfc; }
.aitem .aname { font-size: 14px; font-weight: 500; }
.aitem.lit .aname { font-weight: 600; }
.aitem .abadge { font-size: 12px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.aitem .abadge.none { color: #b8c0c8; font-weight: 400; }

.vitem { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: all 0.15s ease; background: var(--panel-solid); }
.vitem:hover { border-color: #cfd3d9; background: #fafbfc; }
.vitem .vname { font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; }
.vitem .vmeta { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.vitem .vcount { color: var(--accent); font-weight: 600; }

/* Popup */
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.7; }
.popup-date-row { margin: 6px 0; display: flex; align-items: center; gap: 6px; }
.popup-date-row input[type="date"] { font-size: 12px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 5px; }
.visit-list { margin: 8px 0; max-height: 180px; overflow-y: auto; }
.visit-empty { color: #9aa3ab; font-size: 12px; padding: 2px 0; }
.visit-item { display: flex; align-items: center; justify-content: space-between; background: var(--accent-soft); border-radius: 5px; padding: 3px 8px; margin: 4px 0; font-size: 13px; }
.visit-date { color: var(--accent-deep); font-weight: 600; }
.visit-del { background: none; border: none; color: var(--accent-deep); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; }
.visit-del:hover { opacity: 0.6; }
.popup-add { margin-top: 4px; display: inline-block; background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.popup-clear { margin-top: 8px; display: inline-block; color: var(--accent); cursor: pointer; font-size: 12px; border: 1px solid var(--accent-soft); border-radius: 6px; padding: 3px 10px; }
.popup-clear:hover { background: var(--accent-soft); }
.popup-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.popup-row { color: #5a6068; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 1200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* —— 底部导航（仅移动端显示） —— */
.mobile-tabs { display: none; }

/* —— 弹窗通用 —— */
.modal { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.42); }
.modal-card { position: relative; z-index: 1; background: #fff; border-radius: 16px; width: 100%; max-width: 380px; max-height: 86vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal-body { padding: 16px; }
.modal-body h3 { font-size: 13px; color: var(--muted); margin: 16px 0 8px; }
.modal-body h3:first-child { margin-top: 0; }

.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px; cursor: pointer; font-size: 13px; color: var(--ink); }
.theme-chip.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.12); }
.sw-spring { background: #e8728c; } .sw-summer { background: #2f9e5e; } .sw-autumn { background: #d9772b; } .sw-winter { background: #3b7fb5; } .sw-white { background: #ffffff; border: 1px solid #c6ccd4; }

.account-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.account-name { font-weight: 600; font-size: 14px; }
.account-sub { font-size: 12px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 9px; font-size: 13px; cursor: pointer; transition: all 0.15s ease; }
.btn:hover { border-color: #cfd3d9; }
.btn.ghost { color: #5a6068; }
.btn.danger { color: #d33; border-color: #f0c4c4; }
.btn.danger:hover { background: #fdeaea; }
.btn.primary { background: var(--accent); color: #fff; border: none; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.block { width: 100%; padding: 11px; font-size: 14px; }
.data-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* 登录 / 注册 */
.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.auth-tab { flex: 1; padding: 8px; border: 1px solid var(--line); background: #f1f3f5; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; color: #5a6068; }
.auth-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.auth-input { width: 100%; padding: 11px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; box-sizing: border-box; outline: none; }
.auth-input:focus { border-color: var(--accent); }
.auth-error { color: #d33; font-size: 12px; min-height: 16px; margin: 4px 0; }
.auth-hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ============================================================
   移动端（≤720px）：App 化布局
   ============================================================ */
@media (max-width: 720px) {
  .appbar {
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    gap: 8px;
  }
  .appbar-title { font-size: 15px; }
  .icon-btn { width: 34px; height: 34px; font-size: 17px; }

  /* 布局：地图页 / 列表页 二选一，靠 body.show-list 切换 */
  .layout { flex-direction: column; }
  .map-wrap { flex: 1; display: flex; min-height: 0; }
  .sidebar {
    display: none;
    width: 100%; border-left: none; border-top: 1px solid var(--line);
    flex: 1; min-height: 0; overflow: hidden; padding: 12px;
  }
  body.show-list .map-wrap { display: none; }
  body.show-list .sidebar { display: flex; }

  /* 日历在移动端显示 */
  .calendar { display: block; }

  .stats { margin-bottom: 10px; padding: 10px 12px; }
  .stats-num { font-size: 22px; }
  .toggle { margin-bottom: 10px; }
  .list-tabs { margin-bottom: 10px; }
  .list-filter { margin-bottom: 8px; }

  /* 图例上移，避免被底部 Tab 遮挡 */
  .legend { bottom: calc(64px + env(safe-area-inset-bottom)); font-size: 11px; padding: 6px 10px; }

  /* 底部导航：在文档流中，始终位于底部 */
  .mobile-tabs {
    display: flex; position: relative; z-index: 3;
    background: var(--panel); border-top: 1px solid var(--line);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs .mtab {
    flex: 1; border: none; background: none; padding: 11px 0 10px;
    font-size: 13px; font-weight: 600; color: #5a6068; cursor: pointer;
  }
  .mobile-tabs .mtab.active { color: var(--accent); }
  .mobile-tabs .mtab.active::after {
    content: ""; display: block; width: 26px; height: 3px; margin: 4px auto 0;
    background: var(--accent); border-radius: 2px;
  }

  .park-list { padding-bottom: 10px; }
}
