/* ============================================================
   「驿」路同行 — 环卫工人歇脚驿站地图
   设计语言：温暖实用主义（Warm Utilitarianism）
   关键原则：
   - 大字号、强对比（户外阳光下可读）
   - 大按钮（戴手套也能点）
   - 关键操作一步到位（定位/导航/详情）
   - 状态色明确（绿=开放，灰=关闭，黄=维护）
   ============================================================ */

:root {
  /* 主色 — 温暖橙黄，呼应项目组小牛 IP */
  --c-primary:        #F5A623;
  --c-primary-deep:   #E08E0B;
  --c-primary-soft:   #FFF1D6;

  /* 辅色 — 蓝绿，呼应高德地图 */
  --c-accent:         #1A9988;
  --c-accent-soft:    #D6EFEB;

  /* 状态色 */
  --c-success:        #1F9D55;
  --c-success-soft:   #E3F5EA;
  --c-warning:        #E69500;
  --c-warning-soft:   #FFF1CC;
  --c-danger:         #C5382A;
  --c-danger-soft:    #FBE5E1;

  /* 中性 */
  --c-bg:             #FAF7F2;
  --c-surface:        #FFFFFF;
  --c-surface-2:      #F4EFE7;
  --c-text:           #1F1F1F;
  --c-text-2:         #5A564F;
  --c-text-3:         #8C8780;
  --c-border:         #E6E1D6;
  --c-border-strong:  #C9C2B1;

  /* 尺寸 */
  --radius-sm:        8px;
  --radius-md:        12px;
  --radius-lg:        16px;
  --radius-xl:        20px;

  /* 阴影（克制使用） */
  --shadow-sm:        0 1px 2px rgba(40,30,10,.06);
  --shadow-md:        0 4px 14px rgba(40,30,10,.10);
  --shadow-lg:        0 10px 32px rgba(40,30,10,.18);

  /* 安全区 */
  --safe-top:         env(safe-area-inset-top, 0px);
  --safe-bottom:      env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

button { font-family: inherit; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ───────────── Header ───────────── */
.app-header {
  position: sticky;
  top: 0; z-index: 50;
  background: linear-gradient(180deg, #FFF7E8 0%, #FFFFFF 100%);
  border-bottom: 1px solid var(--c-border);
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}
.brand-text { min-width: 0; }
.brand-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: .02em;
  line-height: 1.2;
}
.brand-subtitle {
  font-size: 12px;
  color: var(--c-text-2);
  margin-top: 2px;
  line-height: 1.3;
}

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 16px;
  font-weight: 600;
  min-height: 44px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 2px; }

.btn-icon {
  padding: 6px 12px 6px 10px;
  flex: 0 0 auto;
}
.btn-icon-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-accent);
}

.btn-primary {
  background: var(--c-primary);
  color: #1F1500;
  border-color: var(--c-primary-deep);
}
.btn-primary:hover { background: var(--c-primary-deep); }

.btn-ghost {
  background: transparent;
  border-color: var(--c-border-strong);
  color: var(--c-text-2);
}

.btn-floating {
  position: absolute;
  right: 16px;
  bottom: 16px;
  padding: 8px 14px;
  background: var(--c-surface);
  box-shadow: var(--shadow-md);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text-2);
  z-index: 5;
}

/* ───────────── Filter bar ───────────── */
.filter-bar {
  background: var(--c-surface);
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
}
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.filter-select select {
  width: 100%;
  appearance: none;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 10px 28px 10px 12px;
  font-size: 14px;
  color: var(--c-text);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235A564F' stroke-width='2.2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
}
.filter-select select:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 1px;
}

/* ───────────── Map ───────────── */
.map-wrap {
  position: relative;
  height: 38vh;
  min-height: 280px;
  background: #EEEAE0;
  border-bottom: 1px solid var(--c-border);
}
#map { width: 100%; height: 100%; }

