/* ============================================================
   style-mobile.css — Keep 校园跑 Liquid Glass 移动端 UI
   移动端（≤768px）：全屏地图 + 底部浮动工具栏 + 半屏弹窗
   ============================================================ */

/* ---------- 桌面端 / 移动端显示切换 ---------- */
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
}
@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

/* ============================================================
   移动端底部工具栏（≤768px）
   ============================================================ */
@media (max-width: 768px) {
  /* ---------- 全屏地图 ---------- */
  #app {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .map-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1 !important;
  }

  #map {
    width: 100%;
    height: 100%;
  }

  /* ---------- 移动端底部工具栏 ---------- */
  #mobileToolbar {
    position: fixed;
    bottom: 12px;
    left: 8px;
    right: 8px;
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* 工具栏按钮 */
  .toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 56px;
    height: 52px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px;
    border-radius: 12px;
    transition: all 300ms ease-out;
    color: var(--text-muted);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    outline: none;
  }

  .toolbar-btn:focus,
  .toolbar-btn:focus-visible {
    outline: none;
  }

  @media (hover: hover) {
    .toolbar-btn:hover {
      background: var(--glass-bg-hover);
      color: var(--text-primary);
    }
  }

  .toolbar-btn:active {
    background: var(--glass-bg-hover);
    transform: scale(0.92);
  }

  .toolbar-btn.active {
    color: var(--primary-hover);
    background: var(--primary-light);
  }

  .toolbar-btn svg {
    width: 22px;
    height: 22px;
  }

  .toolbar-btn .toolbar-label {
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
    color: inherit;
  }

  /* ---------- 弹窗遮罩 ---------- */
  #sheetBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 40;
    opacity: 0;
    transition: opacity 300ms ease-out;
    pointer-events: none;
  }

  #sheetBackdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* 底部弹窗 */
  #bottomSheet {
    position: fixed;
    bottom: 96px;
    left: 8px;
    right: 8px;
    max-height: 68vh;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    z-index: 45;
    transform: translateY(100vh);
    transition: transform 350ms cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #bottomSheet.open {
    transform: translateY(0);
  }

  /* 导出面板高度增加 */
  #bottomSheet:has(.sheet-panel[data-panel="export"].active) {
    max-height: 80vh;
  }

  /* 弹窗拖拽手柄 */
  .sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--glass-border);
    border-radius: 4px;
    margin: 10px auto 6px;
    flex-shrink: 0;
    cursor: grab;
    touch-action: none;
  }

  .sheet-handle:active {
    cursor: grabbing;
  }

  /* 弹窗内容区域 */
  .sheet-scroll {
    flex: 1;
    min-height: 0;
    height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 16px 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
  }

  .sheet-scroll::-webkit-scrollbar {
    width: 4px;
  }

  .sheet-scroll::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
  }

  /* 弹窗面板 */
  .sheet-panel {
    display: none;
  }

  .sheet-panel.active {
    display: block;
  }

  /* ---------- 弹窗内适配原控件 ---------- */
  #bottomSheet .card {
    margin: 8px 0;
    border-radius: 16px;
    box-shadow: none;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
  }

  #bottomSheet .card:hover {
    transform: none;
    box-shadow: none;
  }

  #bottomSheet .card-body {
    padding: 10px 12px;
  }

  #bottomSheet .card-header {
    padding: 10px 12px;
  }

  /* 开关控件 */
  #bottomSheet .switch-slider {
    width: 42px;
    height: 22px;
  }

  #bottomSheet .switch-slider::after {
    width: 18px;
    height: 18px;
  }

  #bottomSheet .switch-label input:checked + .switch-slider::after {
    transform: translateX(20px);
  }

  /* 弹窗内按钮间距 */
  #bottomSheet .action-buttons {
    padding: 0;
    margin-top: 12px;
    background: transparent !important;
  }

  #bottomSheet .btn-generate,
  #bottomSheet .btn-preview,
  #bottomSheet .btn-location {
    padding: 12px;
    font-size: 13px;
  }

  #bottomSheet .btn-generate {
    background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.3);
  }

  #bottomSheet .btn-preview {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
  }

  #bottomSheet .btn-preview:hover {
    background: var(--glass-bg-hover);
  }

  #bottomSheet .btn-location {
    width: 100%;
  }

  /* 弹窗内交互控件 */
  #bottomSheet .switch-slider {
    background: var(--glass-bg-hover) !important;
  }

  #bottomSheet input:checked + .switch-slider {
    background: var(--primary) !important;
  }

  #bottomSheet input,
  #bottomSheet select,
  #bottomSheet .param-picker-btn,
  #bottomSheet .map-source-btn,
  #bottomSheet .shape-picker-btn {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
  }

  #bottomSheet .distance-display {
    background: var(--distance-bg) !important;
    border-color: var(--distance-border) !important;
  }

  /* 弹窗内导出份数输入框 */
  #bottomSheet .export-count input[type="number"] {
    flex: 1;
    min-width: 0;
    max-width: none;
  }

  #bottomSheet .export-pace-min,
  #bottomSheet .export-pace-sec {
    flex: 1;
    min-width: 0;
  }

  /* 弹窗内搜索框 */
  #bottomSheet .search-box {
    position: relative;
    overflow: visible;
    z-index: 1;
  }

  #bottomSheet .search-suggestions {
    width: calc(100vw - 48px);
    max-width: none;
  }

  /* 弹窗内距离显示 */
  #bottomSheet .distance-display {
    font-size: 16px;
    padding: 10px 12px;
  }

  /* 弹窗内路线操作网格 */
  #bottomSheet .route-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  /* 弹窗内参数网格 */
  #bottomSheet .param-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* 弹窗内导出设置 */
  #bottomSheet .export-format-row {
    flex-wrap: wrap;
  }

  #bottomSheet .format-radio {
    flex: 1 1 calc(50% - 4px);
    padding: 10px 4px;
  }

  /* 弹窗内预览图表 */
  #bottomSheet .preview-chart {
    min-height: 120px;
  }

  #bottomSheet .preview-chart canvas {
    width: 100% !important;
    height: 150px !important;
  }

  #bottomSheet .preview-panel.visible {
    max-height: none;
  }

  #bottomSheet .preview-stats {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  #bottomSheet .preview-stat-item {
    padding: 6px 2px;
  }

  #bottomSheet .preview-stat-value {
    font-size: 14px;
  }

  /* 弹窗内选择器浮层 */
  #bottomSheet .map-source-dropdown,
  #bottomSheet .shape-picker-dropdown,
  #bottomSheet .param-picker-dropdown {
    position: fixed;
    z-index: 99999;
  }

  /* ---------- 移动端 live-info ---------- */
  .live-info.mobile-live {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 35;
    margin: 0;
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 12px;
    background: var(--live-info-bg);
    border: 1px solid var(--live-info-border);
    color: var(--live-info-color);
    text-align: center;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease-out;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .live-info.mobile-live.visible {
    opacity: 1;
  }

  /* ---------- 移动端消息 ---------- */
  .message.mobile-message {
    position: fixed;
    top: 56px;
    left: 12px;
    right: 12px;
    z-index: 35;
    margin: 0;
    padding: 8px 14px;
    font-size: 12px;
    text-align: center;
    border-radius: 12px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    box-shadow: var(--glass-shadow);
    pointer-events: none;
  }

  /* ---------- 隐藏原 mobile-tabs ---------- */
  #mobileTabs {
    display: none !important;
  }

  /* ---------- 隐藏侧边栏 ---------- */
  .sidebar {
    display: none !important;
  }

  /* ---------- 弹窗内元素修复 ---------- */
  #bottomSheet #searchResult {
    font-size: 11px;
    min-height: 16px;
    color: var(--text-muted);
    padding: 3px 0;
  }

  /* ---------- 弹窗工具标题行 ---------- */
  .sheet-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0 8px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 12px;
  }

  .sheet-panel-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
  }

  /* ---------- 保存的路线列表 ---------- */
  #bottomSheet .saved-routes {
    min-height: 60px;
    max-height: 150px;
    margin-top: 12px;
    margin-bottom: 12px;
  }
}

