/* =====================================================
   移动端全局优化CSS
   Mobile Responsive CSS
   ===================================================== */

/* =====================================================
   1. 全局响应式断点
   Global Responsive Breakpoints
   ===================================================== */

/* 超小手机 (320px及以下) */
@media (max-width: 320px) {
    /* 全局字体调整 */
    html {
        font-size: 12px;
    }
    
    /* 容器宽度 */
    .container, .container-fluid {
        padding: 0 10px !important;
        max-width: 100% !important;
    }
}

/* 小手机 (321px - 375px) */
@media (max-width: 375px) {
    html {
        font-size: 13px;
    }
    
    .container, .container-fluid {
        padding: 0 12px !important;
    }
}

/* 中等手机 (376px - 414px) */
@media (max-width: 414px) {
    html {
        font-size: 14px;
    }
    
    .container, .container-fluid {
        padding: 0 15px !important;
    }
}

/* 大手机 (415px - 576px) */
@media (max-width: 576px) {
    html {
        font-size: 15px;
    }
    
    .container, .container-fluid {
        padding: 0 15px !important;
    }
}

/* 平板 (577px - 768px) */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }
}

/* 小屏PC (769px - 992px) */
@media (max-width: 992px) {
    html {
        font-size: 16px;
    }
}

/* =====================================================
   2. 全局样式优化
   Global Styles Optimization
   ===================================================== */

