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

html, body, #app { height: 100%; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1f2937; }

#app { display: flex; }

/* 侧边栏 */
#sidebar {
  width: 320px;
  flex: 0 0 320px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 16px;
  overflow-y: auto;
}
#sidebar h1 { font-size: 20px; margin-bottom: 4px; }
.tip { font-size: 12px; color: #6b7280; margin-bottom: 12px; }

.panel { background: #f9fafb; border: 1px solid #eef0f3; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.panel-title { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 8px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 4px 0; cursor: pointer; }

.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-xiaoxue { background: #2563eb; }
.dot-chuzhong { background: #16a34a; }
.dot-gaozhong { background: #dc2626; }

#search { width: 100%; padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
#search-result { margin-top: 6px; max-height: 160px; overflow-y: auto; }
#search-result .item { padding: 6px 8px; font-size: 13px; border-radius: 6px; cursor: pointer; }
#search-result .item:hover { background: #e0e7ff; }

#detail { font-size: 13px; line-height: 1.7; }
#detail .row { margin: 2px 0; }
#detail b { color: #111827; }
#detail .lv { display: inline-block; padding: 1px 6px; border-radius: 4px; color: #fff; font-size: 12px; }
.lv-xiaoxue { background: #2563eb; }
.lv-chuzhong { background: #16a34a; }
.lv-gaozhong { background: #dc2626; }

.notice { font-size: 12px; color: #92400e; background: #fffbeb; border-color: #fde68a; line-height: 1.6; }
.notice code { background: #fef3c7; padding: 0 4px; border-radius: 3px; }

/* 地图 */
#map { flex: 1; height: 100%; }

/* 自定义标记 */
.school-marker { border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.school-marker span { transform: rotate(45deg); display: block; text-align: center; color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
/* 近似定位：白色虚线描边 + 半透明，提示非精确 */
.school-marker.approx { border-style: dashed; border-color: #fff; opacity: .82; box-shadow: 0 0 0 2px rgba(0,0,0,.15), 0 1px 4px rgba(0,0,0,.4); }
.school-marker.precise { border-color: #fff; }
.community-marker { background: #fff; border: 2px solid #6b7280; border-radius: 50%; }
.community-marker.approx { opacity: .5; border-style: dashed; }
.community-marker.active { border-color: #f59e0b; background: #fde68a; box-shadow: 0 0 0 3px rgba(245,158,11,.4); }

/* 精确定位/近似定位 图例 */
.legend { margin-top: 8px; font-size: 12px; color: #374151; display: flex; flex-direction: column; gap: 4px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); margin-right: 6px; vertical-align: middle; }
.legend .mk-precise { background: #2563eb; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.legend .mk-approx { background: #2563eb; border: 2px dashed #fff; opacity: .82; box-shadow: 0 0 0 2px rgba(0,0,0,.15); }

/* 徽标 */
.badge { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* 覆盖统计 */
.coverage { font-size: 13px; line-height: 1.7; color: #374151; }

/* 弹窗 */
.leaflet-popup-content { font-size: 13px; line-height: 1.6; }
.leaflet-popup-content b { font-size: 14px; }

/* ===================== 移动端菜单按钮 ===================== */
#menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1600;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2937;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
#menu-btn:hover { background: #f3f4f6; }

/* 抽屉遮罩（仅移动端） */
#drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(0, 0, 0, 0.4);
}

/* ===================== 移动端适配（<=768px） ===================== */
@media (max-width: 768px) {
  #app { display: block; }
  #map { height: 100%; width: 100%; }

  #menu-btn { display: block; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84%;
    max-width: 340px;
    z-index: 1500;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.25);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
  }
  body.drawer-open #sidebar { transform: translateX(0); }
  body.drawer-open #drawer-mask { display: block; }
  body.drawer-open { overflow: hidden; }

  /* 侧边栏内点击后反馈 */
  #sidebar .panel { padding: 12px; }

  /* 更大的点按区域 */
  .chk { min-height: 34px; font-size: 15px; }
  .chk input { width: 18px; height: 18px; }
  #search { min-height: 42px; font-size: 16px; } /* 防止 iOS 缩放 */
  #search-result .item { padding: 10px 8px; font-size: 14px; }

  /* 图层切换/搜索控件太大时允许滚动 */
  #search-result { max-height: 30vh; }

  /* 地图控件缩到角落，避免遮挡 */
  .leaflet-control-zoom { margin-top: 50px !important; }
  .leaflet-control-layers { margin-top: 100px !important; }

  /* 弹窗在小屏上尽量贴边 */
  .leaflet-popup-content { font-size: 12px; line-height: 1.5; }
  .leaflet-popup-content-wrapper, .leaflet-popup-tip { box-shadow: 0 2px 8px rgba(0,0,0,.3); }
  .leaflet-popup { max-width: 72vw; }
}
