/* 换药点地图 · 患者端 P0
   设计约束：正文 >=16px，可点区域 >=44px，颜色 + 文字双编码（色盲友好） */

:root {
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --gray: #6b7280;
  --gray-soft: #f3f4f6;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --line: #e5e7eb;
  --ink: #111827;
  --ink-2: #4b5563;
  --bg: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(17, 24, 39, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- 测试横幅 ---------- */
.testbar {
  background: var(--amber-soft);
  color: var(--amber);
  border-bottom: 1px solid #fde68a;
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 14px;
  text-align: center;
  white-space: pre-line;
}

/* ---------- 标题 ---------- */
.topbar {
  padding: 14px 16px 10px;
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .5px;
}
.topbar .sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ink-2);
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.topbar-main { min-width: 0; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* 右上角入口：医院入口所有尺寸显示；管理登录仅桌面显示 */
.toplink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  min-height: 36px;
}
.toplink:hover { border-color: #cbd5e1; color: var(--ink); }
.toplink svg { flex: 0 0 auto; }
.toplink.adminlink { display: none; }

/* ---------- 地图 ---------- */
.mapwrap {
  position: relative;
  height: 42vh;
  min-height: 230px;
  background: var(--gray-soft);
}
#map { width: 100%; height: 100%; }

.lochint {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 6px 8px 6px 14px;
  font-size: 14px;
}
.lochint #loctext {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.lochint.ok #loctext { color: var(--green); }
.lochint.warn #loctext { color: var(--amber); }

.mini {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  white-space: nowrap;
}
.mini:active { background: var(--gray-soft); }

/* ---------- 列表区 ---------- */
.panel { padding: 12px 0 0; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 10px;
  font-size: 14px;
  color: var(--ink-2);
}

.searchbar { padding: 0 16px 10px; }
.searchbar input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.searchbar input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* 筛选：区域 / 类型 各占一行，标签在左，chips 横向滚动 */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px 16px;
}
.filter-label {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--gray);
  letter-spacing: .5px;
}
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 16px 2px 0;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 15px;
  color: var(--ink-2);
}
.chip[aria-pressed="true"] {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.badge .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: 0;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, .18);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 0 16px 10px;
  font-size: 13px;
  color: var(--gray);
}
.legend-label { color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, .18);
}
.legend-hint { margin-left: auto; font-size: 12px; color: var(--gray); }

/* 地图标记：SVG 针身 + 针心字形，颜色来自高德导出的「颜色」列 */
.hy-pin svg { display: block; filter: drop-shadow(0 1px 2px rgba(17, 24, 39, .35)); }

.list {
  list-style: none;
  margin: 0;
  padding: 0 12px;
}

.item {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 10px;
}
.item:active { background: var(--gray-soft); }

