/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 根变量定义 */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --accent-color: #C71585;
    --success-color: #008B8B;
    --warning-color: #FFA500;
    --danger-color: #DC143C;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
    --border-radius: 15px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 基础样式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background: var(--background-gradient);
    min-height: 100vh;
    position: relative;
}

/* 加载指示器 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--light-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 头部样式 */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 2rem 0;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

header h1 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--background-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 0 2rem;
}

nav a {
    color: var(--dark-color);
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    transition: var(--transition);
    background: rgba(102, 126, 234, 0.05);
    border: 2px solid transparent;
    display: inline-block;
}

nav a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* 主内容区域 */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* 可视化部分 */
.visualization-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
    animation: fadeInUp 0.8s ease-out;
    transition: var(--transition);
}

.visualization-section:hover {
    transform: translateY(-5px);
    box-shadow: var(--hover-shadow);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.visualization-section h2 {
    color: var(--dark-color);
    margin-bottom: 1rem;
    font-size: 2rem;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

.visualization-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--background-gradient);
    border-radius: 2px;
}

.chart-description {
    text-align: center;
    color: #666;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.chart-container {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
}

canvas {
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    display: block;
}

/* 控制按钮 */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.controls button {
    background: var(--background-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.controls button:hover::before {
    left: 100%;
}

.controls button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.controls button:active {
    transform: translateY(-1px);
}

/* 统计部分 */
.stats-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
}

.stats-section h2 {
    color: var(--dark-color);
    margin-bottom: 2rem;
    font-size: 2rem;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

.stats-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--background-gradient);
    border-radius: 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(102, 126, 234, 0.1));
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--background-gradient);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.25);
}

.stat-card h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.8rem 0;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
    font-weight: 500;
}

.stat-value {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
}

/* 控制面板 */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--card-shadow);
    text-align: center;
}

.control-panel h2 {
    color: var(--dark-color);
    margin-bottom: 2rem;
    font-size: 2rem;
    position: relative;
    padding-bottom: 1rem;
}

.control-panel h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--background-gradient);
    border-radius: 2px;
}

.panel-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.panel-buttons button {
    background: var(--background-gradient);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
    min-width: 160px;
}

.panel-buttons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

/* 页脚 */
footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    text-align: center;
    padding: 2.5rem;
    margin-top: 3rem;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.footer-content p {
    color: var(--dark-color);
    margin: 0.5rem 0;
    opacity: 0.8;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1.5rem 0;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    nav ul {
        gap: 1rem;
        padding: 0 1rem;
    }
    
    nav a {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    main {
        padding: 1.5rem;
    }
    
    .visualization-section,
    .stats-section,
    .control-panel {
        padding: 2rem;
    }
    
    .visualization-section h2,
    .stats-section h2,
    .control-panel h2 {
        font-size: 1.5rem;
    }
    
    .chart-container {
        min-height: 400px;
    }
    
    canvas {
        max-height: 400px;
    }
    
    .controls button {
        padding: 0.7rem 1.3rem;
        font-size: 0.85rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .panel-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .panel-buttons button {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls button {
        margin-bottom: 0.5rem;
    }
}

/* 打印样式 */
@media print {
    body {
        background: white;
    }
    
    .loading-overlay {
        display: none;
    }
    
    .controls,
    .control-panel {
        display: none;
    }
    
    .visualization-section {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    footer {
        display: none;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .visualization-section,
    .stats-section,
    .control-panel,
    footer {
        background: white;
        border: 2px solid black;
    }
    
    body {
        background: white;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-color: #ecf0f1;
        --light-color: #2c3e50;
    }
    
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .visualization-section,
    .stats-section,
    .control-panel,
    footer {
        background: rgba(44, 62, 80, 0.95);
        color: var(--dark-color);
    }
    
    .chart-container {
        background: #34495e;
    }
}