/* ============================================================
   服务商查询 H5 · 微信公众号
   设计基准：iPhone 375px，浅色主题
   ============================================================ */

:root {
  --brand: #ff5b4a;
  --brand-dark: #ec4333;
  --brand-soft: #fff1ef;
  --brand-blue: #2b7fff;
  --brand-blue-dark: #1a6ae6;

  --text-1: #1a1d24;
  --text-2: #5c6472;
  --text-3: #9aa2b1;
  --line: #eef0f4;
  --bg: #f5f6f8;
  --card: #ffffff;

  --radius: 14px;
  --shadow: 0 2px 12px rgba(24, 32, 51, .06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

/* 关键：显式声明过 display 的元素（如 .city-sheet 设为 flex）会覆盖浏览器默认的
   [hidden] 隐藏规则，导致 hidden 属性失效、弹层关不掉。此处强制兜底。 */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { overscroll-behavior-y: none; }
/* 弹层打开时锁定背景滚动 */
body.is-locked { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; background: none; border: 0; outline: none; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
img { display: block; max-width: 100%; }

.page { max-width: 640px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

/* ============ 顶部 ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  padding-top: env(safe-area-inset-top, 0px);
  box-shadow: 0 1px 0 rgba(24, 32, 51, .05);
}

.header__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 8px;
}

/* 地区按钮 */
.city-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  max-width: 128px;
  height: 34px;
  padding: 0 4px 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}
.city-btn__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.city-btn__caret { width: 12px; height: 8px; flex-shrink: 0; color: var(--text-3); transition: transform .2s; }
.city-btn.is-open .city-btn__caret { transform: rotate(180deg); }

/* 搜索栏 */
.search {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  background: #f2f3f6;
  border-radius: 17px;
}
.search__icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-3); }
.search__input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  font-size: 14px;
}
.search__input::placeholder { color: var(--text-3); }
.search__clear { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-3); }
.search__clear svg { width: 18px; height: 18px; }

