/* ============================================================
   小区楼栋地图 - 全局样式（移动端优先）
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --main: #ff6b35;          /* 主色：骑手橙 */
  --main-dark: #e8531c;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --text2: #6b7280;
  --line: #e5e7eb;
  --danger: #e5484d;
  --ok: #16a34a;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.06);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 15px; }
a { text-decoration: none; color: inherit; }

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--main);
  color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.topbar .title { font-size: 17px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12px; opacity: .9; }

.back-btn {
  color: #fff; font-size: 22px; line-height: 1; padding: 2px 6px;
  border: 1px solid rgba(255,255,255,.5); border-radius: 8px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; flex: none;
}

/* ---------- 搜索 ---------- */
.search-wrap { padding: 12px 14px 4px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 10px; padding: 8px 12px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.search-box input { flex: 1; border: none; outline: none; background: transparent; }
.search-box .icon { color: var(--text2); font-size: 16px; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
  border: 1px solid var(--line);
}

/* ---------- 小区列表 ---------- */
.community-list { padding: 10px 14px 90px; display: flex; flex-direction: column; gap: 10px; }
.community-item {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 14px;
  display: flex; align-items: center; gap: 12px;
}
.community-item .avatar {
  width: 44px; height: 44px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #ff9a5a, var(--main));
  color: #fff; font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.community-item .info { flex: 1; min-width: 0; }
.community-item .name { font-size: 16px; font-weight: 600; }
.community-item .addr { font-size: 12px; color: var(--text2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.community-item .meta { font-size: 12px; color: var(--text2); margin-top: 2px; }
.community-item .enter {
  background: var(--main); color: #fff; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; flex: none;
}
.empty { text-align: center; color: var(--text2); padding: 40px 20px; font-size: 14px; }

/* ---------- 地图视图 ---------- */
.map-screen { position: fixed; inset: 0; z-index: 40; display: none; flex-direction: column; background: var(--bg); }
.map-screen.show { display: flex; }
.map-screen .topbar { flex: none; }
#viewer-map { flex: 1; width: 100%; }
.building-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  max-height: 42%; display: flex; flex-direction: column;
}
.building-bar .bar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; }
.building-bar .bar-title { font-size: 15px; font-weight: 700; }
.building-bar .bar-count { font-size: 12px; color: var(--text2); }
.building-bar .bar-list { overflow-y: auto; padding: 4px 10px 12px; }
.building-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; margin: 4px;
  background: #fafafa;
}
.building-chip.active { background: var(--main); color: #fff; border-color: var(--main); }

/* 地图上的栋号标签 */
.b-label {
  background: var(--main); color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.b-label.other { background: #4b5563; }

/* 信息窗 */
.info-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.info-row { font-size: 13px; color: var(--text2); margin: 3px 0; }
.info-row b { color: var(--text); }
.info-note {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0;
  white-space: pre-wrap; line-height: 1.5;
}
.nav-btn {
  display: block; width: 100%; text-align: center;
  background: var(--main); color: #fff; font-size: 14px; font-weight: 700;
  padding: 10px; border-radius: 8px; margin-top: 8px;
}

/* ---------- 管理端 ---------- */
.admin-body { padding-bottom: 80px; }
.tabs {
  position: sticky; top: 57px; z-index: 40;
  display: flex; background: #fff; border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1; padding: 12px 0; font-size: 15px; font-weight: 600; color: var(--text2);
  border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--main); border-bottom-color: var(--main); }
.page { display: none; padding: 12px 14px; }
.page.show { display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600;
}
.btn-primary { background: var(--main); color: #fff; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-map { width: 100%; height: 46vh; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 5px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none;
  background: #fff;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: var(--main); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.hint { font-size: 12px; color: var(--text2); margin: 6px 0; line-height: 1.6; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 480px; max-height: 92vh;
  border-radius: 16px 16px 0 0; padding: 16px; overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 12px; }
.modal .close-x { float: right; font-size: 20px; color: var(--text2); padding: 4px; }
.picker-map { width: 100%; height: 240px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 10px; }
.search-result { border: 1px solid var(--line); border-radius: 8px; max-height: 160px; overflow-y: auto; margin-bottom: 10px; }
.search-result div { padding: 9px 12px; font-size: 13px; border-bottom: 1px solid var(--line); }
.search-result div:last-child { border-bottom: none; }
.search-result div.active { background: #fff7ed; }

.building-form {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 70;
  background: #fff; border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  padding: 12px; display: none; border: 1px solid var(--line);
}
.building-form.show { display: block; }

.admin-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.admin-row {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.admin-row .nm { flex: 1; font-weight: 600; }
.admin-row .sub2 { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* 登录 */
.login-wrap { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 24px; border: 1px solid var(--line); }
.login-card h2 { text-align: center; margin-bottom: 18px; font-size: 18px; }
.msg { font-size: 13px; color: var(--danger); text-align: center; margin-top: 8px; min-height: 18px; }

.badge-tag { display: inline-block; background: #eef2ff; color: #4f46e5; font-size: 12px; border-radius: 6px; padding: 2px 8px; }

/* ---------- 我的位置按钮 ---------- */
.locate-btn {
  position: absolute; left: 12px; bottom: 44%; z-index: 65;
  background: rgba(255,255,255,.95); color: #1f2329;
  border: 1px solid var(--line); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  white-space: nowrap;
}
.locate-btn.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

/* ---------- 指南针 ---------- */
.compass {
  position: absolute; top: 74px; right: 12px; z-index: 65;
  width: 66px; height: 66px; border-radius: 50%;
  background: rgba(255,255,255,.94); border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0,0,0,.16);
  cursor: pointer; user-select: none;
}
.compass .c-n { position: absolute; top: 3px; left: 50%; transform: translateX(-50%); color: #e5484d; font-size: 11px; font-weight: 700; }
.compass .c-e { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); color: #6b7280; font-size: 10px; }
.compass .c-s { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); color: #6b7280; font-size: 10px; }
.compass .c-w { position: absolute; top: 50%; left: 5px; transform: translateY(-50%); color: #6b7280; font-size: 10px; }
.compass-arrow {
  position: absolute; top: 26px; left: 50%; margin-left: -9px;
  width: 0; height: 0;
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 16px solid var(--main);
  transform-origin: 50% 100%;
  transform: translateX(0) rotate(0deg);
  transition: transform .12s linear;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.compass-deg {
  position: absolute; bottom: 7px; left: 0; right: 0; text-align: center;
  font-size: 10px; color: #374151; font-weight: 700;
}

/* ---------- 轻提示 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 130px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 8px; z-index: 999;
  opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 86%;
  text-align: center; line-height: 1.5;
}
#toast.show { opacity: 1; }
