/* ============ 明燕智讯 PWA · 全局设计变量 ============
 * 从 app.wxss 转换 (rpx→px: rpx/2, 基于 375px 视口)
 */

/* wx:if hidden elements — kept in DOM, hidden by CSS */
[data-wx-if-hidden="1"] { display: none !important; }

:root {
  --color-primary: #1a1a2e;
  --color-primary-light: #2a2a4e;
  --color-primary-dark: #0f0f1e;
  --color-accent: #4a90ff;
  --color-accent-light: #6ba7ff;

  --color-gold: #ffd700;
  --color-success: #00c896;
  --color-danger: #ff4d4f;
  --color-warning: #faad14;

  --color-text-primary: #ffffff;
  --color-text-secondary: #bcd1ff;
  --color-text-tertiary: #8a9bb8;
  --color-text-disabled: #5a6b88;

  --color-bg-card: rgba(255, 255, 255, 0.06);
  --color-bg-card-hover: rgba(255, 255, 255, 0.1);
  --color-border: rgba(255, 255, 255, 0.12);
  --color-border-strong: rgba(255, 255, 255, 0.2);

  --fs-h1: 24px;
  --fs-h2: 18px;
  --fs-h3: 14px;
  --fs-body: 13px;
  --fs-caption: 11px;

  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
  --radius-pill: 999px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;

  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ============ Reset ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0e1a;
  color: var(--color-text-primary);
  font-size: var(--fs-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

a { color: var(--color-accent); text-decoration: none; }
input, button, textarea { font-family: inherit; outline: none; border: none; background: none; }
button { cursor: pointer; -webkit-appearance: none; }

/* 小程序 scroll-view → Web 水平滚动 */
[scroll-x] {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
[scroll-x]::-webkit-scrollbar { display: none; }

/* ============ 工具类 ============ */
.app-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
}

.app-text-primary { color: var(--color-text-primary); }
.app-text-secondary { color: var(--color-text-secondary); }
.app-text-tertiary { color: var(--color-text-tertiary); }
.app-text-gold { color: var(--color-gold); }
.app-text-success { color: var(--color-success); }
.app-text-danger { color: var(--color-danger); }

.app-h1 { font-size: var(--fs-h1); font-weight: 700; }
.app-h2 { font-size: var(--fs-h2); font-weight: 600; }
.app-h3 { font-size: var(--fs-h3); font-weight: 600; }
.app-body { font-size: var(--fs-body); }
.app-caption { font-size: var(--fs-caption); }

.app-pressable {
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.app-pressable:active {
  transform: scale(0.97);
  background: var(--color-bg-card-hover);
}

/* ============ Toast / Loading / Modal ============ */

.wx-toast {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.85); color: #fff;
  padding: 12px 24px; border-radius: 8px;
  font-size: 14px; z-index: 9999;
  display: flex; align-items: center; gap: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.wx-toast.show { opacity: 1; }
.toast-icon { font-size: 18px; }

.wx-loading {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 9998;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.wx-loading.show { opacity: 1; }
.wx-loading .loading-spinner-wrap {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #64b5f6;
  border-radius: 50%;
  animation: wx-spin 0.8s linear infinite;
  margin-bottom: 16px;
}
.loading-text { color: #fff; font-size: 14px; }

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

/* Modal (we use native confirm() as fallback, but also have CSS version) */
.wx-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 10000;
  display: none; align-items: center; justify-content: center;
}
.wx-modal-overlay.show { display: flex; }
.wx-modal-box {
  background: #1a1f3a; border-radius: 12px;
  padding: 24px; min-width: 280px; max-width: 320px;
  border: 1px solid rgba(255,255,255,0.1);
}
.wx-modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.wx-modal-content { font-size: 14px; color: #94a3b8; margin-bottom: 20px; line-height: 1.5; }
.wx-modal-btns { display: flex; gap: 12px; justify-content: flex-end; }
.wx-modal-btn {
  padding: 8px 20px; border-radius: 6px; font-size: 14px;
}
.wx-modal-btn.confirm { background: #4a90ff; color: #fff; }
.wx-modal-btn.cancel { background: rgba(255,255,255,0.1); color: #fff; }

/* ============ 通用动画 ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ SPA 页面容器 ============ */
#app-container {
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* 桌面端：给页面容器加手机壳效果 */
@media (min-width: 520px) {
  body {
    background: #050812;
  }
  #app-container {
    border-left: 1px solid rgba(255,255,255,0.06);
    border-right: 1px solid rgba(255,255,255,0.06);
  }
}

/* 页面加载 */
.page-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.page-loading .loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(100,150,255,0.15);
  border-top-color: #64b5f6;
  border-radius: 50%;
  animation: wx-spin 0.8s linear infinite;
}

.page-404 {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; color: #64748b; font-size: 16px;
}
.page-404 small { font-size: 12px; margin-top: 8px; color: #475569; }
