/* 色板喺 theme.css，呢度只寫版面。地圖頁（首頁）專用 */
#map-page { position: relative; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
#map-wrap { position: relative; width: 100%; height: 100%; }
#map { width: 100%; height: 100%; }

.floating-btn {
  position: absolute; top: 10px; right: 10px; z-index: 1000;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 4px rgba(58,46,32,.20);
}

/* 搜尋：放左上角。Leaflet 縮放掣改咗擺去右下角（見 map.js），呢度先淨得低。 */
.search-box {
  position: absolute; top: 10px; left: 10px; z-index: 1000;
  width: min(230px, 58vw);
}
.search-input {
  width: 100%; box-sizing: border-box;
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 34px 9px 12px; font-size: 14px;
  box-shadow: 0 1px 4px rgba(58,46,32,.20);
}
.search-input::placeholder { color: var(--muted); }
.search-clear {
  position: absolute; top: 5px; right: 5px; z-index: 1;
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.search-clear:active { background: var(--card); }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  max-height: min(360px, 60vh); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 2px 12px rgba(58,46,32,.22);
}
.search-result-row {
  display: flex; align-items: baseline; gap: 8px; padding: 9px 12px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-row:active { background: var(--card); }
.search-result-code { font-size: 11px; font-weight: 800; color: var(--muted); flex: 0 0 auto; }
.search-result-main { flex: 1 1 auto; min-width: 0; }
.search-result-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-addr { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 12px; font-size: 13px; color: var(--muted); }

.control-panel {
  position: absolute; top: 54px; right: 10px; z-index: 1000;
  width: min(280px, 78vw); max-height: calc(100% - 64px); overflow-y: auto;
  background: var(--panel); border-radius: 12px; padding: 12px;
  box-shadow: 0 2px 12px rgba(58,46,32,.22);
  display: flex; flex-direction: column; gap: 12px;
}
.control-panel.collapsed { display: none; }

.control-section { }
.control-title { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }

.mode-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mode-btn {
  flex: 1 1 auto; min-width: 64px; font-size: 12px; font-weight: 700; padding: 8px 4px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
.mode-btn.active { background: var(--accent); color: var(--on-solid); border-color: var(--accent); }
.mode-note {
  font-size: 11.5px; line-height: 1.5; color: var(--muted); background: var(--card);
  border-radius: 8px; padding: 8px 10px; margin-top: 8px;
}

.street-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.street-chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer;
}
.street-chip.active { background: var(--accent); color: var(--on-solid); border-color: var(--accent); font-weight: 700; }

.select-input {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font-size: 13px;
}

.legend { display: flex; flex-direction: column; gap: 5px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(58,46,32,.35); }
.legend-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-count { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }

.control-count { font-size: 12px; color: var(--muted); text-align: right; border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- marker popup 內容 ---------- */
.leaflet-popup-content-wrapper { background: var(--card); color: var(--text); border-radius: 12px; }
.leaflet-popup-tip { background: var(--card); }
.leaflet-popup-content { margin: 12px 14px; }
.popup-card { min-width: 200px; max-width: 260px; }
.popup-code { font-size: 15px; font-weight: 800; color: var(--accent); }
.popup-street { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.popup-name { font-size: 15px; font-weight: 700; margin: 4px 0 2px; }
.popup-row { font-size: 12px; margin: 2px 0; }
.popup-tag {
  display: inline-block; background: var(--panel); border-radius: 999px; padding: 2px 8px;
  font-size: 11px; margin: 2px 4px 0 0; color: var(--text); border: 1px solid var(--line);
}
.popup-tag-community { border-color: var(--comm-sea-other); color: var(--comm-sea-other); font-weight: 700; }
.popup-photo { max-width: 100%; max-height: 120px; border-radius: 8px; margin-top: 6px; display: block; }
.popup-link {
  display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700;
  color: var(--on-solid); background: var(--accent); padding: 6px 12px; border-radius: 999px;
  text-decoration: none;
}

#toast {
  position: absolute; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  z-index: 1002; background: var(--green); color: var(--on-solid); font-size: 14px; font-weight: 700;
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 2px 10px rgba(58,46,32,.25);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
  max-width: 90%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); }

@media (max-width: 480px) {
  .control-panel { top: 54px; right: 8px; left: 8px; width: auto; max-width: none; }
}

/* ---------- 桌面：控制面板加闊、加大內距，睇落更似正式面板（維持浮動——
   如果改做唔浮動嘅固定側欄，需要 JS 呼叫 leaflet invalidateSize() 先唔會拉花地圖，
   但呢個任務唔准改 JS，所以淨係做視覺優化，行為同 375px 一致）。 ---------- */
@media (min-width: 1024px) {
  .control-panel { width: 300px; padding: 14px; gap: 14px; }
  .floating-btn { padding: 10px 16px; font-size: 14px; }
  .control-title { font-size: 12px; }
}
