/* 响应式设计和移动端优化样式 */

/* 基础响应式设置 */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* 移动端基础样式 */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    body {
        padding-top: 60px; /* 为移动端导航栏留出空间 */
    }
    
    /* 隐藏桌面端元素 */
    .desktop-only {
        display: none !important;
    }
    
    /* 移动端专用元素 */
    .mobile-only {
        display: block !important;
    }
    
    /* 主容器优化 */
    .main-container {
        flex-direction: column;
        height: calc(100vh - 60px);
    }
    
    /* 搜索区域优化 */
    .search-container {
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 10;
        background: rgba(17, 24, 39, 0.95);
        backdrop-filter: blur(10px);
    }
    
    .search-input {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px 16px;
        border-radius: 12px;
        width: 100%;
    }
    
    /* 搜索结果区域 */
    .search-results {
        padding: 0.5rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 卡片样式优化 */
    .result-card {
        margin-bottom: 0.75rem;
        padding: 1rem;
        border-radius: 12px;
        background: rgba(31, 41, 55, 0.8);
        border: 1px solid rgba(75, 85, 99, 0.3);
        backdrop-filter: blur(8px);
        transition: all 0.2s ease;
    }
    
    .result-card:active {
        transform: scale(0.98);
        background: rgba(31, 41, 55, 0.9);
    }
    
    /* 按钮优化 */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.2s ease;
        touch-action: manipulation;
        user-select: none;
    }
    
    .btn:active {
        transform: scale(0.95);
    }
    
    /* 表格响应式 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 600px;
        font-size: 12px;
    }
    
    .table-responsive th,
    .table-responsive td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    
    /* 模态框优化 */
    .modal {
        padding: 1rem;
    }
    
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 16px;
        margin: 0;
        width: 100%;
    }
    
    /* 图表容器优化 */
    .chart-container {
        width: 100%;
        height: 300px;
        margin: 1rem 0;
        overflow: hidden;
        border-radius: 12px;
    }
    
    /* 文本优化 */
    .text-responsive {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .title-responsive {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 0.5rem;
    }
    
    /* 间距优化 */
    .spacing-mobile {
        padding: 0.75rem;
        margin: 0.5rem 0;
    }
}

/* 平板端优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    html {
        font-size: 15px;
    }
    
    .tablet-only {
        display: block !important;
    }
    
    .mobile-only {
        display: none !important;
    }
    
    /* 两栏布局 */
    .main-container {
        display: flex;
        flex-direction: row;
    }
    
    .left-panel {
        width: 45%;
        border-right: 1px solid rgba(75, 85, 99, 0.3);
    }
    
    .right-panel {
        width: 55%;
    }
    
    /* 卡片网格 */
    .card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem;
    }
    
    /* 图表优化 */
    .chart-container {
        height: 350px;
    }
}

/* 桌面端优化 */
@media (min-width: 1025px) {
    .desktop-only {
        display: block !important;
    }
    
    .mobile-only,
    .tablet-only {
        display: none !important;
    }
    
    /* 三栏布局 */
    .main-container {
        display: flex;
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .left-panel {
        width: 35%;
        min-width: 400px;
    }
    
    .right-panel {
        width: 65%;
    }
    
    /* 卡片网格 */
    .card-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
        padding: 1.5rem;
    }
    
    /* 图表优化 */
    .chart-container {
        height: 400px;
    }
    
    /* 悬停效果 */
    .result-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        border-color: rgba(59, 130, 246, 0.5);
    }
    
    .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* 超大屏幕优化 */
@media (min-width: 1440px) {
    .main-container {
        max-width: 1600px;
    }
    
    .card-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .chart-container {
        height: 450px;
    }
}

/* 移动端导航栏 */
.mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    z-index: 1000;
    display: none;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
    }
}

.mobile-nav-title {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.mobile-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-nav-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: white;
    transition: background-color 0.2s ease;
}

.mobile-nav-btn:active {
    background: rgba(75, 85, 99, 0.5);
}

/* 移动端侧边栏 */
.mobile-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: rgba(17, 24, 39, 0.98);
    backdrop-filter: blur(10px);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-sidebar.open {
    transform: translateX(0);
}

.mobile-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(75, 85, 99, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-sidebar-content {
    padding: 1rem;
}

.mobile-sidebar-section {
    margin-bottom: 2rem;
}

.mobile-sidebar-title {
    font-size: 16px;
    font-weight: 600;
    color: white;
    margin-bottom: 1rem;
}

/* 移动端遮罩 */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 触摸优化 */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 滚动优化 */
.smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* 性能优化 */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform {
    will-change: transform;
}

/* 加载动画 */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 淡入动画 */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滑入动画 */
.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

/* 弹性动画 */
.bounce-in {
    animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 暗色主题优化 */
.dark-theme {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --border-primary: #30363d;
    --border-secondary: #21262d;
    --accent-primary: #3b82f6;
    --accent-secondary: #1d4ed8;
}

/* 可访问性优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .result-card {
        border-width: 2px;
        border-color: #ffffff;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* 打印样式 */
@media print {
    .mobile-nav,
    .mobile-sidebar,
    .mobile-overlay,
    .btn,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
        padding: 0 !important;
    }
    
    .result-card {
        border: 1px solid #000;
        margin-bottom: 1rem;
        break-inside: avoid;
    }
}

/* 横屏优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-nav {
        height: 50px;
    }
    
    body {
        padding-top: 50px;
    }
    
    .search-container {
        padding: 0.5rem 1rem;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
    
    .mobile-sidebar {
        width: 280px;
    }
    
    .result-card {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .chart-container {
        height: 250px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 360px) {
    .mobile-sidebar {
        width: 260px;
    }
    
    .mobile-nav-title {
        font-size: 16px;
    }
    
    .result-card {
        padding: 0.5rem;
    }
}