* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: #1f2937;
}

#topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: #104da6;
  color: #fff;
}

#topbar h1 { font-size: 16px; margin: 0; }

#stats { font-size: 14px; opacity: 0.9; }

#sidebar-toggle {
  margin-left: auto;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

/* 汉堡图标仅移动断点可见;桌面只显示文字(文字留作可访问名) */
#sidebar-toggle .toggle-icon { display: none; }

#layout {
  display: flex;
  height: calc(100% - 41px);
}

#sidebar {
  width: 320px;
  flex: none;
  overflow-y: auto;
  border-right: 1px solid #e5e7eb;
  background: #fafafa;
}

#layout.sidebar-collapsed #sidebar { display: none; }

#map { flex: 1; }

/* 侧边栏筛选工具条 */
#geo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

#geo-hint { font-size: 12px; color: #6b7280; }

#geo-reset {
  padding: 2px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
}

#geo-reset:hover { background: #eff6ff; }

/* 大洲 → 国家 → 酒店三级树 */
#geo-tree details { border-bottom: 1px solid #e5e7eb; background: #fff; }

#geo-tree summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  color: #374151;
}

#geo-tree summary::-webkit-details-marker { display: none; }

.continent-group > summary {
  font-weight: 600;
  font-size: 14px;
  color: #1f2937;
}

.country-group > summary {
  padding-left: 26px;
  border-top: 1px solid #f3f4f6;
}

.geo-name { min-width: 0; overflow-wrap: anywhere; }

.geo-count {
  margin-left: auto;
  color: #6b7280;
  font-weight: 400;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.geo-toggle {
  flex: none;
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #104da6;
  cursor: pointer;
}

/* 勾掉的国家整组降透明度(marker 已隐藏),节点保留可随时勾回 */
.geo-off > summary { opacity: 0.55; }

.chip {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
}

/* 酒店列表项 */
.hotel-item {
  display: block;
  width: 100%;
  padding: 6px 12px 6px 44px;
  border: 0;
  background: none;
  text-align: left;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
}

.hotel-item:hover:not(:disabled) { background: #eff6ff; }

.hotel-item:disabled {
  color: #9ca3af;
  cursor: default;
}

.hotel-item small { display: block; color: #d1a72c; }

/* marker 圆点 */
.hotel-marker span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* 品牌图例(即筛选器),浮在地图右上角 */
#legend {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  max-width: 250px;
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.legend-title {
  padding: 2px 6px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 6px;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: left;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
}

.legend-item:hover { background: #eff6ff; }

.legend-name { min-width: 0; overflow-wrap: anywhere; }

.legend-count {
  margin-left: auto;
  padding-left: 8px;
  color: #6b7280;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* 隐藏的品牌:置灰并划线,与 aria-pressed 同步 */
.legend-item[aria-pressed="false"] { opacity: 0.45; }
.legend-item[aria-pressed="false"] .legend-name { text-decoration: line-through; }

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

.popup-name { font-size: 14px; }

.popup-brand .chip { display: inline-block; vertical-align: middle; margin-right: 4px; }

.popup-link {
  display: inline-block;
  margin-top: 4px;
  color: #104da6;
}

/* ---- 移动抽屉式边栏(仅 <768px,≥768 完全沿用桌面常驻布局) ---- */

/* 桌面默认隐藏移动特有的抽屉部件(断点内才启用) */
.drawer-head, #brand-strip, #drawer-backdrop { display: none; }

@media (max-width: 767px) {
  /* 顶栏开关退化为汉堡:只显 ☰,文字保留在可访问树里 */
  #sidebar-toggle .toggle-icon { display: inline-block; font-size: 18px; line-height: 1; }
  #sidebar-toggle .toggle-label {
    position: absolute;
    width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); border: 0;
  }

  /* 抽屉头部 + 关闭按钮 */
  .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
  }
  .drawer-title { font-size: 14px; font-weight: 600; color: #1f2937; }
  #drawer-close {
    padding: 2px 6px;
    border: 0;
    background: none;
    font-size: 16px;
    color: #6b7280;
    cursor: pointer;
  }

  /* 抽屉内可折叠品牌筛选条(与地理树同滚动容器内并排可见) */
  #brand-strip { display: block; background: #fff; }
  #brand-strip summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    list-style: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
  }
  #brand-strip summary::-webkit-details-marker { display: none; }
  #brand-items { padding: 4px 0 6px; }

  /* 覆盖桌面 .sidebar-collapsed 的 display:none:移动端抽屉走 transform 而非显隐 */
  #layout.sidebar-collapsed #sidebar { display: flex; }

  /* 抽屉覆盖式:fixed 从左侧滑入、覆盖在完整尺寸地图上方 */
  #sidebar {
    position: fixed;
    top: 41px; /* 顶栏高,与 #layout 的 calc(100% - 41px) 一致 */
    left: 0;
    bottom: 0;
    width: min(88vw, 360px);
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1200;
    box-shadow: none;
  }
  #sidebar.drawer-open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.25);
  }
  /* 抽屉打开时 #map 尺寸不变 ⇒ 无需调用 map.invalidateSize()(见 spec) */

  /* 桌面浮动图例隐藏;品牌筛选改由抽屉内 #brand-strip 承担 */
  #legend { display: none; }

  /* 半透明遮罩:覆盖抽屉之外的地图区域,点击关闭抽屉 */
  #drawer-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    top: 41px; right: 0; bottom: 0; left: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 1100;
  }
}
