/* ============================================================
   本地深圳律师查找器 — 移动优先响应式样式
   ============================================================ */
:root {
  --primary: #1a3c6e;        /* 法律深蓝 */
  --primary-dark: #12294c;
  --accent: #b01e2e;         /* 深红强调 */
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #22262e;
  --text-sub: #6b7280;
  --border: #e4e8ee;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(26, 60, 110, .08);
  --shadow-lg: 0 6px 24px rgba(26, 60, 110, .16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --map-h: 46dvh;            /* 地图高度；滚动时收缩到只剩 20px */
  --map-min: 20px;           /* 地图收缩后保留的高度 */
}

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

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  max-width: 780px;
  margin: 0 auto;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============ 顶栏 ============ */
.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 10;
}
.topbar-inner { display: flex; align-items: center; gap: 6px; }
.logo {
  font-size: 17px;              /* 与标题同字号同高的小图标 */
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: .5px; flex: 1; }

.searchbar { display: flex; gap: 8px; margin-top: 9px; }
.searchbar input {
  flex: 1; border: none; border-radius: 20px;
  padding: 9px 16px; font-size: 14px; background: rgba(255,255,255,.95);
  color: var(--text); outline: none;
}
.searchbar input::placeholder { color: #9aa3b2; }
.searchbar button {
  border: none; border-radius: 20px; padding: 0 18px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer;
}

/* ============ 地图区 ============ */
#map-area {
  position: relative;         /* 随页面正常滚动（不再 sticky 收缩） */
  z-index: 5;                 /* 独立 stacking context，压制腾讯地图内部图层 */
  height: var(--map-h);
  min-height: 260px;
  background: #dde4ec;
  border-bottom: 3px solid var(--primary);
}
#map-container { width: 100%; height: 100%; pointer-events: auto; }

#map-key-tip {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, .95); color: var(--accent);
  padding: 8px 14px; border-radius: 18px; font-size: 12px;
  box-shadow: var(--shadow-lg); z-index: 1100; max-width: 90%; text-align: center;
  border: 1px solid #f3cdd2;
  pointer-events: auto;
}

#map-controls {
  position: absolute; left: 10px; top: 10px;      /* 左侧：避开腾讯地图右上角内置控件 */
  display: flex; flex-direction: column; gap: 8px; z-index: 1100;
  pointer-events: auto;
}
#map-controls button {
  width: 40px; height: 40px; border-radius: 10px; border: none;
  background: #fff; color: var(--primary); font-size: 18px;
  box-shadow: var(--shadow-lg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#map-controls button:active { background: #eef2f8; }

#map-summary {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px;  /* 居中：避开左下角比例尺 */
  background: rgba(255,255,255,.96); color: var(--primary);
  padding: 7px 14px; border-radius: 18px; font-size: 12.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 1100;
  display: flex; align-items: center; gap: 3px;
  white-space: nowrap;
  pointer-events: auto;
}
#map-summary span { color: var(--accent); font-size: 15px; }
#stat-scope { color: var(--text-sub) !important; font-size: 11.5px !important; font-weight: 400; }

/* ============ 地图律所悬浮信息卡 ============ */
#map-popup {
  position: absolute; left: 12px; right: 12px; bottom: 44px;   /* 悬浮在地图下半部，避开底部统计条 */
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  z-index: 1200; overflow: hidden; animation: mp-in .22s ease;
}
@keyframes mp-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.mp-head { display: flex; align-items: center; gap: 8px; padding: 14px 14px 0; }
.mp-name { font-size: 16px; font-weight: 600; color: var(--primary); flex: 1; }
.mp-body { padding: 10px 14px 12px; }
.mp-row { display: flex; font-size: 12.5px; padding: 3px 0; color: var(--text); }
.mp-k { width: 44px; color: var(--text-sub); flex-shrink: 0; }
.mp-v { flex: 1; word-break: break-all; }
.mp-v a { color: var(--primary); text-decoration: none; }
/* 底部两栏：律所详情 | 关闭 */
.mp-foot-row { display: flex; border-top: 1px solid var(--border); }
.mp-foot-half {
  flex: 1; padding: 12px; text-align: center;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.mp-foot-half + .mp-foot-half { border-left: 1px solid var(--border); }
.mp-foot-half:active { background: #eef2f8; }
#mp-detail-btn { background: var(--primary); color: #fff; letter-spacing: 1px; }
.mp-foot-close { background: #eef2f8; color: var(--text-sub); }

/* ============ 列表区 ============ */
#list-area {
  padding: 10px 12px calc(var(--safe-bottom) + 12px);   /* 顶部 10px 与地图间隔 */
}

/* ============ 排序栏 ============ */
#sort-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;   /* 滚动列表时保持可见，便于随时重排 */
}
.sort-label { font-size: 13px; color: var(--text-sub); flex-shrink: 0; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 6px 14px; border: 1px solid #c9d3e0; border-radius: 16px;
  background: #f5f7fb; color: var(--primary); font-size: 13px;
  cursor: pointer; transition: all .15s;
}
.sort-btn:active { background: #e9eef5; }
.sort-btn.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff; font-weight: 600;
}
.sort-arrow { font-size: 10px; line-height: 1; margin-left: 1px; }

#list-header {
  padding: 12px 2px 8px; font-size: 14px; font-weight: 600; color: var(--text-sub);
  display: flex; justify-content: space-between; align-items: center;
}

