/* 千年经济分析系统 - 移动端响应式优化 */

/* 基础移动端适配 */
@media (max-width: 768px) {
    /* 全局字体和间距调整 */
    body {
        font-size: 14px;
        line-height: 1.5;
    }

    /* 容器和布局优化 */
    .max-w-7xl {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* 导航栏移动端优化 */
    header .flex {
        flex-wrap: wrap;
    }

    header h1 {
        font-size: 1.5rem;
    }

    /* 隐藏桌面导航，显示移动端菜单 */
    nav.hidden.md\\:flex {
        display: none !important;
    }

    /* 移动端汉堡菜单 */
    .mobile-menu-button {
        display: block !important;
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
    }

    .mobile-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        z-index: 50;
    }

    .mobile-menu a {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid #f3f4f6;
        color: #374151;
        text-decoration: none;
    }

    .mobile-menu a:hover {
        background-color: #f9fafb;
    }

    /* 英雄区域移动端优化 */
    .bg-gradient-to-br {
        padding: 3rem 0;
    }

    .text-5xl {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .text-xl {
        font-size: 1.125rem;
    }

    /* 按钮组移动端优化 */
    .flex.justify-center.space-x-4 {
        flex-direction: column;
        space-x: 0;
        gap: 1rem;
    }

    .flex.justify-center.space-x-4 a {
        width: 100%;
        text-align: center;
    }

    /* 网格布局移动端优化 */
    .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
        gap: 1.5rem;
    }

    .grid.grid-cols-1.md\\:grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .grid.grid-cols-1.lg\\:grid-cols-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    /* 卡片组件移动端优化 */
    .bg-white.rounded-lg.shadow-sm {
        margin-bottom: 1rem;
        padding: 1rem;
    }

    /* 图表容器移动端优化 */
    canvas {
        max-width: 100%;
        height: auto !important;
        min-height: 250px;
    }

    .chart-container {
        overflow-x: auto;
        padding-bottom: 1rem;
    }

    /* 表格移动端优化 */
    table {
        font-size: 0.875rem;
        min-width: 100%;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive table {
        min-width: 600px;
    }

    /* 时间轴移动端优化 */
    .timeline-container {
        padding: 1rem 0;
    }

    .timeline-slider {
        width: 100%;
        margin: 1rem 0;
    }

    .timeline-labels {
        display: flex;
        justify-content: space-between;
        font-size: 0.75rem;
        margin-top: 0.5rem;
    }

    /* 因子控制器移动端优化 */
    .factor-controls {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .factor-item {
        background: #f9fafb;
        padding: 1rem;
        border-radius: 0.5rem;
        border: 1px solid #e5e7eb;
    }

    .factor-slider {
        width: 100%;
        margin: 0.5rem 0;
    }

    /* 导出按钮移动端优化 */
    .export-button {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
        width: 100%;
        justify-content: center;
    }

    .export-menu {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto !important;
        border-radius: 1rem 1rem 0 0;
        max-height: 50vh;
        overflow-y: auto;
    }

    /* 通知系统移动端优化 */
    .notification {
        left: 1rem;
        right: 1rem;
        width: auto;
        max-width: none;
    }

    /* 模态框移动端优化 */
    .modal {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    /* 底部导航优化 */
    footer {
        padding: 2rem 0;
    }

    footer .grid {
        grid-template-columns: repeat(1, minmax(0, 1fr));
        gap: 2rem;
        text-align: center;
    }
}

/* 小屏幕设备优化 (320px - 480px) */
@media (max-width: 480px) {
    .text-5xl {
        font-size: 2rem;
    }

    .text-3xl {
        font-size: 1.75rem;
    }

    .text-2xl {
        font-size: 1.5rem;
    }

    .px-8 {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .py-20 {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .py-16 {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    /* 图标尺寸调整 */
    .w-20.h-20 {
        width: 4rem;
        height: 4rem;
    }

    .w-10.h-10 {
        width: 2rem;
        height: 2rem;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    /* 增大可点击区域 */
    button, a, input[type="range"] {
        min-height: 44px;
        min-width: 44px;
    }

    /* 移除hover效果 */
    .hover\\:bg-blue-700:hover {
        background-color: inherit;
    }

    .hover\\:text-gray-700:hover {
        color: inherit;
    }

    .hover\\:scale-110:hover {
        transform: none;
    }

    /* 添加触摸反馈 */
    button:active, a:active {
        transform: scale(0.95);
        transition: transform 0.1s;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .bg-gradient-to-br {
        padding: 2rem 0;
    }

    .text-5xl {
        font-size: 2rem;
    }

    canvas {
        min-height: 200px;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* 移动端专用工具类 */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }

    .desktop-only {
        display: none;
    }

    .mobile-flex {
        display: flex;
    }

    .mobile-grid {
        display: grid;
    }

    .mobile-hidden {
        display: none;
    }

    .mobile-full-width {
        width: 100%;
    }

    .mobile-text-center {
        text-align: center;
    }

    .mobile-p-4 {
        padding: 1rem;
    }

    .mobile-m-2 {
        margin: 0.5rem;
    }

    .mobile-text-sm {
        font-size: 0.875rem;
    }
}

/* 滑动手势支持 */
.swipe-container {
    touch-action: pan-x;
    overflow-x: hidden;
}

.swipe-item {
    transition: transform 0.3s ease;
}

/* 移动端加载动画 */
.mobile-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.mobile-loading::after {
    content: '';
    width: 2rem;
    height: 2rem;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 移动端表单优化 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #e5e7eb;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 移动端安全区域适配 */
@supports (padding: max(0px)) {
    .safe-area-inset {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}
