/* ============================================================
 * 全站 UI 体验升级层（v2026.10 · 增强型，非改版）
 * ------------------------------------------------------------
 * 原则：**只做加法、不改现有结构**。本文件在所有样式之后加载，
 * 仅提供「新增能力类 + 全局细节修正」，不改动任何既有布局尺寸与配色，
 * 因此不会造成视觉回退；同时补齐交付级产品必备的体验细节：
 *
 *   ① 加载骨架屏（skeleton）—— 切页/拉数据不再白屏
 *   ② 空态（empty）—— 带插画位、说明、行动按钮，不再是干巴巴四个字
 *   ③ 错误态 + 重试（error/retry）—— 网络异常可一键重试
 *   ④ 点击反馈（press）—— 所有可点元素统一按压反馈
 *   ⑤ 无障碍焦点环（focus-visible）—— 键盘/读屏可用
 *   ⑥ iOS 安全区（safe-area）—— iPhone 刘海与底部横条不被遮挡
 *   ⑦ 防重复提交（is-busy）—— 支付/下单不再被连点
 *   ⑧ App（WebView）适配 —— 状态栏/安全区/橡皮筋
 *   ⑨ 降低动效偏好（prefers-reduced-motion）
 *   ⑩ 桌面端滚动条美化（后台长时间使用更舒适）
 *
 * 使用方式：在 </head> 前引入（所有既有样式之后），全站即时生效。
 * ============================================================ */

/* ---------- ① 骨架屏 ---------- */
.xqn-skel {
  display: block;
  width: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg,
      rgba(148, 163, 184, .14) 25%,
      rgba(148, 163, 184, .26) 37%,
      rgba(148, 163, 184, .14) 63%);
  background-size: 400% 100%;
  animation: xqn-skel-shimmer 1.4s ease infinite;
}
.xqn-skel-line { height: 14px; margin: 10px 0; }
.xqn-skel-line.xqn-skel-title { height: 20px; width: 42%; }
.xqn-skel-line.xqn-skel-short { width: 62%; }
.xqn-skel-card { height: 96px; margin: 12px 0; border-radius: 14px; }
.xqn-skel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.xqn-skel-grid .xqn-skel { height: 72px; border-radius: 12px; }
@keyframes xqn-skel-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------- ② 空态 ---------- */
.xqn-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 34px 20px; text-align: center; color: var(--gray-3, var(--n-400));
}
.xqn-empty-ico {
  width: 76px; height: 76px; margin-bottom: 12px; border-radius: 24px;
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  background: linear-gradient(160deg, rgba(148, 163, 184, .16), rgba(148, 163, 184, .06));
  line-height: 1;
}
.xqn-empty-ico svg { width: 34px; height: 34px; stroke: currentColor; fill: none; }
.xqn-empty-title { font-size: 14.5px; font-weight: 700; color: var(--ink-2, var(--n-600)); margin-bottom: 5px; }
.xqn-empty-desc { font-size: 12.5px; line-height: 1.65; color: var(--gray-3, var(--n-400)); max-width: 260px; }
.xqn-empty-action {
  margin-top: 14px; padding: 9px 20px; border: 0; border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--c-surface); cursor: pointer;
  background: linear-gradient(135deg, var(--v-600, var(--brand-3)), var(--v-500, var(--brand-1)));
  box-shadow: 0 6px 16px rgba(16, 185, 129, .24);
}
.xqn-empty-action:active { transform: scale(.96); }

/* ---------- ③ 错误态 + 重试 ---------- */
.xqn-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 20px; text-align: center;
}
.xqn-error-ico { font-size: 30px; margin-bottom: 8px; line-height: 1; }
.xqn-error-title { font-size: 14px; font-weight: 700; color: var(--ink-2, var(--n-600)); margin-bottom: 4px; }
.xqn-error-desc { font-size: 12.5px; color: var(--gray-3, var(--n-400)); line-height: 1.6; margin-bottom: 14px; }
.xqn-retry-btn {
  padding: 8px 22px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line, var(--n-200)); background: var(--c-surface);
  font-size: 13px; font-weight: 700; color: var(--ink-2, var(--n-600));
  transition: background .18s ease, transform .18s ease;
}
.xqn-retry-btn:active { transform: scale(.96); background: var(--n-50); }

