/* ================================================================
   iOS 虚拟定位 - 前端样式
   移动优先设计，兼容 iOS Safari
   ================================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #007AFF;
  --danger: #FF3B30;
  --success: #34C759;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --text2: #8E8E93;
  --border: #E5E5EA;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ─── 顶部导航 ─── */
.top-bar {
  background: var(--card);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  z-index: 1000;
  flex-shrink: 0;
}
.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.subtitle {
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

/* ─── 地图 ─── */
#map {
  flex: 1;
  min-height: 300px;
  z-index: 1;
}

/* ─── 搜索栏 ─── */
.search-bar {
  position: absolute;
  top: 80px;
  left: 12px;
  right: 12px;
  z-index: 900;
  max-width: 500px;
  margin: 0 auto;
}
.search-input-wrapper {
  display: flex;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-input-wrapper input {
  flex: 1;
  border: none;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  background: transparent;
}
.search-input-wrapper button {
  border: none;
  background: var(--primary);
  color: white;
  padding: 0 18px;
  font-size: 16px;
  cursor: pointer;
}
.search-results {
  background: var(--card);
  border-radius: var(--radius);
  margin-top: 6px;
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
.search-results .result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}
.search-results .result-item:last-child { border-bottom: none; }
.search-results .result-item:hover, .result-item:active { background: #F0F0F5; }

/* ─── 底部控制面板 ─── */
.control-panel {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px 20px;
  flex-shrink: 0;
  overflow-y: auto;
  max-height: 55vh;
  z-index: 100;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text2);
  flex-shrink: 0;
}
.status-dot.active { background: var(--success); box-shadow: 0 0 6px var(--success); }
#statusText { font-weight: 600; font-size: 14px; }
.status-hint { font-size: 11px; color: var(--text2); margin-left: auto; }

/* 坐标行 */
.coord-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.coord-item {
  flex: 1;
}
.coord-item.coord-small { flex: 0.5; }
.coord-item label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}
.coord-item input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'SF Mono', 'Menlo', monospace;
  background: #FAFAFA;
}

/* 坐标系标签 */
.coord-sys-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.sys-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text2);
}
.sys-tag.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.sys-note { font-size: 10px; color: var(--text2); }

/* 按钮 */
.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.btn {
  flex: 1;
  padding: 12px 10px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

/* 配置区 */
.config-section {
  background: #F9F9FC;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.section-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.config-btns {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.config-steps {
  font-size: 12px;
  color: var(--text2);
}
.config-steps .step {
  padding: 3px 0;
}
.config-steps .step b { color: var(--text); }

/* 提示 */
.tips-box {
  background: #FFF8E1;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 11px;
  color: #8D6E00;
}
.tip-title { font-weight: 700; margin-bottom: 4px; }
.tips-box ul { padding-left: 16px; }
.tips-box li { margin: 3px 0; }

/* 地图图层切换 */
.map-layer-switch {
  position: absolute;
  left: 12px;
  top: 140px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.layer-btn {
  padding: 8px 10px;
  font-size: 11px;
  border: none;
  border-radius: 8px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-weight: 500;
}
.layer-btn.active { background: var(--primary); color: white; }

/* 收藏面板 - 浮窗，默认折叠不挡地图 */
.fav-panel {
  position: absolute;
  right: 12px;
  top: 132px;
  z-index: 900;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 170px;
  max-height: 280px;
  overflow: hidden;
}
.fav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.fav-header button {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
}
.fav-list { overflow-y: auto; max-height: 260px; }
.fav-item {
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.fav-item:active { background: #F0F0F5; }
.fav-item .fav-coords { color: var(--text2); font-size: 10px; }
.fav-item .fav-del { float: right; color: var(--danger); cursor: pointer; }

/* 标记弹出窗口自定义 */
.custom-popup .leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  font-size: 13px;
}
.custom-popup .leaflet-popup-content {
  margin: 10px 14px;
}

/* 响应式 */
@media (max-width: 480px) {
  .coord-row { flex-wrap: wrap; }
  .coord-item.coord-small { flex: 0.4; }
  .config-btns { flex-direction: column; }
  .btn-row { flex-direction: column; }
  .fav-panel { width: 150px; font-size: 11px; }
}
