/* ============================================
   FarmX PRO - 响应式布局优化
   ============================================ */

/* 基础重置 */
* {
    -webkit-tap-highlight-color: transparent;
}

/* 移动端优化 */
@media (max-width: 768px) {
    /* 隐藏桌面侧边栏，显示移动端菜单按钮 */
    .desktop-sidebar {
        display: none !important;
    }
    
    /* 移动端覆盖层 */
    .mobile-overlay {
        display: block !important;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .mobile-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
    
    /* 移动端侧边栏 */
    .mobile-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 80%;
        max-width: 320px;
        height: 100vh;
        background: var(--bg-card);
        z-index: 50;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .mobile-sidebar.active {
        left: 0;
    }
    
    /* 移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex !important;
    }
    
    /* 移动端头部 */
    .mobile-header {
        display: flex !important;
    }
    
    /* 移动端内容区域 */
    .main-content {
        padding-top: 60px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* 表格响应式 */
    .responsive-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .responsive-table-container table {
        min-width: 600px;
    }
    
    /* 卡片响应式 */
    .responsive-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* 按钮响应式 */
    .responsive-buttons {
        flex-direction: column !important;
    }
    
    .responsive-buttons button {
        width: 100%;
        justify-content: center;
    }
    
    /* 表单响应式 */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 模态框响应式 */
    .modal-content {
        width: 95% !important;
        max-width: none !important;
        margin: 0 auto !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* 统计卡片响应式 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    /* 流程步骤响应式 */
    .pipeline-steps {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .pipeline-step {
        width: 100% !important;
    }
    
    /* 标签页响应式 */
    .tab-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-container::-webkit-scrollbar {
        height: 4px;
    }
    
    /* 二维码卡片响应式 */
    .qr-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* 工具栏响应式 */
    .toolbar {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .toolbar button {
        width: 100%;
    }
}

/* 平板优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .desktop-sidebar {
        width: 200px !important;
    }
    
    .main-content {
        padding-left: 200px !important;
    }
    
    .responsive-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    .qr-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 缩小字体 */
    .text-responsive {
        font-size: 0.875rem;
    }
    
    /* 缩小间距 */
    .responsive-padding {
        padding: 0.75rem !important;
    }
    
    /* 缩小图标 */
    .responsive-icon {
        font-size: 0.875rem;
    }
}

/* 横屏优化 */
@media (max-height: 600px) and (orientation: landscape) {
    .modal-content {
        max-height: 80vh;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大触摸目标 */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px;
    }
    
    /* 增大按钮间距 */
    .responsive-buttons button {
        padding: 0.75rem 1rem;
    }
    
    /* 优化滚动体验 */
    .scroll-container {
        -webkit-overflow-scrolling: touch;
    }
}

/* 打印样式 */
@media print {
    .desktop-sidebar,
    .mobile-sidebar,
    .mobile-menu-btn,
    .mobile-header,
    .toolbar {
        display: none !important;
    }
    
    .main-content {
        padding: 0 !important;
    }
    
    body {
        background: white !important;
    }
}

/* 实用类 */
.mobile-menu-btn {
    display: none;
}

.mobile-overlay {
    display: none;
}

.mobile-header {
    display: none;
}

/* 平滑滚动 */
.smooth-scroll {
    -webkit-overflow-scrolling: touch;
}

/* 防止文本溢出 */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 响应式字体 */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    html {
        font-size: 15px;
    }
}

@media (min-width: 1025px) {
    html {
        font-size: 16px;
    }
}

/* 加载状态 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