/* ---------- ④ 点击反馈（按压）----------
 * 只作用于带 .xqn-press / [data-xqn-press] 的元素，避免全站误改。
 * 同时为「裸 div 卡片」提供统一手感，解决此前大量卡片点击无反馈的问题。 */
.xqn-press, [data-xqn-press] {
  transition: transform .14s cubic-bezier(.34, 1.4, .64, 1), box-shadow .18s ease, opacity .18s ease;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.xqn-press:active, [data-xqn-press]:active { transform: scale(.975); opacity: .92; }
@media (hover: hover) {
  .xqn-press:hover, [data-xqn-press]:hover { box-shadow: 0 8px 22px rgba(15, 23, 42, .09); }
}

/* ---------- ⑤ 无障碍焦点环 ---------- */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--v-600, var(--brand-3));
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- ⑥ 安全区工具类 ---------- */
.xqn-safe-b { padding-bottom: env(safe-area-inset-bottom, 0px); }
.xqn-safe-t { padding-top: env(safe-area-inset-top, 0px); }
.xqn-safe-x { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
/* 全屏弹出层（底部抽屉 / 全屏 sheet）统一留出顶部与底部安全区 */
.xqn-sheet-safe {
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

/* ---------- ⑦ 防重复提交 ---------- */
.xqn-busy, [data-xqn-busy="1"] {
  pointer-events: none !important;
  opacity: .62 !important;
  filter: saturate(.7);
}
.xqn-busy::after { content: ''; }

/* ---------- ⑧ App（Capacitor WebView）适配 ----------
 * App 壳通过 <body class="xqn-app"> 声明；此时状态栏由原生接管，
 * 页面顶部需让出安全区，并禁用橡皮筋回弹（避免与原生下拉刷新冲突）。 */
body.xqn-app {
  overscroll-behavior-y: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.xqn-app input, body.xqn-app textarea, body.xqn-app [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
body.xqn-app .app-safe-top { padding-top: env(safe-area-inset-top, 0px); }
body.xqn-app .xqn-app-statusbar { height: env(safe-area-inset-top, 0px); width: 100%; }

/* ---------- ⑨ 降低动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .xqn-skel { animation: none !important; }
  .xqn-press, [data-xqn-press] { transition: none !important; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- ⑩ 桌面端滚动条（后台/工作台）---------- */
@media (min-width: 1024px) {
  ::-webkit-scrollbar { width: 9px; height: 9px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, .3); border-radius: 999px; border: 2px solid transparent;
    background-clip: content-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .5); background-clip: content-box; }
}

/* ---------- 全局细节修正（低风险）---------- */
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
img[loading="lazy"] { opacity: 0; transition: opacity .3s ease; }
img[loading="lazy"].is-loaded { opacity: 1; }
/* 长文本不撑破卡片（此前偶有长手机号/URL 顶破布局） */
.xqn-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xqn-clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 数字/金额统一等宽，避免跳动 */
.xqn-num { font-variant-numeric: tabular-nums; }

/* 弱网/离线提示条（由 ui-kit.js 注入） */
#xqn-netbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 1200;
  padding: 7px 14px; font-size: 12.5px; font-weight: 700; text-align: center;
  color: var(--c-surface); background: var(--brand-amber);
  padding-top: calc(7px + env(safe-area-inset-top, 0px));
  transform: translateY(-100%); transition: transform .28s ease;
}
#xqn-netbar.is-on { transform: translateY(0); }
#xqn-netbar.is-offline { background: var(--n-500); }

/* 全局轻提示（无 #toast 宿主的页面兜底，样式与既有 .toast 保持一致观感） */
#xqn-toast-host {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); z-index: 2000;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; max-width: 88vw;
}
#xqn-toast-host .xqn-toast {
  padding: 10px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  color: var(--c-surface); background: rgba(15, 23, 42, .9);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .22);
  animation: xqn-toast-in .22s ease;
  pointer-events: auto;
}
#xqn-toast-host .xqn-toast.t-success { background: rgba(16, 185, 129, .95); }
#xqn-toast-host .xqn-toast.t-error { background: rgba(239, 68, 68, .95); }
#xqn-toast-host .xqn-toast.t-warn { background: rgba(245, 158, 11, .95); }
@keyframes xqn-toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
