/* 移动端专用优化样式 */
/* 此文件包含针对移动设备的额外优化 */

/* 超小屏幕设备（手机） */
@media (max-width: 480px) {
    /* 基础调整 */
    html {
        font-size: 13px;
    }
    
    .header h1 {
        font-size: 1.6rem;
    }
    
    .header h1 i {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }
    
    /* 商品网格调整 */
    .products-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .product-image {
        height: 180px;
    }
    
    .product-info {
        padding: 1.25rem;
    }
    
    .product-meta {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .price {
        text-align: center;
        font-size: 1.4rem;
    }
    
    .buy-btn {
        padding: 0.875rem;
        font-size: 0.95rem;
    }
    
    /* 订单页面优化 */
    .order-detail {
        padding: 1.5rem 1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin: 0 -1rem 1.5rem;
    }
    
    .order-info-grid {
        gap: 1rem;
    }
    
    .order-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .order-label, .order-value {
        width: 100%;
    }
    
    .order-value {
        text-align: left;
    }
    
    /* 支付方式单列显示 */
    .methods-grid {
        grid-template-columns: 1fr;
    }
    
    .method-card {
        padding: 1.5rem 1rem;
    }
    
    /* 支付按钮优化 */
    .pay-now-btn {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
        margin: 0;
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        padding: 1.25rem;
    }
    
    .order-detail {
        padding-bottom: 5rem; /* 为固定按钮留出空间 */
    }
    
    /* 结果页面优化 */
    .result-container {
        min-height: calc(100vh - 5rem);
        padding: 1rem 0;
    }
    
    .result-box {
        padding: 2rem 1.25rem;
        margin: 0 1rem;
    }
    
    .result-icon {
        width: 80px;
        height: 80px;
        font-size: 2.5rem;
    }
    
    .result-box h2 {
        font-size: 1.6rem;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn {
        width: 100%;
    }
    
    /* 特性网格单列 */
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    /* FAQ调整 */
    .faq-question {
        padding: 1rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .faq-answer.show {
        padding: 1.25rem;
    }
    
    /* 购物车按钮位置调整 */
    .cart-float {
        bottom: 5.5rem; /* 在固定支付按钮上方 */
        right: 1rem;
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .cart-count {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
    
    /* 防止移动端点击时出现蓝色背景 */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* 改善移动端滚动体验 */
    .container {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移除不必要的悬停效果 */
    .product-card:hover {
        transform: none;
    }
    
    .method-card:hover {
        transform: none;
    }
    
    .feature-card:hover {
        transform: none;
    }
}

/* 小屏幕手机 (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    html {
        font-size: 14px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header h1 i {
        width: 55px;
        height: 55px;
        font-size: 1.8rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-image {
        height: 160px;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .methods-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cart-float {
        width: 55px;
        height: 55px;
        bottom: 2rem;
        right: 1.5rem;
    }
}

/* 平板设备 (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 768px;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .methods-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .header h1 {
        font-size: 2.2rem;
    }
}

/* 横屏模式优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 1rem 0;
        margin-bottom: 1rem;
    }
    
    .header h1 {
        font-size: 1.6rem;
    }
    
    .header h1 i {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .product-image {
        height: 120px;
    }
    
    .result-container {
        padding: 1rem 0;
    }
    
    .cart-float {
        bottom: 1rem;
        right: 1rem;
    }
}

/* iOS Safari 专用优化 */
@supports (-webkit-touch-callout: none) {
    .header {
        background-attachment: scroll;
    }
    
    .pay-now-btn,
    .buy-btn,
    .back-link {
        padding: 1rem 1.5rem;
    }
    
    /* 改善iOS滚动 */
    .container {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 修复iOS点击延迟 */
    .product-card,
    .method-card,
    .feature-card {
        cursor: pointer;
    }
}

/* Android Chrome 优化 */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
    /* 隐藏滚动条 */
    ::-webkit-scrollbar {
        display: none;
    }
}

/* 高DPI屏幕优化 (Retina等) */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .header h1 {
        font-weight: 600;
    }
    
    .product-card {
        border: 0.5px solid var(--border-color);
    }
    
    .method-card {
        border: 1.5px solid var(--border-color);
    }
    
    .method-card.selected {
        border-width: 2px;
    }
}

/* 触摸设备优化 (无悬停的设备) */
@media (hover: none) and (pointer: coarse) {
    .product-card:hover {
        transform: none;
    }
    
    .method-card:hover {
        transform: none;
    }
    
    .feature-card:hover {
        transform: none;
    }
    
    .back-link:hover,
    .buy-btn:hover,
    .pay-now-btn:hover {
        transform: none;
    }
    
    /* 增加触摸目标大小 (Apple推荐44px) */
    .buy-btn,
    .pay-now-btn,
    .back-link,
    .method-card,
    .faq-question {
        min-height: 44px;
    }
    
    /* 触摸反馈 */
    .buy-btn:active,
    .pay-now-btn:active,
    .method-card:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
    
    /* 支付方式选中状态更明显 */
    .method-option input[type="radio"]:checked + .method-card {
        border-width: 3px;
    }
}

/* 无障碍优化 - 减少动画 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .product-card,
    .method-card,
    .feature-card {
        transition: none;
    }
    
    .header h1 i {
        animation: none;
    }
}

/* 暗色模式移动端优化 */
@media (prefers-color-scheme: dark) and (max-width: 768px) {
    .product-card,
    .order-detail,
    .payment-methods,
    .result-box,
    .feature-card,
    .faq-section {
        background: #1e293b;
        border-color: #334155;
    }
    
    .security-note {
        background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
    }
    
    /* 移动端固定按钮暗色模式 */
    .pay-now-btn {
        background: var(--primary-gradient);
    }
    
    .cart-float {
        border-color: #475569;
    }
}

/* 低电量模式优化 */
@media (prefers-reduced-data: reduce) {
    .product-image img {
        loading: lazy;
    }
    
    .header::before {
        display: none;
    }
    
    .product-card,
    .method-card,
    .feature-card {
        box-shadow: var(--shadow);
    }
}

/* 大字体模式支持 */
@media (prefers-contrast: high) {
    .buy-btn,
    .pay-now-btn,
    .btn-primary {
        border: 2px solid currentColor;
    }
}

/* 折叠屏设备优化 */
@media (spanning: single-fold-vertical) {
    .container {
        max-width: calc(100vw - env(fold-width));
    }
}

/* 防止移动端键盘弹出时页面变形 */
@media (max-width: 767px) {
    html, body {
        overflow-x: hidden;
    }
    
    input, textarea, select {
        font-size: 16px; /* 防止iOS缩放 */
    }
}

/* 移动端性能优化 */
@media (max-width: 768px) {
    /* 减少模糊效果 */
    .header h1 i,
    .back-link,
    .stat-item {
        backdrop-filter: blur(5px);
    }
    
    /* 减少阴影复杂度 */
    .product-card,
    .method-card,
    .feature-card {
        box-shadow: var(--shadow);
    }
    
    /* 减少渐变复杂度 */
    .header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
}

/* 窄屏设备优化 */
@media (max-width: 360px) {
    html {
        font-size: 12px;
    }
    
    .header h1 {
        font-size: 1.4rem;
    }
    
    .header h1 i {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
    }
    
    .product-meta {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .result-actions .btn {
        min-width: auto;
        width: 100%;
    }
}