/**
 * weui-page-common.css
 * ─────────────────────────────────────────────
 * Phase 1 + 2：从 example.css 提取后再适配业务页的公共样式
 *
 * 设计原则：
 *  1. 所有值优先引用 design-tokens.css 的 CSS 变量
 *  2. 不依赖 SPA hash 路由，适配 PHP 多页面结构
 *  3. 仅补充 weui.min.css 未覆盖的容器/节奏/动效细节
 *  4. 全局适用，不与页面专属样式冲突
 *
 * 目录：
 *  A. 页面骨架 & 安全区
 *  B. 区块标题 & 说明文字
 *  C. 卡片 & 分组增强
 *  D. 消息/结果反馈页
 *  E. 固定底部 CTA
 *  F. 轻入场动画
 *  G. 表单公共增强
 *  H. Footer 公共增强
 *  I. 暗色模式统一修正
 * ─────────────────────────────────────────────
 */


/* ============================================================
   A. 页面骨架 & 安全区
   — 来源：example.css .page / .container 核心思路
   ============================================================ */

/* WeUI page skeleton compatibility: moved from inline base.php
   Provides common page container and main content area for public shells. */
.weui-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: var(--weui-BG-0);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.weui-page__bd {
    flex: 1;
    width: 100%;
}

.weui-page__bd--spaced {
    padding-left: var(--weui-spacing-page);
    padding-right: var(--weui-spacing-page);
}

/* Navbar & tab wrappers will reserve space in page body */
.weui-page--with-navbar {
    padding-top: calc(env(safe-area-inset-top) + 44px);
}

.weui-page--with-tab {
    padding-bottom: calc(env(safe-area-inset-bottom) + 50px);
}

/**
 * .wxc-page：业务页通用外壳
 * 替代 example.css 的 .page（避免命名冲突），
 * 功能保留：safe-area / 全屏高度 / 纵向布局
 */
.wxc-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background-color: var(--weui-BG-0);
    box-sizing: border-box;
    /* Safe-area via env() — 兼容 iOS / Harmony */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Sticky/fixed 场景中内容区自动填充剩余空间 */
.wxc-page__bd {
    flex: 1;
    width: 100%;
}

/* 标准内容左右留白 */
.wxc-page__bd--spaced {
    padding-left: var(--weui-spacing-page);
    padding-right: var(--weui-spacing-page);
}

/* 页面顶部固定标题栏占位 */
.wxc-page--with-navbar {
    padding-top: calc(env(safe-area-inset-top) + 44px);
}

/* 页面底部固定操作区占位 */
.wxc-page--with-tab {
    padding-bottom: calc(env(safe-area-inset-bottom) + 50px);
}


/* ============================================================
   B. 区块标题 & 说明文字
   — 来源：example.css .page__title / .page__desc
   ============================================================ */

/* 页级主标题 */
.wxc-section__title {
    font-size: var(--weui-font-size-body);
    font-weight: var(--weui-font-weight-semibold);
    color: var(--weui-FG-0);
    line-height: var(--weui-line-height-tight);
    margin: 0;
}

/* 区块副标题（section 级别）*/
.wxc-section__subtitle {
    font-size: var(--weui-font-size-small);
    font-weight: var(--weui-font-weight-medium);
    color: var(--weui-FG-1);
    margin-top: var(--weui-spacing-xxs);
    line-height: var(--weui-line-height-relaxed);
}

/* 区块说明文字（描述) */
.wxc-section__desc {
    font-size: var(--weui-font-size-small);
    color: var(--weui-FG-1);
    line-height: var(--weui-line-height-relaxed);
    margin-top: var(--weui-spacing-xs);
}

/* 区块头部容器（包含标题+说明）*/
.wxc-section__hd {
    padding: var(--weui-spacing-xl) var(--weui-spacing-page) var(--weui-spacing-xs);
}

