/*****************************************
 * 移动端专用样式优化
 * 针对小屏幕设备的特殊处理
 *****************************************/

    
    .form-actions {
        flex-direction: column;
        gap: var(--space-3);
        margin-top: var(--space-6);
    }
}

/* ======================================
   小屏幕设备优化 (max-width: 639px)
   ====================================== */
@media (max-width: 639px) {
    /* 整体间距调整 */
    :root {
        --space-4: 0.75rem;
        --space-6: 1rem;
        --space-8: 1.5rem;
        --space-10: 2rem;
    }
    
    /* 移动端标签切换优化 */
    .package-tabs {
        gap: var(--space-2) !important;
        padding: 0 var(--space-2) !important;
        margin-bottom: var(--space-6) !important;
    }
    
    .tab-item {
        padding: var(--space-3) !important;
        max-width: none !important;
    }
    
    .tab-icon {
        font-size: var(--text-lg) !important;
        margin-bottom: var(--space-1) !important;
    }
    
    .tab-name {
        font-size: var(--text-xs) !important;
        margin-bottom: var(--space-1) !important;
    }
    
    .tab-price {
        font-size: var(--text-sm) !important;
    }
    
    .package-content {
        min-height: 400px !important;
        padding: 0 var(--space-2) !important;
    }
    
    .package-card {
        margin: 0 !important;
        padding: var(--space-4) !important;
        min-height: 400px !important;
    }
    
    /* 头部导航优化 */
    .nav-container {
        padding: var(--space-3) 0;
    }
    
    .logo {
        font-size: var(--text-lg);
    }
    
    .logo-image {
        height: 32px;
        max-width: 150px;
    }
    
    /* 超小屏幕logo进一步优化 */
    @media (max-width: 374px) {
        .logo-image {
            height: 28px;
            max-width: 120px;
        }
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
    }
    
    /* 页面标题优化 */
    .page-header {
        margin-bottom: var(--space-8);
        padding: 0 var(--space-2);
    }
    
    .page-title {
        font-size: var(--text-2xl);
        margin-bottom: var(--space-2);
    }
    
    .page-subtitle {
        font-size: var(--text-base);
    }
    
    .page-description {
        font-size: var(--text-sm);
        padding: 0 var(--space-2);
    }
    
    /* 移动端套餐卡片优化 - 单卡片显示 */
    .package-card {
        padding: var(--space-6) !important;
        margin: 0 !important;
        border-radius: var(--radius-xl) !important;
        box-shadow: var(--shadow-lg) !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* 移动端套餐卡片内容优化 */
    .package-header {
        margin-bottom: var(--space-6) !important;
        text-align: center !important;
    }
    
    .package-name {
        font-size: var(--text-xl) !important;
        margin-bottom: var(--space-2) !important;
    }
    
    .package-description {
        font-size: var(--text-sm) !important;
        line-height: 1.5 !important;
    }
    
    .package-price {
        margin-bottom: var(--space-6) !important;
    }
    
    .price-amount {
        font-size: 2.5rem !important;
    }
    
    .package-features {
        margin-bottom: var(--space-6) !important;
    }
    
    .feature-item {
        margin-bottom: var(--space-3) !important;
        font-size: var(--text-sm) !important;
    }
    
    .feature-icon {
        width: 20px !important;
        height: 20px !important;
        font-size: var(--text-xs) !important;
    }
    
    .package-limit {
        padding: var(--space-3) !important;
        font-size: var(--text-sm) !important;
        margin-bottom: var(--space-4) !important;
    }
    
    .btn-lg {
        padding: var(--space-4) var(--space-6) !important;
        font-size: var(--text-base) !important;
        min-height: 48px !important;
        height: 48px !important;
        width: 100% !important;
    }
    
    .package-card.featured::before {
        font-size: var(--text-xs);
        padding: var(--space-1) var(--space-2);
    }
    
    .package-name {
        font-size: var(--text-lg);
    }
    
    .package-description {
        font-size: var(--text-sm);
    }
    
    .price-amount {
        font-size: 2.5rem;
    }
    
    .price-currency {
        font-size: var(--text-base);
    }
    
    .package-features {
        margin-bottom: var(--space-5);
    }
    
    .feature-item {
        margin-bottom: var(--space-2);
        font-size: var(--text-sm);
    }
    
    .feature-icon {
        width: 18px;
        height: 18px;
        font-size: var(--text-xs);
    }
    
    .package-limit {
        padding: var(--space-2);
        font-size: var(--text-xs);
        margin-bottom: var(--space-3);
    }
    
    .btn-lg {
        padding: var(--space-3) var(--space-5); /* 移动端更小内边距 */
        font-size: var(--text-base);
        min-height: 44px; /* 移动端合适的最低高度 */
        line-height: 1.1;
    }
    
    /* 支付区域优化 */
    .payment-section {
        padding: var(--space-6);
        margin: 0 var(--space-2);
    }
    
    .section-title {
        font-size: var(--text-lg);
        margin-bottom: var(--space-5);
    }
    
    .payment-methods {
        gap: var(--space-3);
    }
    
    .payment-method {
        padding: var(--space-4);
        gap: var(--space-3);
    }
    
    .method-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .method-name {
        font-size: var(--text-sm);
    }
    
    .method-desc {
        font-size: var(--text-xs);
    }
    
    .method-check {
        width: 20px;
        height: 20px;
    }
    
    /* 订单摘要优化 */
    .order-summary {
        padding: var(--space-5);
    }
    
    .summary-row {
        margin-bottom: var(--space-2);
        font-size: var(--text-sm);
    }
    
    .summary-row.total {
        font-size: var(--text-base);
    }
    
    /* 操作按钮优化 */
    .action-buttons {
        flex-direction: column;
        gap: var(--space-3);
        margin: 0 var(--space-2);
    }
    
    .btn {
        padding: var(--space-3) var(--space-5);
        font-size: var(--text-sm);
    }
    
    .btn-lg {
        padding: var(--space-4) var(--space-6);
        font-size: var(--text-base);
    }
    
    /* 用户协议优化 */
    .agreement-section {
        margin: 0 var(--space-2);
    }
    
    .agreement-text {
        font-size: var(--text-xs);
        line-height: 1.6;
    }
    
    /* 帮助区域优化 */
    .help-section {
        padding: var(--space-6);
        margin: 0 var(--space-2);
    }
    
    .help-title {
        font-size: var(--text-lg);
        margin-bottom: var(--space-4);
    }
    
    .help-grid {
        gap: var(--space-3);
    }
    
    .help-item {
        gap: var(--space-2);
    }
    
    .help-icon {
        width: 20px;
        height: 20px;
        font-size: var(--text-xs);
    }
    
    .help-question {
        font-size: var(--text-sm);
    }
    
    .help-answer {
        font-size: var(--text-xs);
    }
    
    /* 页脚优化 */
    .footer {
        padding: var(--space-6) 0;
    }
    
    .footer-links {
        flex-direction: column;
        gap: var(--space-2);
        margin-bottom: var(--space-3);
    }
    
    .footer-content p {
        font-size: var(--text-xs);
        margin-bottom: var(--space-1);
    }
    
    /* 容器优化 */
    .container {
        padding: 0 var(--space-3);
    }
    
    .main-content {
        padding: var(--space-4) 0;
    }
}

/* ======================================
   超小屏幕设备优化 (max-width: 374px)
   ====================================== */
@media (max-width: 374px) {
    /* 字体大小调整 */
    :root {
        --text-xs: 0.7rem;
        --text-sm: 0.8rem;
        --text-base: 0.9rem;
        --text-lg: 1rem;
        --text-xl: 1.1rem;
        --text-2xl: 1.3rem;
        --text-3xl: 1.5rem;
    }
    
    /* 超小屏套餐卡片进一步优化 - 单卡片显示 */
    .package-card {
        padding: var(--space-4) !important;
        min-height: 350px !important;
    }
    
    .package-name {
        font-size: var(--text-lg) !important;
    }
    
    .price-amount {
        font-size: 2rem !important;
    }
    
    .package-features {
        margin-bottom: var(--space-4) !important;
    }
    
    .feature-item {
        font-size: var(--text-xs) !important;
        margin-bottom: var(--space-2) !important;
    }
    
    .btn-lg {
        padding: var(--space-3) var(--space-4) !important;
        font-size: var(--text-sm) !important;
        min-height: 44px !important;
        height: 44px !important;
    }
    
    /* 按钮占位符移动端适配 */
    .btn-placeholder {
        height: 52px; /* 移动端按钮高度+间距 */
    }
    
    /* 超小屏按钮高度调整 */
    .package-card .btn-lg {
        min-height: 42px !important;
        height: 42px !important;
        bottom: 16px !important; /* 超小屏16px间距 */
    }
    
    /* 超小屏占位符调整 */
    .btn-placeholder {
        height: 44px; /* 超小屏按钮高度+间距 */
    }
    
    .price-amount {
        font-size: 2rem;
    }
    
    .payment-method {
        padding: var(--space-3);
        gap: var(--space-2);
    }
    
    .method-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .method-info {
        flex: 1;
    }
    
    .method-name {
        font-size: var(--text-sm);
    }
    
    .method-desc {
        font-size: var(--text-xs);
    }
    
    /* 按钮优化 - 移动端统一高度 */
    .btn {
        padding: var(--space-3) var(--space-4);
        font-size: var(--text-sm);
    }
    
    .btn-lg {
        padding: var(--space-3) var(--space-5); /* 更小内边距 */
        font-size: var(--text-base);
        min-height: 44px; /* 移动端统一高度 */
        height: 44px; /* 强制固定高度 */
        line-height: 1.1;
    }
    
    /* 移动端套餐按钮强制统一 - 固定高度定位 */
    .package-card .btn-lg {
        min-height: 48px !important;
        height: 48px !important;
        padding: 0 !important;
        font-size: var(--text-base) !important;
        line-height: 1 !important;
        bottom: 20px !important; /* 移动端较小间距20px */
        left: var(--space-6) !important;
        right: var(--space-6) !important;
        width: calc(100% - var(--space-12)) !important;
    }
}

/* ======================================
   横屏模式优化
   ====================================== */
@media (max-width: 896px) and (orientation: landscape) {
    /* 减少垂直间距 */
    .page-header {
        margin-bottom: var(--space-6);
    }
    
    .packages-container {
        gap: var(--space-4);
    }
    
    .package-card {
        padding: var(--space-5);
    }
    
    .payment-section {
        padding: var(--space-5);
    }
    
    .help-section {
        padding: var(--space-5);
    }
    
    /* 调整字体大小 */
    .page-title {
        font-size: var(--text-2xl);
    }
    
    .price-amount {
        font-size: 2rem;
    }
    
    .section-title {
        font-size: var(--text-lg);
    }
}

/* ======================================
   iPhone X及以上刘海屏优化
   ====================================== */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: env(safe-area-inset-top);
    }
    
    .main-wrapper {
        padding-top: env(safe-area-inset-top);
    }
}

