/* ===== 基础重置与移动适配 ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #333;
  background: #f5f5f5;
  overscroll-behavior: none;
}
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #e5e5e5;
}

/* ===== 导航页 UI ===== */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(10px);
  padding: 10px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.top-bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.top-bar .sub {
  font-size: 12px;
  color: #666;
}

.bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: rgba(255,255,255,0.95);
  backdrop-filter: saturate(180%) blur(10px);
  padding: 14px 16px 22px;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.1);
}
.bottom-sheet label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #444;
}
.bottom-sheet select {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid #ccc;
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
}
.route-info {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.route-info.hidden { display: none; }
.info-row {
  background: #f1f8ff;
  border-left: 4px solid #2196F3;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.info-row span { display: block; }
.info-row .label { font-size: 12px; color: #666; }
.info-row .value { font-weight: 700; color: #111; }

.fab {
  position: absolute;
  right: 16px;
  bottom: 180px;
  z-index: 10;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.fab:active { transform: scale(0.96); }

.compass {
  position: absolute;
  top: 66px;
  right: 16px;
  z-index: 10;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: transform 0.15s linear;
}
.compass.hidden { display: none; }
.compass .arrow {
  transition: transform 0.15s linear;
}

.perm-banner {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 11;
  background: #fff3cd;
  color: #856404;
  padding: 8px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.perm-banner.hidden { display: none; }
.perm-banner button {
  background: #856404;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

/* ===== 地图标记样式 ===== */
.camp-marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  width: 32px !important;
  height: 32px !important;
  border-radius: 50%;
  background: #fff;
  border: 2px solid currentColor;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.user-marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px !important;
  height: 24px !important;
}
.user-dot {
  width: 16px;
  height: 16px;
  background: #2196F3;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.user-arrow {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 18px solid #2196F3;
  transform-origin: 50% 70%;
}

/* ===== 后台管理页 ===== */
.admin-wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.admin-header h1 {
  margin: 0;
  font-size: 20px;
}
.card {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.form-row input,
.form-row select,
.form-row textarea {
  flex: 1 1 220px;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid #ccc;
  border-radius: 8px;
}
.form-row textarea {
  flex: 1 1 100%;
  min-height: 72px;
  resize: vertical;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: #2196F3;
  color: #fff;
}
.btn.secondary { background: #9E9E9E; }
.btn.danger { background: #f44336; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #eee;
}
th { color: #666; font-weight: 600; }
tr:active { background: #f8f8f8; }

.admin-map-wrap {
  height: 260px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #ddd;
  margin-bottom: 10px;
}
.hint {
  color: #666;
  font-size: 13px;
  margin: 6px 0 12px;
}

/* ===== 定位失败 Banner ===== */
.locate-error-banner {
  position: absolute;
  top: 80px;
  left: 16px;
  right: 16px;
  z-index: 50;
  background: #fff3e0;
  border: 1px solid #ffb74d;
  border-left: 4px solid #ff9800;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideDown 0.3s ease-out;
}

.locate-error-banner.hidden {
  display: none !important;
}

.locate-error-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.locate-error-body {
  flex: 1;
  min-width: 0;
}

.locate-error-title {
  font-size: 14px;
  font-weight: 600;
  color: #e65100;
  margin-bottom: 4px;
}

.locate-error-msg {
  font-size: 12px;
  color: #5d4037;
  line-height: 1.5;
  word-break: break-word;
}

.locate-error-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.locate-error-retry,
.locate-error-dismiss {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.locate-error-retry {
  background: #ff9800;
  color: #fff;
  font-weight: 500;
}

.locate-error-retry:hover {
  background: #f57c00;
}

.locate-error-retry:active {
  background: #ef6c00;
}

.locate-error-dismiss {
  background: transparent;
  color: #8d6e63;
  border: 1px solid #d7ccc8;
}

.locate-error-dismiss:hover {
  background: rgba(0,0,0,0.04);
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 失败时, 用户位置标记也变灰 + 加 ❌ */
.user-marker-icon.failed {
  opacity: 0.5;
  position: relative;
}

.user-marker-icon.failed::after {
  content: '❌';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 14px;
  background: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ===== admin: 使用我的位置 ===== */
#useMyLocationBtn {
  background: #ff9800;
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  padding: 8px 14px;
}
#useMyLocationBtn:hover { background: #f57c00; }
#useMyLocationBtn:active { background: #ef6c00; }
#useMyLocationBtn:disabled {
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.7;
}

.locate-status-row {
  min-height: 0;
  margin-top: -8px;
}

.locate-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  background: #f5f5f5;
  color: #666;
  width: 100%;
  transition: all 0.2s;
}

.locate-status.hidden { display: none !important; }

.locate-status.loading {
  background: #fff3e0;
  color: #e65100;
}

.locate-status.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.locate-status.error {
  background: #ffebee;
  color: #c62828;
}

.locate-status-icon { font-size: 16px; line-height: 1; }

.locate-status-msg {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.locate-status-accuracy {
  font-size: 11px;
  opacity: 0.7;
  margin-left: 8px;
}

/* ===== 登录遮罩 ===== */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 50%, #1e3a5f 100%);
  padding: 20px;
}

.login-gate.hidden { display: none !important; }

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-icon {
  font-size: 48px;
  margin-bottom: 8px;
  line-height: 1;
}

.login-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  color: #1e293b;
}

.login-sub {
  margin: 0 0 24px;
  font-size: 14px;
  color: #64748b;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form input {
  padding: 12px 14px;
  font-size: 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
  letter-spacing: 4px;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: #2d5a87;
  background: #fff;
}

.login-btn {
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #2d5a87, #1e3a5f);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, box-shadow 0.2s;
}

.login-btn:hover { box-shadow: 0 4px 12px rgba(45, 90, 135, 0.4); }
.login-btn:active { transform: translateY(1px); }

.login-error {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 13px;
  border-radius: 6px;
  animation: shake 0.4s;
}

.login-error.hidden { display: none !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.login-back {
  display: inline-block;
  margin-top: 20px;
  color: #64748b;
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}

.login-back:hover { color: #1e3a5f; }

/* ===== 搜索栏 + 类型过滤 ===== */

.dest-top {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dest-top label {
  font-size: 14px;
  font-weight: 600;
  color: #2d5a87;
  white-space: nowrap;
  margin-bottom: 0;
}

.dest-top-select {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  padding: 4px 0;
  cursor: pointer;
  color: #1e293b;
}

.dest-top-select:focus { outline: none; }

.search-bar {
  position: absolute;
  top: 60px;
  left: 12px;
  right: 12px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.type-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 2px;
}

.type-chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  background: rgba(255,255,255,0.95);
  border: 1.5px solid #e0e0e0;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.15s;
}

.chip.active {
  background: #2d5a87;
  color: #fff;
  border-color: #2d5a87;
}

/* ===== 加载进度 ===== */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.95);
  padding: 14px 20px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 14px;
  color: #555;
}

.loading-indicator.hidden { display: none !important; }

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid #e0e0e0;
  border-top-color: #2d5a87;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 底部面板重做 ===== */
.bottom-sheet {
  padding: 16px 16px 20px;
}

/* 主信息: 距离 + 时间 */
.route-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  margin: 12px 0;
}

.route-stat {
  flex: 1;
  text-align: center;
}

.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: #2d5a87;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.route-divider {
  width: 1px;
  height: 40px;
  background: #e0e0e0;
}

/* 方向卡片 */
.route-direction {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dir-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #cbd5e1;
  transition: all 0.2s;
}

.dir-card.dir-target {
  background: #e3f2fd;
  border-left-color: #2d5a87;
}

.dir-card.dir-target .dir-icon {
  color: #2d5a87;
  font-size: 28px;
}

.dir-icon {
  font-size: 22px;
  width: 36px;
  text-align: center;
  color: #64748b;
  flex-shrink: 0;
}

.dir-info {
  flex: 1;
  min-width: 0;
}

.dir-label {
  font-size: 11px;
  color: #888;
  margin-bottom: 2px;
}

.dir-value {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

/* ===== 百度地图步行导航按钮 ===== */
.nav-btn {
  display: block;
  width: 100%;
  margin: 12px 0;
  padding: 12px 16px;
  background: linear-gradient(135deg, #4a90e2, #2d5a87);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(45, 90, 135, 0.25);
  transition: transform 0.1s, box-shadow 0.2s;
  text-align: center;
}

.nav-btn:hover { box-shadow: 0 4px 14px rgba(45, 90, 135, 0.4); }
.nav-btn:active { transform: translateY(1px); }

/* ===== 标记名称标签 ===== */
.camp-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.camp-marker-label {
  margin-top: 4px;
  padding: 2px 6px;
  background: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  line-height: 1.3;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;  /* 不阻挡地图拖动 */
}

.camp-marker-target .camp-marker-label {
  font-size: 12px;
  padding: 3px 8px;
  box-shadow: 0 2px 6px rgba(233, 30, 99, 0.3);
}

/* ===== 微信内步行按钮下方提示 ===== */
.nav-weixin-hint {
  margin: -8px 0 12px;
  padding: 8px 12px;
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 6px;
  color: #e65100;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.nav-weixin-hint.hidden { display: none !important; }

.nav-weixin-hint strong { color: #bf360c; font-weight: 700; }

/* ===== 我的状态卡 (常驻) ===== */
.my-status-card {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  border: 1px solid #90caf9;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.my-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.my-status-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.my-status-info {
  flex: 1;
  min-width: 0;
}

.my-status-label {
  font-size: 11px;
  color: #1565c0;
  font-weight: 500;
  margin-bottom: 2px;
}

.my-status-value {
  font-size: 14px;
  color: #0d47a1;
  font-weight: 600;
  line-height: 1.3;
}

.my-status-arrow {
  text-align: right;
  flex-shrink: 0;
}

.my-status-arrow .my-status-label {
  color: #6a1b9a;
}

.my-status-arrow .my-status-value {
  color: #4a148c;
  font-size: 16px;
}

/* ===== 增强版用户位置 marker ===== */
.user-marker-icon {
  position: relative;
  width: 48px !important;
  height: 48px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 22px solid #2196F3;
  top: 0;
  left: 50%;
  margin-left: -11px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
  transform-origin: 50% 75%;
  transition: transform 0.3s ease;
}

/* ===== 导航按钮组 ===== */
.nav-btn-group {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.nav-btn-group .nav-btn {
  flex: 1;
  margin: 0;
}

.nav-btn-secondary {
  background: linear-gradient(135deg, #ff7043, #e64a19);
  box-shadow: 0 2px 8px rgba(230, 74, 25, 0.25);
}
.nav-btn-secondary:hover {
  box-shadow: 0 4px 14px rgba(230, 74, 25, 0.4);
}

/* ===== 底部面板折叠 ===== */
.bottom-sheet {
  transition: max-height 0.3s ease, padding 0.3s ease, transform 0.3s ease;
  max-height: 80vh;
  overflow: hidden auto;
}

.bottom-sheet.collapsed {
  max-height: 48px;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
}

.bottom-sheet.collapsed > *:not(.sheet-handle) {
  display: none;
}

.sheet-handle {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  padding: 6px 0 8px;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.sheet-handle-icon {
  display: inline-block;
  font-size: 14px;
  color: #999;
  transition: transform 0.3s ease;
  user-select: none;
}

.bottom-sheet.collapsed .sheet-handle-icon {
  transform: rotate(180deg);
}

/* 全屏模式: 隐藏顶部搜索/类型过滤, 给地图更多空间 */
body.fullscreen .top-bar,
body.fullscreen .search-bar {
  display: none;
}