/**
 * WeUI 原生 .weui-cells__title 增强
 * — 来源：example.css .page__title 排版节奏
 * 加上品牌绿竖线指示器
 */
.weui-cells__title {
    position: relative;
    padding-left: calc(var(--weui-spacing-page) + 10px);
    font-size: var(--weui-font-size-small);
    font-weight: var(--weui-font-weight-semibold);
    color: var(--weui-FG-0);
    letter-spacing: 0.2px;
}

.weui-cells__title::before {
    content: '';
    position: absolute;
    left: var(--weui-spacing-page);
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 14px;
    background: var(--weui-BRAND);
    border-radius: var(--weui-radius-full);
}


/* ============================================================
   C. 卡片 & 分组增强
   — 来源：example.css .page .weui-cells 节奏
   ============================================================ */

/**
 * WeUI 卡片分组统一增强
 * 圆角 / 轻阴影 / 白底 / 呼吸间距
 */
.weui-cells {
    border-radius: var(--weui-radius-xl);
    overflow: hidden;
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.04),
        0 4px 16px rgba(0, 0, 0, 0.05);
    margin-left: var(--weui-spacing-sm);
    margin-right: var(--weui-spacing-sm);
    background: var(--weui-BG-2);
}

/* 标准 cell 行间距 */
.weui-cell {
    padding: var(--weui-spacing-sm) var(--weui-spacing-md);
    min-height: 48px; /* 满足最小触摸热区 */
    align-items: center;
}

/* 选中/聚焦态——轻背景高亮（适用 active 伪类） */
.weui-cell_active:active {
    background-color: var(--weui-BG-1);
    transition: background-color 80ms ease;
}

/* 嵌套 radio/checkbox 分组—去掉多余阴影 */
.weui-cell .weui-cells {
    box-shadow: none;
    margin: 0;
    border-radius: 0;
}

/* 卡片标签（state badge）—— pill 形 */
.weui-badge {
    border-radius: var(--weui-radius-full);
    font-size: 11px;
    font-weight: var(--weui-font-weight-semibold);
    padding: 2px 7px;
    line-height: 1.4;
    vertical-align: middle;
}

/* 品牌色推荐 badge */
.weui-badge--brand {
    background: var(--weui-BRAND);
    color: var(--weui-WHITE);
}

/* 警告 badge */
.weui-badge--warn {
    background: var(--weui-WARN);
    color: var(--weui-WHITE);
}

/* cell 描述文字 */
.weui-cell__desc {
    font-size: var(--weui-font-size-small);
    color: var(--weui-FG-1);
    line-height: var(--weui-line-height-relaxed);
    margin-top: 2px;
}

/* cell 头部图标标准尺寸 */
.weui-cell__hd img,
.weui-cell__hd .wxc-icon {
    width: 24px;
    height: 24px;
    display: block;
    border-radius: var(--weui-radius-sm);
    margin-right: var(--weui-spacing-sm);
}


/* ============================================================
   D. 消息/结果反馈页
   — 来源：example.css .page.msg / .page.msg_success
   ============================================================ */

/**
 * .wxc-result：成功/错误/空状态通用容器
 * 适用于购买成功页、错误页等
 */
.wxc-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: var(--weui-spacing-xxl) var(--weui-spacing-page);
    text-align: center;
}

.wxc-result__icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: var(--weui-spacing-lg);
}

.wxc-result__title {
    font-size: var(--weui-font-size-h2);
    font-weight: var(--weui-font-weight-bold);
    color: var(--weui-FG-0);
    margin-bottom: var(--weui-spacing-sm);
}

.wxc-result__desc {
    font-size: var(--weui-font-size-body);
    color: var(--weui-FG-1);
    line-height: var(--weui-line-height-relaxed);
    max-width: 280px;
}

.wxc-result__actions {
    margin-top: var(--weui-spacing-xl);
    width: 100%;
}


/* ============================================================
   E. 固定底部 CTA
   — 来源：example.css .weui-bottom-fixed-opr-page 思路
   ============================================================ */

