/* 移动端通用优化样式 */

/* 防止iOS Safari的橡皮筋效果 */
body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
}

/* 防止双击缩放 */
* {
    touch-action: manipulation;
}

/* 优化文本选择 */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 允许输入框文本选择 */
input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 防止长按选择 */
* {
    -webkit-touch-callout: none;
}

/* 优化按钮点击效果 */
button, .btn, .action-btn, .nav-item, .service-card {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 触摸反馈效果 */
button:active, .btn:active, .action-btn:active, .nav-item:active, .service-card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* 优化滚动条 */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 移动端安全区域适配 */
@supports (padding: max(0px)) {
    .header {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
    
    .container, .form-container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* 横屏适配 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .header {
        padding: 10px 20px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .header p {
        font-size: 12px;
    }
    
    .container, .form-container {
        margin: 10px;
        padding: 15px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .icon, .action-btn .icon, .service-card .icon {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* 减少动画以提升性能 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .empty-state {
        color: #999;
    }
    
    .empty-state .icon {
        opacity: 0.7;
    }
}

/* 移动端表格优化 */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    .table th,
    .table td {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }
}

/* 移动端模态框优化 */
@media (max-width: 768px) {
    .modal {
        padding: 20px;
        margin: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        max-width: 100%;
        width: 100%;
    }
}

/* 移动端表单优化 */
@media (max-width: 768px) {
    .form-group input,
    .form-group textarea {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 8px;
    }
    
    .form-group input:focus,
    .form-group textarea:focus {
        -webkit-appearance: none;
        appearance: none;
        outline: none;
        box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
    }
}

/* 移动端按钮组优化 */
@media (max-width: 768px) {
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group .btn {
        width: 100%;
        margin: 0;
    }
}

/* 移动端卡片优化 */
@media (max-width: 768px) {
    .card, .order-card, .stat-card, .action-card {
        margin-bottom: 12px;
        border-radius: 12px;
    }
    
    .card:last-child, .order-card:last-child {
        margin-bottom: 0;
    }
}

/* 移动端导航优化 */
@media (max-width: 768px) {
    .nav-content {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .nav-content::-webkit-scrollbar {
        display: none;
    }
    
    .nav-item {
        flex-shrink: 0;
    }
}

/* 移动端头部优化 */
@media (max-width: 768px) {
    .header {
        border-radius: 0 0 20px 20px !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
        padding: 12px 15px !important;
    }
    
    .header h1 {
        font-size: 18px !important;
        margin-bottom: 2px !important;
    }
    
    .header p {
        font-size: 12px !important;
        opacity: 0.8 !important;
    }
}

/* 移动端容器优化 */
@media (max-width: 768px) {
    .container, .form-container {
        margin: 10px !important;
        padding: 12px !important;
        border-radius: 16px !important;
        background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%) !important;
        border: 1px solid rgba(102, 126, 234, 0.1) !important;
        box-shadow: 0 2px 12px rgba(102, 126, 234, 0.08) !important;
    }
}

/* 移动端按钮优化 */
@media (max-width: 768px) {
    .btn, button:not(.nav-btn):not(.nav-item) {
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        border-radius: 12px !important;
        transition: all 0.2s ease !important;
        min-height: 44px !important;
    }
}

/* 移动端输入框优化 */
@media (max-width: 768px) {
    .form-group input,
    .form-group textarea,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea {
        padding: 12px !important;
        font-size: 16px !important; /* 防止iOS缩放 */
        border-radius: 12px !important;
        border: 2px solid #e1e1e1 !important;
        min-height: 44px !important;
    }
    
    .form-group input:focus,
    .form-group textarea:focus,
    input:focus,
    textarea:focus {
        border-color: #667eea !important;
        box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3) !important;
    }
}

/* 移动端卡片优化 */
@media (max-width: 768px) {
    .card, .order-card, .stat-card, .action-card, .service-card {
        margin-bottom: 12px !important;
        border-radius: 16px !important;
        background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%) !important;
        border: 1px solid rgba(102, 126, 234, 0.1) !important;
        box-shadow: 0 2px 12px rgba(102, 126, 234, 0.08) !important;
        padding: 16px !important;
    }
    
    .card:last-child, .order-card:last-child {
        margin-bottom: 0 !important;
    }
}
