/* ============================================================
   ContentFlow H5 外壳样式
   ------------------------------------------------------------
   这里只放「浏览器环境需要、小程序里不存在」的东西：

     1. 外壳布局：导航栏 / 页面容器 / 底部 tabBar
        （小程序的导航栏和 tabBar 由微信客户端提供，网页里得自己搭）
     2. 弹层定位：小程序里 fixed 的弹层改成相对外壳的 absolute，
        桌面浏览器下居中显示时才不会铺满整屏
     3. H5 自建组件：toast / modal / loading / 客服弹层
     4. 小程序标签的等价物：scroll-view、picker（覆盖式原生日期输入）
     5. 表单元素兜底重置

   注意：页面自身的样式全部来自 assets/pages/*.css（由 wxss 自动转换），
   布局结构全部来自 wxml 编译产物 —— 这一层只补浏览器独有的部分。
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: #0b1220;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- 外壳 ---------- */
/* max-width 收在 420px：小程序按 375 逻辑宽设计，太宽的容器会把卡片拉松 */
.app-shell {
  position: relative;
  height: 100vh;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f172a;
}
@supports (height: 100dvh) { .app-shell { height: 100dvh; } }
@media (min-width: 481px) {
  .app-shell { box-shadow: 0 0 60px rgba(0, 0, 0, .55); }
}

/* ---------- 顶部导航（= 小程序 navigationBar） ---------- */
.app-nav {
  flex-shrink: 0;
  height: 48px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #0f172a;
  border-bottom: 1px solid rgba(51, 65, 85, .55);
  z-index: 50;
}
.app-nav .nav-title {
  font-size: 16px;
  font-weight: 600;
  color: #f1f5f9;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-nav .nav-back {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 8px;
  user-select: none;
}
.app-nav .nav-back:active { background: rgba(148, 163, 184, .12); }
.app-nav .nav-back.hide { display: none; }

/* ---------- 页面区（= 小程序的 page） ----------
   每个页面是一个绝对定位的滚动容器：切换页面时旧页面保留，
   返回时滚动位置还在，和微信里一致。 */
.app-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0f172a;
}
#page-stack { position: absolute; inset: 0; }
.wx-page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: none;
}
.wx-page.on { display: block; }
.wx-page::-webkit-scrollbar { width: 0; }