/**
 * .wxc-bottom-bar：固定底部操作区
 * 含安全区留白、毛玻璃背景
 */
.wxc-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: var(--weui-spacing-sm) var(--weui-spacing-page);
    padding-bottom: calc(var(--weui-spacing-sm) + env(safe-area-inset-bottom));
    background: var(--weui-BG-2);
    box-shadow: 0 -1px 0 var(--weui-FG-3), 0 -4px 16px rgba(0, 0, 0, 0.05);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* 底部操作区高度占位（使内容不被遮挡）*/
.wxc-bottom-bar-placeholder {
    height: calc(64px + env(safe-area-inset-bottom));
}

/* 底部 CTA 按钮 — 渐变绿 + 强阴影 */
.wxc-bottom-bar .weui-btn_primary {
    background: linear-gradient(135deg, var(--weui-BRAND) 0%, #05a84f 100%);
    border: none;
    border-radius: var(--weui-radius-full);
    font-weight: var(--weui-font-weight-bold);
    font-size: var(--weui-font-size-body);
    min-height: var(--weui-BTN-HEIGHT);
    box-shadow: 0 4px 14px rgba(7, 193, 96, 0.35);
    letter-spacing: 0.5px;
}

.wxc-bottom-bar .weui-btn_primary:active {
    box-shadow: 0 2px 6px rgba(7, 193, 96, 0.25);
    transform: translateY(1px);
}

/* 次要按钮 */
.wxc-bottom-bar .weui-btn_default {
    background: transparent;
    border: 1px solid var(--weui-FG-3);
    border-radius: var(--weui-radius-full);
    color: var(--weui-FG-0);
    font-size: var(--weui-font-size-body);
    min-height: var(--weui-BTN-HEIGHT);
}

/* 协议勾选行 */
.wxc-bottom-bar .weui-agree {
    font-size: var(--weui-font-size-small);
    color: var(--weui-FG-1);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: var(--weui-spacing-xs);
}

.wxc-bottom-bar .weui-agree a {
    color: var(--weui-LINK);
}


/* ============================================================
   F. 轻入场动画
   — 来源：example.css slideIn/slideOut keyframes（只保留淡入上移，不保留 hash 路由切换）
   ============================================================ */

@keyframes wxc-fade-in-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wxc-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes wxc-scale-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* 入场动画工具类 */
.wxc-animate-in {
    animation: wxc-fade-in-up var(--weui-duration-normal, 0.25s) ease-out both;
}

.wxc-animate-in--fast {
    animation-duration: var(--weui-duration-fast, 0.15s);
}

.wxc-animate-in--slow {
    animation-duration: 0.4s;
}

/* 子项延迟动画（表单分组逐行入场）*/
.wxc-animate-in--delay-1 { animation-delay: 0.05s; }
.wxc-animate-in--delay-2 { animation-delay: 0.10s; }
.wxc-animate-in--delay-3 { animation-delay: 0.15s; }
.wxc-animate-in--delay-4 { animation-delay: 0.20s; }

/* 页面内容区通用入场 */
.wxc-page__bd {
    animation: wxc-fade-in-up 0.25s ease-out both;
}

/* 卡片弹出动画 */
.wxc-card-enter {
    animation: wxc-scale-in 0.2s ease-out both;
}


/* ============================================================
   G. 表单公共增强
   — 细节来源：example.css 的 form 类页面节奏
   ============================================================ */

/* 表单内容区标准边距 */
.weui-form .weui-form__bd {
    padding-bottom: var(--weui-spacing-lg);
}

/* 表单 label 宽度统一（3.5em 适配4字标签）*/
.weui-cells_form .weui-label {
    min-width: 3.5em;
    font-size: var(--weui-font-size-body);
    font-weight: var(--weui-font-weight-medium);
    color: var(--weui-FG-0);
    white-space: nowrap;
}

/* 表单底部说明文字 */
.weui-cells__tips {
    font-size: var(--weui-font-size-mini);
    color: var(--weui-FG-2);
    padding: var(--weui-spacing-xs) var(--weui-spacing-page);
    line-height: var(--weui-line-height-relaxed);
    margin-left: var(--weui-spacing-sm);
    margin-right: var(--weui-spacing-sm);
}

/* 表单警告提示 */
.weui-cells__tips_warn {
    color: var(--weui-WARN);
}

/* Input placeholder */
.weui-input::placeholder,
.weui-textarea::placeholder {
    color: var(--weui-FG-2);
    font-size: var(--weui-font-size-body);
}

/* Input focus 视觉反馈 */
.weui-input:focus,
.weui-textarea:focus {
    outline: none;
}

/* 图片上传格子 */
.weui-uploader__file {
    border-radius: var(--weui-radius-md);
    overflow: hidden;
}

.weui-uploader__input-box {
    border-radius: var(--weui-radius-md);
    border-color: var(--weui-FG-3);
    transition: border-color 0.15s ease;
}

.weui-uploader__input-box:active {
    border-color: var(--weui-BRAND);
}

/* details/summary 折叠面板 */
details.weui-cells > summary.weui-cell {
    cursor: pointer;
    list-style: none;
}

details.weui-cells > summary.weui-cell::marker,
details.weui-cells > summary.weui-cell::-webkit-details-marker {
    display: none;
}

details.weui-cells > summary.weui-cell .weui-cell__ft::after {
    content: '▾';
    font-size: 12px;
    color: var(--weui-FG-2);
    transition: transform 0.2s ease;
}

details[open].weui-cells > summary.weui-cell .weui-cell__ft::after {
    transform: rotate(180deg);
}

/* 弹窗遮罩毛玻璃 */
.weui-mask {
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

/* Dialog 圆角 */
.weui-dialog {
    border-radius: var(--weui-radius-xl);
    overflow: hidden;
}

/* Half-screen dialog 顶部圆角 */
.weui-half-screen-dialog {
    border-radius: var(--weui-HALFSCREEN-RADIUS, 16px) var(--weui-HALFSCREEN-RADIUS, 16px) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}


/* ============================================================
   H. Footer 公共增强
   — 来源：example.css .page__ft 节奏
   ============================================================ */

.weui-footer {
    padding: var(--weui-spacing-xl) var(--weui-spacing-page);
    padding-bottom: calc(var(--weui-spacing-xl) + env(safe-area-inset-bottom));
    text-align: center;
}

.weui-footer__text {
    font-size: var(--weui-font-size-mini);
    color: var(--weui-FG-2);
    line-height: var(--weui-line-height-relaxed);
    margin-bottom: var(--weui-spacing-xxs);
}

.weui-footer__link {
    font-size: var(--weui-font-size-mini);
    color: var(--weui-FG-2);
}

.weui-footer__link:active {
    color: var(--weui-BRAND);
}

/* Footer 上方渐变分隔线 */
.wxc-footer-divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--weui-FG-3) 25%,
        var(--weui-FG-3) 75%,
        transparent
    );
    margin: 0 var(--weui-spacing-xxl);
}


