/**
 * 移动端优化样式 - 专门针对移动设备和微信浏览器的适配
 * 解决移动端页面错乱问题，特别是微信浏览器兼容性
 */

/* ============================================
   全局移动端优化
   ============================================ */

/* 防止iOS橡皮筋效果导致的布局问题 */
html {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
    width: 100%;
}

body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* 修复微信浏览器中的viewport问题 */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

/* iOS安全区域适配 */
@supports (padding: max(0px)) {
    .navbar,
    .footer,
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-top: max(16px, env(safe-area-inset-top));
    }
    
    .footer {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   移动端导航栏优化
   ============================================ */

/* 移动端汉堡菜单按钮 */
.mobile-menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    z-index: 1002;
    padding: 0;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #333;
    margin: 5px auto;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* 移动端导航菜单容器 */
.mobile-nav-wrapper {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-nav-wrapper.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-menu {
    position: absolute;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 320px;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav-wrapper.active .mobile-nav-menu {
    right: 0;
}

.mobile-nav-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-nav-menu .nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 20px;
}

.mobile-nav-menu .nav-menu li {
    width: 100%;
    margin: 0;
}

.mobile-nav-menu .nav-link {
    display: block;
    padding: 12px 16px;
    font-size: 16px;
    border-radius: 8px;
    width: 100%;
}

/* 移动端下拉菜单 */
.mobile-nav-menu .nav-dropdown {
    position: relative;
}

.mobile-nav-menu .dropdown-menu {
    position: static;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: #f8f9fa;
    margin-top: 8px;
    border-radius: 8px;
    padding: 8px;
}

.mobile-nav-menu .nav-dropdown.active .dropdown-menu {
    display: block;
}

.mobile-nav-menu .dropdown-column {
    padding: 8px;
}

.mobile-nav-menu .dropdown-column h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #666;
}

.mobile-nav-menu .dropdown-column a {
    display: block;
    padding: 8px 12px;
    font-size: 14px;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.mobile-nav-menu .dropdown-column a:hover {
    background: rgba(0, 166, 251, 0.1);
    color: #00A6FB;
}

/* ============================================
   移动端Hero区域优化
   ============================================ */

@media (max-width: 768px) {
    .hero {
        padding-top: 80px; /* 为固定导航栏留出空间 */
        min-height: auto;
        overflow: hidden;
    }
    
    .hero-bg {
        display: none; /* 移动端隐藏复杂背景动画 */
    }
    
    .hero-content {
        display: flex;
        flex-direction: column;
        gap: 24px;
        padding: 20px;
    }
    
    .hero-text {
        text-align: center;
        order: 1;
    }
    
    .hero-visual {
        order: 2;
        max-width: 100%;
        margin: 0 auto;
    }
    
    .hero-badge {
        display: inline-flex;
        margin: 0 auto 16px;
    }
    
    .hero-title {
        font-size: 28px;
        line-height: 1.3;
        margin-bottom: 16px;
    }
    
    .gradient-text {
        font-size: 24px;
    }
    
    .hero-description {
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 24px;
    }
    
    .hero-features {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 24px;
    }
    
    .feature-item {
        justify-content: center;
    }
    
    .hero-actions {
        flex-direction: column;
        gap: 12px;
        align-items: center;
    }
    
    .btn-large {
        width: 100%;
        max-width: 280px;
        height: 48px;
        font-size: 15px;
    }
    
    /* 架构图移动端优化 */
    .architecture-diagram {
        transform: scale(0.7);
        margin: -50px auto;
    }
    
    .arch-center {
        width: 180px;
        height: 180px;
    }
    
    .core-icon svg {
        width: 30px;
        height: 30px;
    }
    
    .core-label {
        font-size: 14px;
    }
    
    .core-desc {
        font-size: 11px;
    }
    
    .arch-module {
        padding: 12px;
    }
    
    .module-title {
        font-size: 12px;
    }
    
    .module-items {
        font-size: 10px;
    }
}

/* ============================================
   移动端内容区域优化
   ============================================ */

@media (max-width: 768px) {
    /* 通用容器优化 */
    .container {
        padding: 0 16px;
        width: 100%;
    }
    
    section {
        padding: 40px 0;
        overflow: hidden;
    }
    
    .section-title {
        font-size: 24px;
        text-align: center;
        margin-bottom: 24px;
    }
    
    /* 卡片布局优化 */
    .value-grid,
    .solutions-grid,
    .cases-grid,
    .pricing-cards {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0;
    }
    
    .value-card,
    .solution-card,
    .case-card,
    .pricing-card {
        width: 100%;
        margin: 0;
        padding: 20px;
        box-sizing: border-box;
    }
    
    /* 表格响应式处理 */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    /* 图片响应式 */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* 按钮优化 - 增加触摸区域 */
    .btn {
        min-height: 44px;
        padding: 12px 24px;
        font-size: 14px;
        touch-action: manipulation;
    }
    
    /* 表单优化 */
    input,
    textarea,
    select {
        font-size: 16px; /* 防止iOS缩放 */
        min-height: 44px;
        padding: 12px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* 模态框优化 */
    .modal {
        padding: 16px;
    }
    
    .modal-content {
        width: 100%;
        max-width: calc(100vw - 32px);
        margin: 20px auto;
    }
}

/* ============================================
   微信浏览器特殊优化
   ============================================ */

/* 检测微信浏览器 */
.wechat-browser {
    /* 微信浏览器特殊样式 */
}

/* 修复微信浏览器position:fixed问题 */
.wechat-browser .navbar {
    position: absolute;
    top: 0;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.wechat-browser body {
    padding-top: 70px;
}

/* 修复微信浏览器滚动问题 */
.wechat-browser .scroll-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
    height: 100%;
}

/* 微信浏览器输入框优化 */
.wechat-browser input,
.wechat-browser textarea {
    -webkit-appearance: none;
    -webkit-user-select: text;
    user-select: text;
}

/* ============================================
   性能优化
   ============================================ */

@media (max-width: 768px) {
    /* 禁用移动端不必要的动画 */
    * {
        animation-duration: 0.2s !important;
    }
    
    /* 减少阴影复杂度 */
    .card,
    .value-card,
    .solution-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* 优化滚动性能 */
    .scroll-container {
        will-change: transform;
        transform: translateZ(0);
        backface-visibility: hidden;
    }
    
    /* 禁用hover效果 */
    @media (hover: none) {
        .btn:hover,
        .nav-link:hover,
        .card:hover {
            transform: none;
            box-shadow: none;
        }
    }
}

/* ============================================
   小屏幕设备特殊优化 (≤375px)
   ============================================ */

@media (max-width: 375px) {
    .container {
        padding: 0 12px;
    }
    
    .hero-title {
        font-size: 24px;
    }
    
    .gradient-text {
        font-size: 20px;
    }
    
    .hero-description {
        font-size: 13px;
    }
    
    .section-title {
        font-size: 20px;
    }
    
    .value-card,
    .solution-card {
        padding: 16px;
    }
    
    .btn-large {
        font-size: 14px;
        height: 44px;
    }
    
    /* 超小屏幕下的网格布局 */
    .value-grid-enhanced {
        grid-template-columns: 1fr;
    }
    
    .architecture-diagram {
        transform: scale(0.6);
        margin: -60px auto;
    }
}

/* ============================================
   横屏模式优化
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding: 8px 0;
    }
    
    .nav-brand .logo {
        height: 35px;
    }
    
    .hero {
        padding-top: 60px;
        min-height: 100vh;
    }
    
    .hero-content {
        flex-direction: row;
        align-items: center;
    }
    
    .hero-text {
        flex: 1;
        text-align: left;
    }
    
    .hero-visual {
        flex: 1;
    }
    
    section {
        padding: 24px 0;
    }
}

/* ============================================
   触摸优化
   ============================================ */

@media (pointer: coarse) {
    /* 增加所有可点击元素的触摸区域 */
    a,
    button,
    .btn,
    .nav-link,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 链接间距优化 */
    .nav-menu li {
        margin: 0 4px;
    }
    
    /* 表单元素触摸优化 */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
        margin: 12px;
    }
}

/* ============================================
   深色模式支持
   ============================================ */

@media (prefers-color-scheme: dark) {
    @media (max-width: 768px) {
        .mobile-nav-menu {
            background: #1a1a1a;
            color: #fff;
        }
        
        .mobile-nav-header {
            border-bottom-color: #333;
        }
        
        .mobile-nav-menu .nav-link {
            color: #fff;
        }
        
        .mobile-nav-menu .dropdown-menu {
            background: #2a2a2a;
        }
        
        .mobile-nav-menu .dropdown-column a {
            color: #ccc;
        }
        
        .mobile-menu-toggle span {
            background: #fff;
        }
    }
}

/* ============================================
   打印样式优化
   ============================================ */

@media print {
    .mobile-menu-toggle,
    .mobile-nav-wrapper {
        display: none !important;
    }
    
    .navbar {
        position: static;
    }
    
    body {
        padding-top: 0;
    }
}