/* ============================================
   统一布局：微信 / PWA桌面 / 浏览器 三种模式一致
   基准：微信内置浏览器 44px 顶栏 + 无底部栏
   ============================================ */

/* CSS 变量：各模式下的顶部偏移 */
:root {
  --app-top-offset: 0px;
  --app-bottom-offset: 0px;
}

/* 微信浏览器：微信自带 44px 导航栏，不需要额外 padding */
body.wechat-browser {
  --app-top-offset: 0px;
}

/* PWA standalone 模式：需要模拟微信的 44px 顶栏 + iOS 安全区 */
@media (display-mode: standalone) {
  :root {
    --app-top-offset: calc(44px + env(safe-area-inset-top, 0px));
    --app-bottom-offset: env(safe-area-inset-bottom, 0px);
  }
  body {
    padding-top: var(--app-top-offset) !important;
    padding-bottom: var(--app-bottom-offset) !important;
    /* 背景色填充顶部安全区 */
    background-color: #059669;
  }
}

/* 普通移动浏览器 */
@media (display-mode: browser) and (max-width: 768px) {
  :root {
    --app-top-offset: 0px;
    --app-bottom-offset: 0px;
  }
}

/* ===== 全局安全区域适配 ===== */
#root {
  min-height: calc(100vh - var(--app-top-offset) - var(--app-bottom-offset));
  background: #f1f5f9;
}

/* ===== 微信专用修复 ===== */
body.wechat-browser {
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
body.wechat-browser * {
  -webkit-text-size-adjust: 100% !important;
  max-height: 999999px;
}
body.wechat-browser input,
body.wechat-browser textarea,
body.wechat-browser [contenteditable] {
  -webkit-user-select: auto;
  user-select: auto;
}

/* ===== 全局防缩放 ===== */
html {
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}

/* ===== PWA 安装引导弹窗 ===== */
#pwa-install-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); z-index: 99999;
  display: flex; align-items: center; justify-content: center;
  animation: pwa-fade-in 0.25s ease;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px) 16px;
}
@keyframes pwa-fade-in { from { opacity: 0; } to { opacity: 1; } }

.pwa-guide-card {
  background: #fff; border-radius: 16px; padding: 28px 24px 24px;
  max-width: 360px; width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: pwa-slide-up 0.3s ease;
}
@keyframes pwa-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.pwa-guide-icon { font-size: 48px; margin-bottom: 12px; }
.pwa-guide-card h3 { font-size: 18px; color: #1a1a1a; margin: 0 0 8px; font-weight: 600; }
.pwa-guide-card > p { font-size: 14px; color: #666; margin: 0 0 20px; }

.pwa-guide-steps { text-align: left; margin-bottom: 20px; }
.pwa-guide-steps .step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid #f0f0f0;
  font-size: 14px; color: #333;
}
.pwa-guide-steps .step:last-child { border-bottom: none; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: #059669; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.pwa-guide-btn {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; cursor: pointer;
  background: #f0f0f0; color: #333;
}
.pwa-guide-btn.primary { background: #059669; color: #fff; }