/* ============================================================
   I. 暗色模式统一修正
   ============================================================ */

@media (prefers-color-scheme: dark) {
    .weui-cells {
        box-shadow:
            0 1px 4px rgba(0, 0, 0, 0.2),
            0 4px 16px rgba(0, 0, 0, 0.25);
    }

    .wxc-bottom-bar {
        box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.1), 0 -4px 16px rgba(0, 0, 0, 0.3);
        background: rgba(var(--weui-BG-2-rgb, 28, 28, 30), 0.92);
    }

    .weui-dialog {
        background: var(--weui-BG-2);
    }

    .wxc-bottom-bar .weui-btn_primary {
        box-shadow: 0 4px 14px rgba(7, 193, 96, 0.25);
    }
}


/* ============================================================
   J. 无障碍 & 降级
   ============================================================ */

/* 尊重减弱动效偏好 */
@media (prefers-reduced-motion: reduce) {
    .wxc-animate-in,
    .wxc-card-enter,
    .wxc-page__bd {
        animation: none !important;
    }

    .weui-cell_active:active,
    .wxc-bottom-bar .weui-btn_primary:active {
        transition: none !important;
        transform: none !important;
    }
}
/* Page Header — moved from page-header.php (shared) */
.wxc-page-header {
    position: relative;
    background: linear-gradient(165deg, var(--weui-BRAND) 0%, #05a045 100%);
    color: var(--weui-WHITE);
    padding: calc(env(safe-area-inset-top) + 40px) 24px 36px;
    text-align: center;
    border-radius: 0 0 24px 24px;
    overflow: hidden;
}

/* ── Ambient shapes — softer, larger, slower drift ── */
.wxc-page-header__bg-shapes {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.wxc-page-header__shape {
    position: absolute;
    border-radius: 50%;
    background: var(--weui-WHITE);
    opacity: 0.08;
    will-change: transform;
}

.wxc-page-header__shape--1 {
    width: 180px;
    height: 180px;
    top: -60px;
    right: -40px;
    animation: wxc-header-float 8s ease-in-out infinite alternate;
}

.wxc-page-header__shape--2 {
    width: 100px;
    height: 100px;
    bottom: -30px;
    left: -20px;
    animation: wxc-header-float 10s ease-in-out 1s infinite alternate-reverse;
}

.wxc-page-header__shape--3 {
    width: 60px;
    height: 60px;
    top: 20%;
    left: 60%;
    opacity: 0.05;
    animation: wxc-header-float 12s ease-in-out 2s infinite alternate;
}

@keyframes wxc-header-float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(8px, -6px) scale(1.05); }
}

