/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --accent-color: #007bff;
    --chart-bg: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    --accent-color: #4dabf7;
    --chart-bg: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SimHei', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 主题切换 */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.theme-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px var(--shadow);
}

.theme-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--shadow);
}

/* 头部导航 */
.header {
    background: var(--bg-secondary);
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header h1 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    justify-content: center;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-list li {
    background: var(--bg-primary);
    border-radius: 25px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.nav-list a {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    white-space: nowrap;
}

.nav-list a:hover {
    background: var(--accent-color);
    color: white;
}

/* 主要内容 */
.main-content {
    padding-bottom: 50px;
}

.chart-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 15px var(--shadow);
    border: 1px solid var(--border-color);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.chart-header h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.edit-btn, .refresh-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.edit-btn:hover, .refresh-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

/* 图表容器 */
.chart-container {
    background: var(--chart-bg);
    border-radius: 8px;
    padding: 20px;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--border-color);
}

.chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

.chart-container > div {
    width: 100%;
    height: 400px;
}

/* 数据编辑器 */
.data-editor {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-editor h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.data-editor textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.data-editor button {
    margin-top: 10px;
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.data-editor button:hover {
    background: #0056b3;
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: none;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 15px var(--shadow);
}

.back-to-top:hover {
    background: #0056b3;
    transform: translateY(-3px);
}

.back-to-top.show {
    display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .nav-list {
        gap: 5px;
    }
    
    .nav-list a {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .chart-section {
        padding: 20px;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-container > div {
        height: 300px;
    }
    
    .theme-toggle {
        top: 10px;
        right: 10px;
    }
    
    .theme-btn {
        padding: 8px 16px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .chart-section {
        padding: 15px;
    }
    
    .chart-header h2 {
        font-size: 1.2rem;
    }
    
    .nav-list {
        max-height: 200px;
        overflow-y: auto;
    }
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
}

/* 加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chart-section {
    animation: fadeIn 0.6s ease-out;
}

/* 图表特定样式 */
#contourChart, #stemChart, #dumbbellChart, #pyramidChart, #funnelChart, #waffleChart {
    max-height: 500px;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 选择文本的样式 */
::selection {
    background: var(--accent-color);
    color: white;
}