/* ---------- 底部 tabBar（= app.json 的 tabBar，纯文字无图标） ---------- */
.app-tabbar {
  flex-shrink: 0;
  display: none;
  height: 52px;
  padding-bottom: env(safe-area-inset-bottom);
  background: #111827;
  border-top: 1px solid #1f2937;
}
.app-tabbar.show { display: flex; }
.app-tabbar .tb {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  user-select: none;
}
.app-tabbar .tb.on { color: #3b82f6; font-weight: 500; }

/* ============================================================
   小程序标签 / 能力的等价物
   ============================================================ */

/* scroll-view scroll-x → 横向滚动容器 */
.wx-scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.wx-scroll-x::-webkit-scrollbar { height: 0; }

/* picker → 覆盖一层原生 date/time 输入，视觉外壳仍是 wxml 的子树 */
.wx-picker { position: relative; }
.wx-picker-input {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  background: none;
  padding: 0;
  z-index: 2;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* 输入框占位符颜色（小程序用 placeholder-style / placeholder-class 指定） */
[data-ph]::placeholder { color: var(--wx-ph, #475569); }

/* 按钮禁用 / 加载态（小程序 button 的 disabled / loading 属性） */
[data-disabled="true"] { opacity: .5; pointer-events: none; }
[data-loading="true"] { pointer-events: none; }
[data-loading="true"]::after {
  content: '';
  display: inline-block;
  width: 11px; height: 11px;
  margin-left: 7px;
  vertical-align: -1px;
  border: 1.6px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.wx-hidden { display: none !important; }

/* ============================================================
   弹层：relative to shell（覆盖页面 css 里的 fixed）
   ============================================================ */
.mask, .pay-mask {
  position: absolute !important;
  inset: 0;
}
.sheet, .pay-sheet {
  position: absolute !important;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 82%;
  overflow-y: auto;
}
.sheet { display: none; }
.sheet.show { display: block; }

/* ---------- toast ---------- */
#toast-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9999;
}
.toast {
  max-width: 70%;
  padding: 13px 20px;
  border-radius: 10px;
  background: rgba(15, 23, 42, .94);
  border: 1px solid rgba(59, 130, 246, .35);
  color: #e2e8f0;
  font-size: 13.5px;
  line-height: 1.6;
  text-align: center;
  box-shadow: 0 10px 32px rgba(0, 0, 0, .45);
  animation: toastIn .18s ease-out;
}
.toast .t-ok { color: #34d399; font-weight: 700; margin-right: 6px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* ---------- modal ---------- */
#modal-wrap {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .6);
  z-index: 9998;
  padding: 24px;
}
#modal-wrap.show { display: flex; }
.modal {
  width: 100%;
  max-width: 320px;
  max-height: 82vh;
  overflow-y: auto;
  background: #1e293b;
  border-radius: 14px;
  padding: 22px 20px 8px;
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}
.modal-title { font-size: 16px; font-weight: 600; color: #f1f5f9; text-align: center; }
.modal-text {
  font-size: 13.5px;
  color: #94a3b8;
  line-height: 1.75;
  margin-top: 12px;
  text-align: center;
  white-space: pre-wrap;
  max-height: 44vh;
  overflow-y: auto;
}
.modal-input {
  margin-top: 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 11px 12px;
  color: #e2e8f0;
  font-size: 15px;
  width: 100%;
  outline: none;
  font-family: inherit;
  resize: none;
}
.modal-btns {
  display: flex;
  margin-top: 18px;
  border-top: 1px solid rgba(51, 65, 85, .7);
}
.modal-btns > div {
  flex: 1;
  text-align: center;
  padding: 14px 0;
  font-size: 15px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}
.modal-btns > div:active { background: rgba(148, 163, 184, .08); }
.modal-btns > div.primary { color: #60a5fa; font-weight: 600; }
.modal-btns > div.danger { color: #f87171; font-weight: 600; }
.modal-btns > div + div { border-left: 1px solid rgba(51, 65, 85, .7); }

/* 操作表（wx.showActionSheet）：竖排选项 */
.modal-btns.col-btns { flex-direction: column; }
.modal-btns.col-btns > div + div { border-left: none; border-top: 1px solid rgba(51, 65, 85, .7); }
.modal-btns.col-btns > div.cancel-item { color: #64748b; }

/* 客服弹层（open-type="contact" 的降级） */
.kf-body { margin-top: 14px; }
.c-row {
  font-size: 13.5px;
  color: #cbd5e1;
  line-height: 1.8;
  padding: 11px 0;
  border-bottom: 1px solid rgba(51, 65, 85, .5);
  cursor: pointer;
}
.c-row:last-child { border-bottom: none; }
.c-row b { color: #60a5fa; }
.c-row .c-act { float: right; font-size: 12px; color: #64748b; }

/* ---------- 加载遮罩 ---------- */
#loading-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9997;
  pointer-events: none;
}
.loading-box {
  padding: 18px 22px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .95);
  border: 1px solid rgba(59, 130, 246, .3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.loading-spin {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(96, 165, 250, .25);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 12.5px; color: #94a3b8; }

/* ---------- 表单元素兜底 ----------
   小程序的 input/textarea 没有浏览器默认样式，这里只补最小限度的可读性；
   页面自己的 .inp / .input 类会覆盖（page css 在 h5.css 之后加载）。 */
input, textarea {
  font-family: inherit;
  font-size: 16px;          /* 16px 以下 iOS 会自动放大页面 */
  color: #e2e8f0;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 7px;
  padding: 12px;
  width: 100%;
  outline: none;
  resize: none;
  -webkit-appearance: none;
  appearance: none;
}
input::placeholder, textarea::placeholder { color: #475569; }
input:focus, textarea:focus { border-color: #3b82f6; }
input[type="date"], input[type="time"] { color-scheme: dark; }

/* 小程序 button 渲染成 div，补一个指针手势 */
.btn-primary, .btn-ghost, .btn-main, .btn-wx, .contact-btn, .service-btn, .remind-opt { cursor: pointer; }

/* ---------- 图片：没有配置图源时给个提示框，避免大片空白 ---------- */
img { background: #fff; }
img.kf-qr, img.pay-qr {
  width: 180px;
  height: 180px;
  object-fit: contain;
  margin: 16px auto 0;
  padding: 6px;
  border-radius: 8px;
  display: block;
}

/* 长按删除的提示：避免移动端弹出系统菜单 */
.sched-item { -webkit-touch-callout: none; }