.item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.item-name {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}
.item-dist {
  flex: 0 0 auto;
  font-size: 15px;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.item-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 14px;
  color: var(--ink-2);
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 20px;
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid #dbeafe;
}
.badge.gray { background: var(--gray-soft); color: var(--gray); border-color: var(--line); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 6px;
}
.status.open { color: var(--green); background: var(--green-soft); border: 1px solid #bbf7d0; }
.status.closed { color: var(--gray); background: var(--gray-soft); border: 1px solid var(--line); }
.status.paused { color: var(--red); background: #fef2f2; border: 1px solid #fecaca; }
.status.unknown { color: var(--amber); background: var(--amber-soft); border: 1px solid #fde68a; }

.services {
  margin-top: 8px;
  font-size: 14px;
  color: var(--gray);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--gray);
  font-size: 15px;
  padding: 32px 16px;
}

.foot {
  padding: 8px 16px 28px;
  font-size: 13px;
  color: var(--gray);
  line-height: 1.6;
}
.foot p { margin: 6px 0; }
.foot .dim { color: #9ca3af; }

/* ---------- 详情面板 ---------- */
.detail {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.detail[hidden] { display: none; }

.detail-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  animation: slideup .22s ease-out;
  -webkit-overflow-scrolling: touch;
}
@keyframes slideup {
  from { transform: translateY(24px); opacity: .6; }
  to   { transform: translateY(0);    opacity: 1; }
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--gray-soft);
  color: var(--ink-2);
  font-size: 17px;
  line-height: 40px;
}

.detail h2 {
  margin: 0 44px 10px 0;
  font-size: 21px;
  line-height: 1.35;
}
.detail .row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.d-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  margin: 14px 0;
  font-size: 16px;
  font-weight: 600;
}
.d-status.open { background: var(--green-soft); color: #15803d; border: 1px solid #bbf7d0; }
.d-status.closed { background: var(--gray-soft); color: var(--ink-2); border: 1px solid var(--line); }
.d-status.paused { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.d-status.unknown { background: var(--amber-soft); color: var(--amber); border: 1px solid #fde68a; }
.d-status small { font-weight: 400; font-size: 14px; opacity: .85; }

.dl {
  margin: 0 0 16px;
  border-top: 1px solid var(--line);
}
.dl > div {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.dl dt {
  flex: 0 0 88px;
  color: var(--gray);
}
.dl dd {
  margin: 0;
  flex: 1;
  color: var(--ink);
  word-break: break-word;
}

.week {
  margin: 0 0 16px;
  font-size: 15px;
  border-top: 1px solid var(--line);
}
.week .w-row {
  display: flex;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
}
.week .w-row.today { color: var(--ink); font-weight: 600; background: var(--blue-soft); }
.week .w-day { flex: 0 0 76px; }
.week .w-time { flex: 1; }

.actions {
  display: flex;
  gap: 10px;
  margin: 18px 0 10px;
}
.btn {
  flex: 1;
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn:disabled {
  opacity: .55;
  color: var(--gray);
}
.btn:active { transform: scale(.99); }

.hint {
  font-size: 14px;
  color: var(--gray);
  background: var(--gray-soft);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.6;
}
.verify {
  margin-top: 14px;
  font-size: 13px;
  color: var(--gray);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.verify a { color: var(--blue); text-decoration: none; align-self: flex-start; }

.week-unknown {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  border-radius: 10px;
  color: var(--amber);
  font-size: 14px;
  line-height: 1.55;
}
.week-unknown strong { font-size: 15px; }

.verify-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  border-radius: 10px;
  color: var(--amber);
  font-size: 13px;
  line-height: 1.55;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 2000;
  max-width: 86vw;
  background: rgba(17, 24, 39, .9);
  color: #fff;
  font-size: 15px;
  line-height: 1.5;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* ---------- Leaflet 微调 ---------- */
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px !important; }
.dot-me {
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, .18);
}

@media (min-width: 561px) {
  .detail { align-items: center; }
  .detail-card { border-radius: 18px; max-height: 86vh; }
}


/* ---------- 桌面端：地图 + 右侧列表 ---------- */
@media (min-width: 960px) {
  html, body { height: 100%; }

  body {
    max-width: none;
    margin: 0;
    padding-bottom: 0;
    height: 100vh;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "testbar testbar"
      "topbar  topbar"
      "map     panel";
  }

  .testbar { grid-area: testbar; padding: 8px 24px; }

  .topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--line);
  }
  .topbar h1 { font-size: 24px; }
  .topbar .sub { margin-top: 2px; }
  .toplink { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  .toplink.adminlink { display: inline-flex; }

  .mapwrap {
    grid-area: map;
    height: 100%;
    min-height: 0;
  }

  .panel {
    grid-area: panel;
    height: 100%;
    overflow-y: auto;
    padding-top: 14px;
    border-left: 1px solid var(--line);
    background: #fff;
  }
  .panel-head { padding: 0 18px 10px; }
  .searchbar { padding: 0 18px 10px; }
  .filter-row { padding-left: 18px; align-items: flex-start; }
  .filter-label { padding-top: 8px; }
  .chip { min-height: 32px; padding: 0 11px; font-size: 13px; }
  .chips {
    flex-wrap: wrap;
    overflow-x: visible;
    padding-right: 18px;
  }
  .legend { padding-left: 18px; }
  .list { padding: 0 14px; }
  .foot { padding: 8px 18px 28px; }

  .lochint {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: 720px;
    margin: 0 auto;
  }
}
