/* ========================================
   移动端增强样式
   专注于移动设备的交互和体验优化
   ======================================== */

/* 移动端滚动优化 */
@media (max-width: 768px) {
    /* 平滑滚动 */
    html {
        scroll-behavior: smooth;
    }
    
    /* iOS 弹性滚动 */
    body,
    .content-container,
    .modal-box,
    .sidebar {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 防止过度滚动 */
    body {
        overscroll-behavior-y: contain;
    }
}

/* 移动端手势优化 */
@media (max-width: 768px) {
    /* 可点击元素 */
    .btn,
    .nav-item,
    .action-btn,
    .card,
    .stat-card,
    .mini-stat-card {
        -webkit-tap-highlight-color: rgba(79, 70, 229, 0.1);
        tap-highlight-color: rgba(79, 70, 229, 0.1);
    }
    
    /* 链接和按钮点击反馈 */
    .btn:active,
    .nav-item:active,
    .action-btn:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }
    
    /* 卡片点击反馈 */
    .stat-card:active,
    .mini-stat-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* 移动端导航优化 */
@media (max-width: 768px) {
    /* 侧边栏动画 */
    .sidebar {
        will-change: transform;
    }
    
    /* 移动端菜单按钮脉冲效果 */
    @keyframes pulse {
        0%, 100% { transform: scale(1); }
        50% { transform: scale(1.05); }
    }
    
    .mobile-menu-btn.has-notification {
        animation: pulse 2s infinite;
    }
    
    /* 侧边栏导航项增强 */
    .nav-item {
        position: relative;
        overflow: hidden;
    }
    
    .nav-item::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        transform: translate(-50%, -50%);
        transition: width 0.3s, height 0.3s;
    }
    
    .nav-item:active::after {
        width: 200px;
        height: 200px;
    }
}

/* 移动端表格卡片式布局增强 */
@media (max-width: 768px) {
    .data-table tr {
        position: relative;
        overflow: hidden;
    }
    
    .data-table tr::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 4px;
        background: var(--primary-color);
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    .data-table tr:active::before {
        opacity: 1;
    }
    
    /* 表格数据展示优化 */
    .data-table td {
        word-break: break-word;
    }
    
    .data-table td:before {
        min-width: 100px;
    }
}

/* 移动端模态框增强 */
@media (max-width: 768px) {
    .modal-overlay {
        backdrop-filter: blur(8px);
    }
    
    .modal-box {
        animation: slideUpModal 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* 模态框关闭手势 */
    .modal-header {
        cursor: grab;
    }
    
    .modal-header:active {
        cursor: grabbing;
    }
}

/* 移动端加载状态 */
@media (max-width: 768px) {
    .loading-spinner {
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    /* 骨架屏样式 */
    .skeleton {
        background: linear-gradient(
            90deg,
            var(--bg-secondary) 25%,
            var(--bg-tertiary) 50%,
            var(--bg-secondary) 75%
        );
        background-size: 200% 100%;
        animation: shimmer 1.5s infinite;
        border-radius: var(--radius-md);
    }
    
    @keyframes shimmer {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
    
    .skeleton-card {
        height: 100px;
        margin-bottom: 12px;
    }
    
    .skeleton-text {
        height: 16px;
        margin-bottom: 8px;
    }
}

/* 移动端底部操作栏 - 仅在需要时显示 */
@media (max-width: 768px) {
    .mobile-bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid var(--border-color);
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom)); /* iOS安全区域 */
        display: none; /* 默认隐藏，需要时显示 */
        gap: 10px;
        z-index: 998;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        animation: slideUp 0.3s ease;
    }
    
    .mobile-bottom-bar.show {
        display: flex;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .mobile-bottom-bar .btn {
        flex: 1;
        margin: 0;
    }
}

/* 移动端下拉刷新 */
@media (max-width: 768px) {
    .pull-to-refresh {
        position: absolute;
        top: -60px;
        left: 0;
        right: 0;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-size: 14px;
        transition: var(--transition);
    }
    
    .pull-to-refresh.active {
        top: 0;
    }
    
    .pull-to-refresh-icon {
        animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
}

/* 移动端图片查看器 */
@media (max-width: 768px) {
    .image-viewer {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.95);
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
    }
    
    .image-viewer img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        touch-action: pinch-zoom;
    }
    
    .image-viewer-close {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        background: rgba(255, 255, 255, 0.2);
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 24px;
        cursor: pointer;
        backdrop-filter: blur(10px);
    }
}

