/**
 * 全局基础样式：所有页面共用
 */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 顶部导航条：固定顶部，仅在有 meta.showTopNav 的页面显示；参照 WH5 TopNavBack */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: none;
  height: 44px;
  padding-top: env(safe-area-inset-top, 0);
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  align-items: center;
  box-sizing: content-box;
}

/* 返回按钮：左侧固定宽度，使用图标不占标题空间 */
.top-nav-back {
  position: absolute;
  left: 0;
  top: 0;
  margin-top: env(safe-area-inset-top, 0);
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: #111;
}

.top-nav-back:active {
  background: rgba(0, 0, 0, 0.04);
}

.top-nav-back-icon {
  width: 22px;
  height: 22px;
  display: block;
}

/* 标题：绝对定位左右留出 44px，水平与垂直均居中，不与返回重叠 */
.top-nav-title {
  position: absolute;
  left: 44px;
  right: 44px;
  top: env(safe-area-inset-top, 0);
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* 显示顶部导航时：内容区从导航下开始，高度为视口减去导航，避免出现整页滚动 */
body.with-topnav {
  --topnav-height: calc(44px + env(safe-area-inset-top, 0px));
  --app-content-height: calc(100vh - var(--topnav-height));
}

body.with-topnav #app {
  padding-top: var(--topnav-height);
  height: 100vh;
  min-height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
}

#app {
  height: 100vh;
  box-sizing: border-box;
}

.page {
  padding: 0px;
}

.spa-error {
  padding: 16px;
  color: #c00;
}

/* 路由加载过程全局 loading */
.spa-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
}

.spa-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spa-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #eee;
  border-top-color: #1989fa;
  border-radius: 50%;
  animation: spa-loading-spin 0.8s linear infinite;
}

@keyframes spa-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.spa-loading-text {
  font-size: 14px;
  color: #666;
}

/* 全局 API loading 遮罩（参照 WH5 LoadingOverlay / api.css） */
.api-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20000;
  display: none;
  align-items: center;
  justify-content: center;
}

.api-loading-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  pointer-events: auto;
  cursor: wait;
}

.api-loading-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background-color: rgba(0, 0, 0, 0.8);
  padding: 24px 28px;
  border-radius: 10px;
  min-width: 130px;
}

.api-loading-spinner {
  display: block;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spa-loading-spin 0.8s linear infinite;
}

.api-loading-text {
  font-size: 14px;
  color: #fff;
  text-align: center;
}

/* 全局确认/提示弹窗（替代 window.confirm / window.alert） */
.app-confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25000;
  display: none;
  align-items: center;
  justify-content: center;
}

.app-confirm-mask {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.app-confirm-panel {
  position: relative;
  z-index: 1;
  width: 300px;
  max-width: calc(100vw - 48px);
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.app-confirm-msg {
  padding: 24px 20px 18px;
  font-size: 15px;
  line-height: 1.6;
  color: #333;
  text-align: left;
  word-break: break-word;
}

.app-confirm-actions {
  display: flex;
  border-top: 1px solid #eee;
}

.app-confirm-btn {
  flex: 1;
  height: 48px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-confirm-btn:active {
  background: rgba(0, 0, 0, 0.04);
}

.app-confirm-cancel {
  color: #999;
  border-right: 1px solid #eee;
}

.app-confirm-ok {
  color: #1989fa;
  font-weight: 600;
}

.app-confirm-ok-full {
  border-right: none;
}