/* ======================================
   iOS Safari底部工具栏优化
   ====================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .action-buttons {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ======================================
   触摸设备优化
   ====================================== */
@media (hover: none) and (pointer: coarse) {
    /* 增大点击区域 */
    .package-card,
    .payment-method,
    .btn {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* 减少悬停效果 */
    .package-card:hover {
        transform: none;
    }
    
    .payment-method:hover {
        background: transparent;
    }
    
    /* 增加点击反馈 */
    .package-card:active,
    .payment-method:active,
    .btn:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
    
    /* 优化滚动性能 */
    .packages-container,
    .payment-methods,
    .help-grid {
        -webkit-overflow-scrolling: touch;
    }
}

/* ======================================
   暗黑模式移动端优化
   ====================================== */
@media (prefers-color-scheme: dark) and (max-width: 639px) {
    .package-card {
        background: var(--bg-card);
        border-color: var(--border-color);
    }
    
    .payment-method {
        background: var(--bg-card);
        border-color: var(--border-color);
    }
    
    .order-summary {
        background: var(--gray-100);
    }
    
    .help-section {
        background: var(--gray-100);
    }
}

/* ======================================
   性能优化 - 减少重绘重排
   ====================================== */
@media (max-width: 639px) {
    /* 使用transform代替position进行动画 */
    .package-card,
    .payment-method {
        will-change: transform;
    }
    
    /* 隐藏不必要的元素 */
    .mobile-hidden {
        display: none !important;
    }
    
    /* 简化动画 */
    .fade-in,
    .slide-in-up,
    .scale-in {
        animation-duration: 0.3s;
    }
}

/* ======================================
   特殊场景处理
   ====================================== */

/* 键盘弹出时的处理 */
@media (max-width: 639px) {
    /* 防止输入框被键盘遮挡 */
    input:focus,
    textarea:focus {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 防止横向滚动 */
body {
    overflow-x: hidden;
}

/* 优化图片加载 */
img {
    max-width: 100%;
    height: auto;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 优化字体渲染 */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ======================================
   微信内置浏览器优化
   ====================================== */
.wechat-webview {
    /* 微信内置浏览器特殊处理 */
    .header {
        padding-top: 20px; /* 微信状态栏高度 */
    }
    
    .main-wrapper {
        padding-top: 20px;
    }
}

/* 微信分享按钮优化 */
.wechat-share-btn {
    background: #07C160;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.wechat-share-btn:active {
    background: #06A952;
}