/* 移动端浮动操作按钮 */
@media (max-width: 768px) {
    .fab {
        position: fixed;
        right: 16px;
        bottom: 80px;
        width: 56px;
        height: 56px;
        background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
        border: none;
        border-radius: 50%;
        color: white;
        font-size: 24px;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 997;
        transition: var(--transition);
    }
    
    .fab:active {
        transform: scale(0.9);
    }
    
    .fab:hover {
        box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
    }
}

/* 移动端空状态 */
@media (max-width: 768px) {
    .empty-state {
        padding: 40px 20px;
        text-align: center;
    }
    
    .empty-state-icon {
        width: 80px;
        height: 80px;
        margin: 0 auto 20px;
        background: var(--bg-secondary);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 40px;
        color: var(--text-tertiary);
    }
    
    .empty-state-title {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 8px;
    }
    
    .empty-state-desc {
        font-size: 14px;
        color: var(--text-secondary);
        margin-bottom: 20px;
    }
}

/* 移动端提示气泡 */
@media (max-width: 768px) {
    .tooltip-mobile {
        position: absolute;
        background: rgba(0, 0, 0, 0.9);
        color: white;
        padding: 8px 12px;
        border-radius: var(--radius-md);
        font-size: 12px;
        white-space: nowrap;
        pointer-events: none;
        z-index: 10000;
        animation: tooltipFade 0.2s ease;
    }
    
    @keyframes tooltipFade {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* 移动端徽章 */
@media (max-width: 768px) {
    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    .badge-dot {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--danger-color);
        position: absolute;
        top: 0;
        right: 0;
    }
}

/* 移动端进度条 */
@media (max-width: 768px) {
    .progress-bar {
        height: 6px;
        background: var(--bg-tertiary);
        border-radius: 3px;
        overflow: hidden;
    }
    
    .progress-bar-fill {
        height: 100%;
        background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
        border-radius: 3px;
        transition: width 0.3s ease;
    }
}

/* 移动端分段控制器 */
@media (max-width: 768px) {
    .segment-control {
        display: flex;
        background: var(--bg-secondary);
        border-radius: var(--radius-md);
        padding: 4px;
        gap: 4px;
    }
    
    .segment-control-item {
        flex: 1;
        padding: 10px;
        text-align: center;
        border: none;
        background: transparent;
        color: var(--text-secondary);
        font-size: 14px;
        font-weight: 500;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: var(--transition);
    }
    
    .segment-control-item.active {
        background: white;
        color: var(--primary-color);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
}

/* 移动端性能优化 */
@media (max-width: 768px) {
    /* GPU 加速 */
    .sidebar,
    .modal-box,
    .btn,
    .stat-card {
        will-change: transform;
        transform: translateZ(0);
        backface-visibility: hidden;
    }
    
    /* 减少重绘 */
    .data-table tr,
    .card,
    .mini-stat-card {
        contain: layout style paint;
    }
}

/* 移动端可访问性 */
@media (max-width: 768px) {
    /* 焦点可见性 */
    .btn:focus-visible,
    .form-control:focus-visible,
    .nav-item:focus-visible {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* 屏幕阅读器优化 */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* 移动端打印优化 */
@media print {
    .mobile-header,
    .sidebar,
    .fab,
    .mobile-bottom-bar,
    .action-btn {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

