/**
 * 移动端优化样式
 * Mobile Optimization Styles
 * 
 * 功能：
 * 1. 响应式设计
 * 2. 触摸优化
 * 3. 移动端布局
 * 4. 性能优化
 */

/* 移动端基础样式 */
@media (max-width: 768px) {
    /* 基础重置 */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* 允许文本选择 */
    input, textarea, [contenteditable] {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
    
    /* 视口优化 */
    html {
        font-size: 16px;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    body {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端导航 */
    .mobile-nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        padding: 10px 15px;
    }
    
    .hamburger-menu {
        background: none;
        border: none;
        font-size: 24px;
        padding: 8px;
        cursor: pointer;
        color: #333;
    }
    
    .mobile-menu {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 80%;
        height: calc(100vh - 60px);
        background: #fff;
        box-shadow: 2px 0 4px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        z-index: 999;
        overflow-y: auto;
    }
    
    .mobile-menu.active {
        left: 0;
    }
    
    .mobile-menu .menu-item {
        display: block;
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        color: #333;
        text-decoration: none;
        font-size: 16px;
    }
    
    .mobile-menu .menu-item:hover {
        background: #f5f5f5;
    }
    
    /* 移动端表单 */
    .mobile-form {
        padding: 20px;
    }
    
    .mobile-input {
        width: 100%;
        padding: 12px 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        font-size: 16px;
        margin-bottom: 15px;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .mobile-input:focus {
        outline: none;
        border-color: #007bff;
        box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
    }
    
    /* 移动端按钮 */
    .mobile-button {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mobile-button:active {
        transform: scale(0.98);
    }
    
    .mobile-button.primary {
        background: #007bff;
        color: white;
    }
    
    .mobile-button.secondary {
        background: #6c757d;
        color: white;
    }
    
    .mobile-button.success {
        background: #28a745;
        color: white;
    }
    
    /* 触摸反馈 */
    .touchable {
        transition: all 0.2s ease;
        cursor: pointer;
    }
    
    .touchable.touch-active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    /* 移动端图表 */
    .mobile-chart {
        width: 100% !important;
        height: 300px !important;
    }
    
    .chart-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端卡片 */
    .mobile-card {
        margin: 15px;
        padding: 20px;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .mobile-card .card-header {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 15px;
        color: #333;
    }
    
    .mobile-card .card-content {
        font-size: 14px;
        line-height: 1.5;
        color: #666;
    }
    
    /* 移动端列表 */
    .mobile-list {
        background: #fff;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .mobile-list .list-item {
        padding: 15px 20px;
        border-bottom: 1px solid #eee;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .mobile-list .list-item:last-child {
        border-bottom: none;
    }
    
    .mobile-list .list-item .item-title {
        font-weight: 500;
        color: #333;
    }
    
    .mobile-list .list-item .item-subtitle {
        font-size: 12px;
        color: #999;
        margin-top: 2px;
    }
    
    /* 移动端模态框 */
    .mobile-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 2000;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .mobile-modal .modal-content {
        background: #fff;
        border-radius: 12px;
        padding: 20px;
        max-width: 100%;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .mobile-modal .modal-header {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 15px;
        text-align: center;
    }
    
    .mobile-modal .modal-close {
        position: absolute;
        top: 10px;
        right: 15px;
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #999;
    }
    
    /* 移动端工具提示 */
    .mobile-tooltip {
        position: absolute;
        background: rgba(0,0,0,0.8);
        color: white;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 12px;
        z-index: 1000;
        max-width: 200px;
        word-wrap: break-word;
    }
    
    /* 移动端Toast */
    .mobile-toast {
        position: fixed;
        bottom: 20px;
        left: 20px;
        right: 20px;
        background: rgba(0,0,0,0.8);
        color: white;
        padding: 12px 20px;
        border-radius: 8px;
        text-align: center;
        font-size: 14px;
        z-index: 3000;
        transform: translateY(100px);
        opacity: 0;
        transition: all 0.3s ease;
    }
    
    .mobile-toast.show {
        transform: translateY(0);
        opacity: 1;
    }
    
    /* 移动端上下文菜单 */
    .mobile-context-menu {
        position: absolute;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        z-index: 1000;
        min-width: 120px;
        overflow: hidden;
    }
    
    .mobile-context-menu .menu-item {
        padding: 12px 16px;
        border-bottom: 1px solid #eee;
        cursor: pointer;
        font-size: 14px;
        color: #333;
    }
    
    .mobile-context-menu .menu-item:last-child {
        border-bottom: none;
    }
    
    .mobile-context-menu .menu-item:active {
        background: #f5f5f5;
    }
    
    /* 移动端下拉刷新 */
    .pull-refresh-indicator {
        position: fixed;
        top: -50px;
        left: 50%;
        transform: translateX(-50%);
        background: #007bff;
        color: white;
        padding: 10px 20px;
        border-radius: 20px;
        font-size: 14px;
        z-index: 1000;
        transition: all 0.3s ease;
    }
    
    /* 移动端刷新动画 */
    .refresh-animation {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: rgba(0,0,0,0.8);
        color: white;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100vh;
        z-index: 2000;
    }
    
    .refresh-animation .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid rgba(255,255,255,0.3);
        border-top: 4px solid white;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: 15px;
    }
    
    .refresh-animation .text {
        font-size: 16px;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    /* 移动端视图切换 */
    .view {
        display: none;
        padding: 20px;
        min-height: calc(100vh - 60px);
    }
    
    .view.active {
        display: block;
    }
    
    /* 移动端导航项 */
    .nav-item {
        display: flex;
        align-items: center;
        padding: 12px 20px;
        color: #333;
        text-decoration: none;
        border-bottom: 1px solid #eee;
    }
    
    .nav-item.active {
        background: #f8f9fa;
        color: #007bff;
    }
    
    .nav-item .nav-icon {
        margin-right: 15px;
        font-size: 18px;
    }
    
    .nav-item .nav-text {
        font-size: 16px;
        font-weight: 500;
    }
    
    /* 移动端表格 */
    .mobile-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 14px;
    }
    
    .mobile-table th,
    .mobile-table td {
        padding: 12px 8px;
        text-align: left;
        border-bottom: 1px solid #eee;
    }
    
    .mobile-table th {
        background: #f8f9fa;
        font-weight: 600;
        color: #333;
    }
    
    /* 移动端分页 */
    .mobile-pagination {
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 20px 0;
    }
    
    .mobile-pagination .page-btn {
        padding: 8px 12px;
        margin: 0 4px;
        border: 1px solid #ddd;
        background: #fff;
        color: #333;
        text-decoration: none;
        border-radius: 4px;
        font-size: 14px;
    }
    
    .mobile-pagination .page-btn.active {
        background: #007bff;
        color: white;
        border-color: #007bff;
    }
    
    .mobile-pagination .page-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
    
    /* 移动端搜索 */
    .mobile-search {
        position: relative;
        margin: 15px;
    }
    
    .mobile-search input {
        width: 100%;
        padding: 12px 40px 12px 15px;
        border: 1px solid #ddd;
        border-radius: 25px;
        font-size: 16px;
        background: #f8f9fa;
    }
    
    .mobile-search .search-icon {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        color: #999;
        font-size: 18px;
    }
    
    /* 移动端标签 */
    .mobile-tags {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 15px 0;
    }
    
    .mobile-tag {
        padding: 6px 12px;
        background: #e9ecef;
        color: #495057;
        border-radius: 16px;
        font-size: 12px;
        font-weight: 500;
    }
    
    .mobile-tag.primary {
        background: #007bff;
        color: white;
    }
    
    .mobile-tag.success {
        background: #28a745;
        color: white;
    }
    
    .mobile-tag.warning {
        background: #ffc107;
        color: #212529;
    }
    
    .mobile-tag.danger {
        background: #dc3545;
        color: white;
    }
    
    /* 移动端进度条 */
    .mobile-progress {
        width: 100%;
        height: 8px;
        background: #e9ecef;
        border-radius: 4px;
        overflow: hidden;
        margin: 10px 0;
    }
    
    .mobile-progress .progress-bar {
        height: 100%;
        background: #007bff;
        border-radius: 4px;
        transition: width 0.3s ease;
    }
    
    /* 移动端开关 */
    .mobile-switch {
        position: relative;
        display: inline-block;
        width: 50px;
        height: 24px;
    }
    
    .mobile-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }
    
    .mobile-switch .slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: #ccc;
        transition: 0.3s;
        border-radius: 24px;
    }
    
    .mobile-switch .slider:before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        transition: 0.3s;
        border-radius: 50%;
    }
    
    .mobile-switch input:checked + .slider {
        background-color: #007bff;
    }
    
    .mobile-switch input:checked + .slider:before {
        transform: translateX(26px);
    }
    
    /* 移动端加载状态 */
    .mobile-loading {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 20px;
        color: #666;
    }
    
    .mobile-loading .spinner {
        width: 30px;
        height: 30px;
        border: 3px solid #f3f3f3;
        border-top: 3px solid #007bff;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: 15px;
    }
    
    .mobile-loading .text {
        font-size: 14px;
    }
    
    /* 移动端空状态 */
    .mobile-empty {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 60px 20px;
        color: #999;
        text-align: center;
    }
    
    .mobile-empty .icon {
        font-size: 48px;
        margin-bottom: 15px;
        opacity: 0.5;
    }
    
    .mobile-empty .title {
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 8px;
        color: #666;
    }
    
    .mobile-empty .description {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* 移动端错误状态 */
    .mobile-error {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 20px;
        color: #dc3545;
        text-align: center;
    }
    
    .mobile-error .icon {
        font-size: 48px;
        margin-bottom: 15px;
    }
    
    .mobile-error .title {
        font-size: 16px;
        font-weight: 500;
        margin-bottom: 8px;
    }
    
    .mobile-error .description {
        font-size: 14px;
        line-height: 1.5;
        margin-bottom: 20px;
    }
    
    .mobile-error .retry-btn {
        padding: 10px 20px;
        background: #dc3545;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 14px;
        cursor: pointer;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-nav {
        padding: 15px 30px;
    }
    
    .mobile-card {
        margin: 20px;
        padding: 25px;
    }
    
    .mobile-form {
        padding: 30px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-nav {
        padding: 8px 15px;
    }
    
    .mobile-menu {
        top: 50px;
        height: calc(100vh - 50px);
    }
    
    .view {
        min-height: calc(100vh - 50px);
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mobile-button,
    .mobile-input {
        border-width: 0.5px;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .mobile-nav {
        background: #1a1a1a;
        color: #fff;
    }
    
    .mobile-menu {
        background: #1a1a1a;
    }
    
    .mobile-menu .menu-item {
        color: #fff;
        border-bottom-color: #333;
    }
    
    .mobile-card {
        background: #2d2d2d;
        color: #fff;
    }
    
    .mobile-input {
        background: #2d2d2d;
        border-color: #444;
        color: #fff;
    }
    
    .mobile-button.primary {
        background: #0d6efd;
    }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