.map-loading,
.map-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--c-text-2);
  background: #EEEAE0;
  padding: 16px;
  text-align: center;
}
.map-error { color: var(--c-danger); background: var(--c-danger-soft); }

/* hidden 属性必须严格生效 — 不然错误浮层会一直挡住地图 */
.map-loading[hidden],
.map-error[hidden],
#map-loading[hidden],
#map-error[hidden] { display: none !important; }
.map-error-inner { max-width: 92%; line-height: 1.6; }
.map-error-title { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.map-error-detail { font-size: 14px; white-space: pre-line; }
.map-error-host {
  margin-top: 8px; font-size: 12px; color: var(--c-text-2);
  background: rgba(255,255,255,.6); border-radius: 8px; padding: 4px 8px;
  display: inline-block; word-break: break-all;
}

/* 高德 Marker 自定义 — 在 JS 中注入样式，这里给关键结构 */
.amap-marker-station {
  position: relative;
  width: 36px; height: 44px;
}
.amap-marker-station .marker-pin {
  position: absolute; inset: 0;
  background: var(--c-success);
  border: 2px solid #FFFFFF;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
}
.amap-marker-station .marker-pin.is-closed { background: var(--c-text-3); }
.amap-marker-station .marker-pin.is-maintenance { background: var(--c-warning); }
.amap-marker-station .marker-pin::after {
  content: '';
  position: absolute;
  top: 8px; left: 8px;
  width: 16px; height: 16px;
  background: #FFFFFF;
  border-radius: 50%;
}
.amap-marker-station.active .marker-pin {
  background: var(--c-primary);
  transform: rotate(-45deg) scale(1.15);
}

/* ───────────── List ───────────── */
.list-wrap {
  flex: 1;
  background: var(--c-bg);
  padding: 12px 12px 0;
}
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.list-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--c-text);
}
.list-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--c-text-2);
}
.list-sort-tag {
  background: var(--c-accent-soft);
  color: var(--c-accent);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}

.station-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name name"
    "addr addr"
    "dist dist"
    "nav  nav";
  gap: 8px 10px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.station-card:hover { border-color: var(--c-primary); box-shadow: var(--shadow-sm); }
.station-card:active { transform: scale(.995); }
.station-card.is-active { border-color: var(--c-primary); box-shadow: 0 0 0 2px var(--c-primary-soft); }

.station-card .station-name {
  grid-area: name;
  font-size: 17px;
  font-weight: 700;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.station-card .station-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  line-height: 1;
}
.station-card .station-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.station-card .station-status.status-open {
  color: var(--c-success);
  background: var(--c-success-soft);
}
.station-card .station-status.status-closed {
  color: var(--c-text-3);
  background: var(--c-surface-2);
}
.station-card .station-status.status-maintenance {
  color: var(--c-warning);
  background: var(--c-warning-soft);
}
.station-card .station-distance {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-accent);
  white-space: nowrap;
}

.station-card .station-address {
  grid-area: addr;
  font-size: 14px;
  color: var(--c-text-2);
  line-height: 1.4;
}

.station-card .station-facilities {
  grid-area: dist;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.facility-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--c-text-2);
  background: var(--c-surface-2);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
}
.facility-chip svg { color: var(--c-accent); }