/* 所有移动端设备通用样式 */
@media (max-width: 768px) {
    /* 防止横向滚动 */
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* 所有元素自适应 */
    * {
        box-sizing: border-box !important;
        max-width: 100% !important;
    }
    
    /* 图片自适应 */
    img {
        max-width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
    }
    
    /* 视频自适应 */
    video, iframe {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* 表格自适应 */
    table {
        width: 100% !important;
        table-layout: fixed !important;
    }
    
    /* 链接触摸优化 */
    a {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* 按钮触摸优化 */
    button, .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 输入框触摸优化 */
    input, textarea, select {
        min-height: 44px;
        font-size: 16px !important; /* 防止iOS自动缩放 */
    }
    
    /* 文字选择禁用（可选） */
    /* body {
        -webkit-user-select: none;
        user-select: none;
    } */
    
    /* 滚动优化 */
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }
    
    /* 优化可点击区域 */
    .iconfont, [class*="icon-"] {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* =====================================================
   3. 字体大小响应式
   Responsive Font Sizes
   ===================================================== */

@media (max-width: 600px) {
    /* 标题字体 */
    h1 { font-size: 24px !important; line-height: 1.4 !important; }
    h2 { font-size: 20px !important; line-height: 1.4 !important; }
    h3 { font-size: 18px !important; line-height: 1.4 !important; }
    h4 { font-size: 16px !important; line-height: 1.4 !important; }
    h5 { font-size: 14px !important; line-height: 1.4 !important; }
    h6 { font-size: 12px !important; line-height: 1.4 !important; }
    
    /* 段落字体 */
    p, span, div, li, a {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    
    /* 小号文字 */
    .small, small {
        font-size: 12px !important;
    }
}

@media (min-width: 601px) and (max-width: 768px) {
    h1 { font-size: 28px !important; line-height: 1.4 !important; }
    h2 { font-size: 24px !important; line-height: 1.4 !important; }
    h3 { font-size: 20px !important; line-height: 1.4 !important; }
    h4 { font-size: 18px !important; line-height: 1.4 !important; }
}

/* =====================================================
   4. 间距优化
   Spacing Optimization
   ===================================================== */

@media (max-width: 600px) {
    /* 减小内边距 */
    .padding-large { padding: 20px 15px !important; }
    .padding-medium { padding: 15px 10px !important; }
    .padding-small { padding: 10px 8px !important; }
    .padding-none { padding: 0 !important; }
    
    /* 减小外边距 */
    .margin-large { margin: 20px 10px !important; }
    .margin-medium { margin: 15px 8px !important; }
    .margin-small { margin: 10px 5px !important; }
    .margin-none { margin: 0 !important; }
    
    /* 通用间距 */
    [class*="box"], [class*="container"] {
        padding: 15px 10px !important;
    }
}

/* =====================================================
   5. Flex布局优化
   Flexbox Optimization
   ===================================================== */

@media (max-width: 768px) {
    /* 自动换行 */
    .flex-wrap {
        flex-wrap: wrap !important;
    }
    
    /* 垂直排列 */
    .flex-column {
        flex-direction: column !important;
    }
    
    /* 居中对齐 */
    .flex-center {
        justify-content: center !important;
        align-items: center !important;
    }
    
    /* 宽度自适应 */
    .flex-1, [class*="col-"], [class*="flex-"] {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* 列布局调整 */
    .row, [class*="list"] {
        display: flex !important;
        flex-wrap: wrap !important;
    }
}

/* =====================================================
   6. 隐藏和显示
   Hide and Show
   ===================================================== */

@media (max-width: 768px) {
    /* 隐藏桌面端元素 */
    .hidden-mobile, .hidden-xs, .hidden-sm {
        display: none !important;
    }
    
    /* 显示移动端元素 */
    .visible-mobile, .visible-xs, .visible-sm {
        display: block !important;
    }
}

@media (min-width: 769px) {
    /* 隐藏移动端元素 */
    .hidden-desktop, .hidden-md, .hidden-lg, .hidden-xl {
        display: none !important;
    }
    
    /* 显示桌面端元素 */
    .visible-desktop, .visible-md, .visible-lg, .visible-xl {
        display: block !important;
    }
}

/* =====================================================
   7. 表格优化
   Table Optimization
   ===================================================== */

@media (max-width: 600px) {
    /* 表格横向滚动 */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* 表格单元格 */
    table td, table th {
        padding: 8px 5px !important;
        font-size: 12px !important;
    }
    
    /* 小字体表格 */
    .table-small td, .table-small th {
        font-size: 11px !important;
        padding: 5px 3px !important;
    }
}

/* =====================================================
   8. 按钮和表单优化
   Button and Form Optimization
   ===================================================== */

@media (max-width: 600px) {
    /* 按钮大小 */
    .btn, button, input[type="submit"], input[type="button"] {
        padding: 12px 20px !important;
        font-size: 14px !important;
        min-height: 44px;
    }
    
    /* 按钮宽度 */
    .btn-block, .btn-full {
        width: 100% !important;
        display: block !important;
    }
    
    /* 表单组 */
    .form-group {
        margin-bottom: 15px !important;
    }
    
    /* 表单标签 */
    label {
        display: block !important;
        margin-bottom: 5px !important;
        font-size: 14px !important;
    }
}

/* =====================================================
   9. 卡片和盒子优化
   Card and Box Optimization
   ===================================================== */

@media (max-width: 600px) {
    /* 卡片样式 */
    .card, .box {
        width: 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px !important;
        border-radius: 8px !important;
        overflow: hidden !important;
    }
    
    /* 卡片图片 */
    .card img, .box img {
        width: 100% !important;
        height: auto !important;
    }
    
    /* 卡片内容 */
    .card-body, .box-content {
        padding: 15px !important;
    }
}

/* =====================================================
   10. 网格布局优化
   Grid Layout Optimization
   ===================================================== */

@media (max-width: 600px) {
    /* 单列布局 */
    .grid-1, .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr !important;
    }
    
    /* Flex布局单列 */
    [class*="list"], [class*="items"] {
        flex-direction: column !important;
    }
    
    [class*="list"] > *,
    [class*="items"] > * {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 15px 0 !important;
    }
}

@media (min-width: 601px) and (max-width: 768px) {
    /* 双列布局 */
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* =====================================================
   11. 辅助类
   Helper Classes
   ===================================================== */

@media (max-width: 768px) {
    /* 文字对齐 */
    .text-center-mobile { text-align: center !important; }
    .text-left-mobile { text-align: left !important; }
    .text-right-mobile { text-align: right !important; }
    
    /* 宽度类 */
    .w-100-mobile { width: 100% !important; }
    .w-auto-mobile { width: auto !important; }
    
    /* 显示/隐藏 */
    .block-mobile { display: block !important; }
    .inline-block-mobile { display: inline-block !important; }
    .flex-mobile { display: flex !important; }
    
    /* 定位 */
    .relative-mobile { position: relative !important; }
    .absolute-mobile { position: absolute !important; }
    .fixed-mobile { position: fixed !important; }
    
    /* 溢出 */
    .overflow-hidden-mobile { overflow: hidden !important; }
    .overflow-auto-mobile { overflow: auto !important; }
}

/* =====================================================
   12. 性能优化
   Performance Optimization
   ===================================================== */

@media (max-width: 768px) {
    /* 禁用动画（提升性能） */
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0s !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
    
    /* 简化阴影 */
    * {
        box-shadow: none !important;
    }
    
    /* 简化渐变 */
    * {
        background-image: none !important;
    }
}

/* 可选：如果需要保留动画，注释掉上面的代码 */

/* =====================================================
   13. 可访问性优化
   Accessibility Optimization
   ===================================================== */

@media (max-width: 768px) {
    /* 增大点击区域 */
    a, button, [role="button"] {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 10px !important;
    }
    
    /* 焦点样式 */
    a:focus, button:focus, input:focus, textarea:focus {
        outline: 2px solid #0078D7 !important;
        outline-offset: 2px !important;
    }
}

/* =====================================================
   14. 安全区域适配（刘海屏）
   Safe Area Support
   ===================================================== */

@supports (padding-top: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        /* 顶部安全区域 */
        .safe-top {
            padding-top: env(safe-area-inset-top) !important;
        }
        
        /* 底部安全区域 */
        .safe-bottom {
            padding-bottom: env(safe-area-inset-bottom) !important;
        }
        
        /* 左侧安全区域 */
        .safe-left {
            padding-left: env(safe-area-inset-left) !important;
        }
        
        /* 右侧安全区域 */
        .safe-right {
            padding-right: env(safe-area-inset-right) !important;
        }
    }
}

/* =====================================================
   15. 打印优化
   Print Optimization
   ===================================================== */

@media print {
    /* 隐藏不必要的内容 */
    .no-print, nav, footer, .header, .sidebar, .mobile-container {
        display: none !important;
    }
    
    /* 调整字体大小 */
    body {
        font-size: 12pt !important;
        line-height: 1.5 !important;
    }
    
    /* 移除背景色 */
    body {
        background: white !important;
        color: black !important;
    }
}