/* 定位条 */
.locbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 14px 10px;
}
.locbar__left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--text-2);
  font-size: 13px;
}
.locbar__pin { width: 15px; height: 15px; flex-shrink: 0; color: var(--brand); }
.locbar__text {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
  word-break: break-all;
}
.locbar__text.is-loading { color: var(--text-3); }
.locbar__text.is-fail { color: #e8892b; }

.relocate {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 13px;
}
.relocate__icon { width: 13px; height: 13px; }
.relocate:active { background: #ffe2de; }
.relocate.is-spinning .relocate__icon { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 内容区 ============ */
.content { padding: 0 12px 24px; }

.result-bar {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 14px 4px 8px;
}
.result-bar__title { font-size: 15px; font-weight: 600; }
.result-bar__count { font-size: 12px; color: var(--text-3); }

/* 所选地区无分销商提示 */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #8a6d3b;
  background: #fff8e6;
  border: 1px solid #ffe3ad;
  border-radius: 10px;
}
.notice::before {
  content: "!";
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  color: #fff;
  background: #f0a020;
  border-radius: 50%;
}

.provider-list { display: flex; flex-direction: column; gap: 10px; }

/* ============ 服务商卡片 ============ */
.card {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise .32s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card__cover {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f1f4;
}
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__badge {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, rgba(255, 91, 74, .95), rgba(255, 130, 90, .95));
  border-radius: 0 6px 0 6px;
}

.card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.card__top { display: flex; align-items: flex-start; gap: 8px; }
.card__name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__dist {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
  padding-top: 2px;
}
.card__dist.is-far { color: var(--text-3); font-weight: 500; }

.card__addr {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__tag {
  display: inline-block;
  max-width: 100%;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--brand-blue-dark);
  background: #eef4ff;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.card__actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 15px;
  text-decoration: none;
  transition: transform .12s, opacity .12s;
}
.btn:active { transform: scale(.96); opacity: .88; }
.btn svg { width: 14px; height: 14px; }

.btn--nav {
  color: #fff;
  background: linear-gradient(135deg, #4a90ff, var(--brand-blue));
  box-shadow: 0 2px 8px rgba(43, 127, 255, .28);
}
.btn--call {
  color: var(--text-1);
  background: #fff;
  border: 1px solid #e3e6ec;
}
.btn--call svg { color: var(--brand-blue); }
.btn--nav.is-ghost { background: #dfe3ea; color: #8b93a2; box-shadow: none; }

/* 骨架屏 */
.card--skeleton { animation: none; }
.sk { background: linear-gradient(90deg, #eff0f3 25%, #f7f8fa 37%, #eff0f3 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 4px; }
.sk--cover { width: 96px; height: 96px; border-radius: 10px; flex-shrink: 0; }
.sk--line { height: 13px; }
.sk--btns { height: 30px; width: 100%; margin-top: auto; border-radius: 15px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* 空状态 */
.empty { padding: 64px 20px; text-align: center; }
.empty__img { width: 108px; height: 108px; margin: 0 auto 12px; }
.empty__title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.empty__desc { margin-top: 6px; font-size: 13px; color: var(--text-3); }

.load-more { padding: 20px 0 8px; text-align: center; font-size: 12px; color: var(--text-3); }
.footer-tip { padding: 24px 0 8px; text-align: center; font-size: 12px; color: var(--text-3); }

/* ============ 遮罩 ============ */
.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(17, 21, 30, .45);
  animation: fade .22s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ 地区选择弹层（省 → 市） ============ */
.city-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px 16px 0 0;
  animation: slideUp .26s cubic-bezier(.22, .8, .3, 1) both;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }

.city-sheet__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.city-sheet__close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.city-sheet__close svg { width: 18px; height: 18px; }

/* 省 / 市 切换 */
.city-sheet__tabs {
  position: relative;
  display: flex;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.ctab {
  position: relative;
  padding: 11px 2px;
  font-size: 14px;
  color: var(--text-2);
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctab.is-active { color: var(--text-1); font-weight: 600; }
.ctab__ink {
  position: absolute;
  bottom: 0;
  height: 2px;
  width: 0;
  background: var(--brand);
  border-radius: 2px;
  transition: left .22s ease, width .22s ease;
}

/* 列表按内容自适应高度，条目多时内部滚动 */
.city-sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(72vh - 96px);
  min-height: 180px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.clist { padding: 4px 0 8px; }
.citem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  font-size: 14px;
  border-bottom: 1px solid #f6f7f9;
}
.citem:active { background: #fafbfc; }
.citem.is-active { color: var(--brand); font-weight: 600; background: #fffaf9; }
.citem__check { width: 16px; height: 16px; color: var(--brand); flex-shrink: 0; }
.citem--empty { justify-content: center; color: var(--text-3); font-size: 13px; }
.citem__hint { font-size: 12px; color: var(--text-3); font-weight: 400; }

/* ============ 底部动作弹层 ============ */
.action-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 50;
  max-width: 616px;
  margin: 0 auto;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  animation: slideUp .24s cubic-bezier(.22, .8, .3, 1) both;
}
.action-sheet__title { padding: 16px 16px 4px; font-size: 15px; font-weight: 600; text-align: center; }
.action-sheet__sub { padding: 0 16px 12px; font-size: 12px; color: var(--text-3); text-align: center; border-bottom: 1px solid var(--line); }
.action-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  font-size: 16px;
  border-bottom: 1px solid var(--line);
}
.action-item:active { background: #f6f7f9; }
.action-item__dot { width: 8px; height: 8px; border-radius: 50%; }
.action-item--cancel { color: var(--text-2); border-bottom: 0; margin-top: 6px; font-weight: 600; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  z-index: 90;
  transform: translateX(-50%);
  max-width: 78vw;
  padding: 9px 16px;
  font-size: 13px;
  color: #fff;
  background: rgba(26, 29, 36, .88);
  border-radius: 8px;
  text-align: center;
  animation: fade .2s ease both;
}

/* 定位诊断面板（仅 ?debug=1 显示） */
.diag {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 200;
  max-height: 46vh;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 11px;
  line-height: 1.6;
  color: #d7dce5;
  background: rgba(20, 23, 30, .94);
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
}
.diag__title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.diag__row { display: flex; gap: 8px; padding: 2px 0; }
.diag__step {
  flex: 0 0 52px;
  color: #8fd3ff;
}
.diag__detail { flex: 1; word-break: break-all; }

/* 小屏适配 */
@media (max-width: 340px) {
  .card__cover, .sk--cover { width: 82px; height: 82px; }
  .btn { padding: 0 9px; }
}