.station-card .station-actions {
  grid-area: nav;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.station-card .station-actions .btn {
  flex: 1;
  min-height: 42px;
  font-size: 14px;
  padding: 8px 12px;
}

.list-empty {
  text-align: center;
  padding: 36px 16px 48px;
  color: var(--c-text-2);
}
.list-empty-icon { font-size: 36px; margin-bottom: 8px; }
.list-empty-hint { font-size: 13px; color: var(--c-text-3); margin-top: 4px; }

/* ───────────── Footer / Stats ───────────── */
.app-footer {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 14px 16px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 480px;
}
.stat {
  background: var(--c-surface-2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: center;
}
.stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.1;
}
.stat-label {
  font-size: 12px;
  color: var(--c-text-2);
  margin-top: 4px;
}
.footer-tip {
  font-size: 12px;
  color: var(--c-text-3);
  margin: 4px 0 0;
  text-align: center;
}

/* ───────────── Drawer (详情) ───────────── */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 18, 12, .42);
  z-index: 80;
  animation: fade-in .2s ease;
}
.drawer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: var(--c-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  padding-bottom: var(--safe-bottom);
}
.drawer.is-open { transform: translateY(0); }
.drawer-handle {
  width: 44px; height: 5px;
  background: var(--c-border-strong);
  border-radius: 999px;
  margin: 8px auto 0;
}
.drawer-close {
  position: absolute;
  top: 8px; right: 12px;
  width: 36px; height: 36px;
  border: none; background: transparent;
  font-size: 26px; line-height: 1;
  color: var(--c-text-2);
  border-radius: var(--radius-sm);
}
.drawer-body {
  overflow-y: auto;
  padding: 14px 18px 18px;
  -webkit-overflow-scrolling: touch;
}

.drawer-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 4px;
  padding-right: 40px;
}
.drawer-subtitle {
  font-size: 14px;
  color: var(--c-text-2);
  margin-bottom: 12px;
}

.detail-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
}
.detail-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text-2);
  margin-bottom: 8px;
  letter-spacing: .02em;
}
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  color: var(--c-text);
  margin-bottom: 6px;
  line-height: 1.5;
}
.detail-row svg { flex: 0 0 auto; color: var(--c-accent); margin-top: 2px; }

.detail-facilities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.detail-actions .btn { min-height: 48px; font-size: 15px; }

.admin-only {
  background: var(--c-warning-soft);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--c-warning);
  border: 1px dashed var(--c-warning);
}
.admin-only strong { display: block; margin-bottom: 6px; color: #8A5C00; }
.admin-only input {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border-strong);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 6px;
}
.admin-only .status-btns {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.admin-only .status-btns button {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  font-size: 13px;
  font-weight: 600;
}
.admin-only .status-btns button.is-active {
  background: var(--c-primary);
  color: #1F1500;
  border-color: var(--c-primary-deep);
}

/* ───────────── Modal (反馈) ───────────── */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 18, 12, .5);
  padding: 0;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--c-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slide-up .25s ease;
}
@media (min-width: 640px) {
  .modal { align-items: center; padding: 20px; }
  .modal-card { border-radius: var(--radius-xl); }
}
.modal-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
}
.modal-hint {
  font-size: 13px;
  color: var(--c-text-2);
  margin: 0 0 14px;
}

.form-label {
  display: block;
  margin-bottom: 12px;
}
.form-label > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-2);
  margin-bottom: 6px;
}
.form-label select,
.form-label input,
.form-label textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  font-size: 15px;
  color: var(--c-text);
  font-family: inherit;
}
.form-label textarea { resize: vertical; min-height: 90px; }
.form-label select:focus-visible,
.form-label input:focus-visible,
.form-label textarea:focus-visible {
  outline: 3px solid var(--c-primary);
  outline-offset: 1px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.modal-actions .btn { min-height: 44px; padding: 8px 18px; }

.form-status {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--c-success);
}
.form-status.is-error { color: var(--c-danger); }

/* ───────────── Toast ───────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(20, 18, 12, .92);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 200;
  max-width: 80vw;
  box-shadow: var(--shadow-md);
  animation: fade-in .15s ease;
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--c-danger); }
.toast.is-success { background: var(--c-success); }

/* ───────────── 动画 ───────────── */
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide-up { from { transform: translateY(100%) } to { transform: translateY(0) } }

/* ───────────── 大屏适配 ───────────── */
@media (min-width: 900px) {
  .map-wrap { height: 50vh; min-height: 420px; }
  .filter-row { max-width: 720px; }
  .app-footer { flex-direction: row; justify-content: space-between; max-width: 720px; margin: 0 auto; width: 100%; }
  .stats { max-width: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}