#lawfirm-list { list-style: none; }
#lawfirm-list li {
  background: var(--card); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow); cursor: pointer;
  border-left: 4px solid transparent;
  transition: transform .1s;
}
#lawfirm-list li:active { transform: scale(.985); background: #fafbfd; }
#lawfirm-list li .lf-name { font-size: 15.5px; font-weight: 600; color: var(--primary); }
#lawfirm-list li .lf-meta { margin-top: 6px; font-size: 12.5px; color: var(--text-sub); display: flex; flex-wrap: wrap; gap: 4px 10px; }
#lawfirm-list li .lf-meta b { color: var(--accent); font-weight: 600; }
#lawfirm-list li .lf-meta .tag {
  background: #eef2f8; color: var(--primary); border-radius: 4px;
  padding: 1px 7px; font-size: 11.5px;
}
/* 列表地址行：去省/市后单行显示，超出省略 */
#lawfirm-list li .lf-addr {
  margin-top: 6px; font-size: 12.5px; color: var(--text-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#list-empty { text-align: center; color: var(--text-sub); padding: 40px 20px; }
#list-empty .hint { font-size: 12.5px; margin-top: 8px; color: #9aa3b2; }
#list-loading { text-align: center; color: var(--text-sub); padding: 30px; }

/* ============ 页脚 ============ */
footer {
  background: transparent;        /* 无框架无悬浮，自然沉底 */
  color: #a0a8b5;
  font-size: 11px;
  text-align: center;
  padding: 4px 14px calc(var(--safe-bottom) + 12px);
  line-height: 1.6;
}
footer p + p { margin-top: 0; }
footer .beian a { color: inherit; text-decoration: none; }
footer .beian { margin-top: 3px; }

/* ============ Toast ============ */
#toast {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%);
  background: rgba(26,38,60,.92); color: #fff;
  padding: 10px 20px; border-radius: 22px; font-size: 13px;
  z-index: 1100; box-shadow: var(--shadow-lg); max-width: 86%;
  text-align: center; transition: opacity .2s;
}

.hidden { display: none !important; }

/* ============ 悬浮绿色电话按钮 ============ */
#float-contact {
  position: fixed; right: 14px; bottom: calc(24px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(22, 163, 74, .45);
  cursor: pointer; z-index: 1200;
  animation: floatPulse 2.4s ease-in-out infinite;
}
#float-contact svg { width: 26px; height: 26px; }
#float-contact:active { transform: scale(.94); }
@keyframes floatPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(22, 163, 74, .45); }
  50% { box-shadow: 0 6px 28px rgba(22, 163, 74, .75); }
}

/* ============ 联系遮罩 + 菜单 ============ */
#contact-overlay {
  position: fixed; inset: 0; z-index: 1150;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; backdrop-filter: blur(2px);
  animation: fadeIn .2s ease;
}
/* 首页遮罩：弹出菜单后不透明度在原 0.55 基础上增加 20%（相对 → 0.66） */
#contact-overlay.home-overlay {
  background: rgba(15, 23, 42, .66);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.contact-menu {
  width: 100%; max-width: 340px; background: var(--card);
  border-radius: 18px; padding: 20px 16px 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.contact-menu .cm-title {
  font-size: 16px; font-weight: 600; color: var(--text);
  text-align: center; margin-bottom: 4px;
}
.contact-menu .cm-subtitle {
  font-size: 13px; color: var(--text-sub);
  text-align: center; margin: 0 0 16px; line-height: 1.5;
}
.cm-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 50px; border-radius: 12px;
  font-size: 15px; font-weight: 500; text-decoration: none;
  margin-bottom: 10px; transition: opacity .15s;
}
.cm-btn:active { opacity: .8; }
.cm-call { background: #4169e1; color: #fff; border: 1px solid #3a5fd0; }         /* 宝蓝 */
.cm-wechat { background: #07c160; color: #fff; border: 1px solid #06ad56; }        /* 微信绿 */
.cm-close {
  width: 100%; height: 44px; border: none; border-radius: 12px;
  background: #f1f5f9; color: var(--text-sub); font-size: 14px; cursor: pointer;
}
.cm-msg {
  text-align: center; font-size: 14.5px; color: var(--text);
  line-height: 1.8; padding: 2px 0 16px;
}
.cm-msg b { color: var(--accent); font-size: 16px; }

/* ============ 全屏地图 ============ */
#map-area.fullscreen {
  position: fixed; inset: 0; width: 100%; height: 100dvh;
  z-index: 100; border: none;
}
#map-area.fullscreen + #list-area { display: none; }

/* ============ 桌面端加宽 ============ */
@media (min-width: 600px) {
  :root { --map-h: 50dvh; }
}

/* 隐藏腾讯地图原生控件（右上角 + - 缩放/指南针），用我们左侧自定义按钮 */
#map-container .tmap-zoom-control,
#map-container .tmap-compass-ctrl,
#map-container [class*="tmap-zoom"],
#map-container [class*="tmap-compass"] { display: none !important; }

/* ============ 分页 ============ */
#pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 6px; padding: 14px 0 8px; flex-wrap: wrap;
}
.pg-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--primary);
  font-size: 13px; cursor: pointer;
}
.pg-btn:active { background: #eef2f8; }
.pg-btn:disabled { color: #c0c8d4; border-color: #eef0f4; }
.pg-cur {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.pg-prev, .pg-next { font-size: 13px; }
.pg-dots { color: var(--text-sub); padding: 0 2px; font-size: 13px; }

/* 搜索结果下拉 */
#search-drop {
  position: absolute; left: 14px; right: 14px; top: calc(var(--safe-top) + 96px);
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 50; max-height: 60dvh; overflow-y: auto;
}
#search-drop .sd-title { padding: 8px 12px; font-size: 12px; color: var(--text-sub); background: #f4f6f9; }
#search-drop a {
  display: block; padding: 11px 14px; color: var(--text); text-decoration: none;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
#search-drop a small { color: var(--text-sub); margin-left: 8px; }
#search-drop a:active { background: #f0f3f8; }