/* ---------- 极小屏幕安全区域适配 ---------- */
@media (max-width: 768px) and (max-height: 600px) {
  #bottomSheet {
    max-height: 55vh;
  }

  #bottomSheet .preview-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  #bottomSheet .export-format-row {
    flex-wrap: wrap;
  }

  #bottomSheet .format-radio {
    flex: 1 1 calc(50% - 4px);
  }
}

/* ---------- 桌面端确保底部工具栏不显示 ---------- */
@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
}

/* ============================================================
   Toast 提示弹窗
   ============================================================ */
.toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 99999;
  padding: 12px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
  color: var(--text-primary);
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease-out, transform 300ms ease-out;
  max-width: calc(100vw - 48px);
  white-space: nowrap;
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Leaflet 版权信息
   ============================================================ */
.leaflet-control-attribution {
  position: absolute !important;
  bottom: auto !important;
  top: 8px !important;
  right: 8px !important;
  left: auto !important;
  background: var(--glass-bg) !important;
  backdrop-filter: blur(var(--glass-blur)) !important;
  -webkit-backdrop-filter: blur(var(--glass-blur)) !important;
  border-radius: 8px !important;
  padding: 2px 8px !important;
  font-size: 10px !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--glass-border) !important;
}

.leaflet-control-attribution a {
  color: var(--primary) !important;
}

/* ============================================================
   自定义确认弹窗
   ============================================================ */
.confirm-modal-content {
  max-width: 320px;
  text-align: center;
  padding: 32px 24px 24px;
}

.confirm-message {
  margin: 0 0 24px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 12px;
}

.confirm-actions .btn-secondary,
.confirm-actions .btn-primary {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  border-radius: 12px;
}

/* ============================================================
   生成结果弹窗
   ============================================================ */
.generating-content {
  text-align: center;
  padding: 36px 24px 28px;
}

.generating-text {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
}

.generating-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.gen-modal-support {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.gen-modal-support .support-qr-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.gen-modal-support .support-qr {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  object-fit: cover;
}

.gen-modal-support .support-text p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}