/* ── Content layer ── */
.wxc-page-header__content {
    position: relative;
    z-index: 1;
    animation: wxc-header-fadeIn 500ms ease-out both;
}

@keyframes wxc-header-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Icon — frosted glass pill ── */
.wxc-page-header__icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: wxc-header-fadeIn 500ms ease-out 100ms both;
}

.wxc-page-header__icon {
    display: block;
    font-size: 28px;
    line-height: 1;
}

/* ── Title — tighter, lighter ── */
.wxc-page-header__title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin: 0 0 6px;
    animation: wxc-header-fadeIn 500ms ease-out 150ms both;
}

/* ── Subtitle — whisper weight ── */
.wxc-page-header__desc {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.75;
    margin: 0;
    letter-spacing: 0.01em;
    line-height: 1.5;
    animation: wxc-header-fadeIn 500ms ease-out 250ms both;
}

/* ── Reduce motion preference ── */
@media (prefers-reduced-motion: reduce) {
    .wxc-page-header__shape--1,
    .wxc-page-header__shape--2,
    .wxc-page-header__shape--3,
    .wxc-page-header__content,
    .wxc-page-header__icon-wrap,
    .wxc-page-header__title,
    .wxc-page-header__desc {
        animation: none;
    }
}

/* Section Header — moved from section-header.php to shared CSS */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 16px 8px;
    margin: 0;
    line-height: 1;
}

.section-header__leading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.section-header__bar {
    display: block;
    width: 3px;
    height: 14px;
    border-radius: 9999px;
    background: var(--weui-BRAND);
    flex-shrink: 0;
    opacity: .85;
}

.section-header__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--weui-FG-0);
    letter-spacing: .02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-header .section-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.section-header .section-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--weui-FG-2);
    letter-spacing: .01em;
    white-space: nowrap;
    flex-shrink: 0;
    margin: 0;
    padding: 2px 8px;
    background: var(--weui-BG-2);
    border-radius: 9999px;
    transition: opacity 150ms ease;
}
