/* 第5章数据可视化平台 - 完整样式 */

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 顶部控制面板 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.control-group select {
    padding: 0.6rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.control-group select:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 按钮样式 */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* 主要内容区域 */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

/* 主题部分 */
.theme-section {
    display: none;
    animation: fadeIn 0.8s ease-out;
}

.theme-section.active {
    display: block;
}

.theme-header {
    text-align: center;
    margin-bottom: 3rem;
    color: white;
}

.theme-header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.theme-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 图表网格布局 */
.charts-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    transition: all 0.3s ease;
}

.charts-grid.layout-1x1 {
    grid-template-columns: 1fr;
}

.charts-grid.layout-1x2 {
    grid-template-columns: repeat(2, 1fr);
}

.charts-grid.layout-2x2 {
    grid-template-columns: repeat(2, 1fr);
}

.charts-grid.layout-auto {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* 图表容器 */
.chart-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    min-height: 400px;
}

.chart-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.chart-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.chart-type-selector {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    min-width: 100px;
}

.chart-type-selector:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.chart-type-selector:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.chart-type-selector option {
    background: #667eea;
    color: white;
    padding: 0.4rem;
}

.chart {
    width: 100%;
    height: 350px;
    position: relative;
}

/* 页脚 */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: #666;
}

/* 通知系统 */
.notification-container {
    position: fixed;
    top: 100px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 350px;
}

.notification {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #667eea;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
    transition: all 0.3s ease;
}

.notification-success {
    border-left-color: #10b981;
    background: linear-gradient(to right, rgba(16, 185, 129, 0.1), white);
}

.notification-error {
    border-left-color: #ef4444;
    background: linear-gradient(to right, rgba(239, 68, 68, 0.1), white);
}

.notification-info {
    border-left-color: #3b82f6;
    background: linear-gradient(to right, rgba(59, 130, 246, 0.1), white);
}

.notification:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-grid.layout-2x2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .theme-header h2 {
        font-size: 2rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .charts-grid.layout-1x2,
    .charts-grid.layout-2x2 {
        grid-template-columns: 1fr;
    }
    
    .chart {
        height: 300px;
    }
    
    .notification-container {
        left: 15px;
        right: 15px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.4rem;
    }
    
    .controls {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }
    
    .control-group {
        width: 100%;
        justify-content: center;
    }
    
    .control-group select {
        flex: 1;
        max-width: 200px;
    }
    
    .chart {
        height: 250px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .header,
    .footer {
        background: rgba(17, 24, 39, 0.95);
    }
    
    .chart-container {
        background: #1f2937;
        color: white;
    }
    
    .chart-header {
        background: linear-gradient(135deg, #3730a3, #6b21a8);
    }
    
    .control-group select {
        background: #374151;
        color: white;
        border-color: #4b5563;
    }
    
    .notification {
        background: #1f2937;
        color: white;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .chart-container {
        border: 2px solid #333;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 打印样式 */
@media print {
    .header,
    .footer,
    .notification-container {
        display: none;
    }
    
    .main {
        padding: 0;
    }
    
    .chart-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
        margin-bottom: 1rem;
    }
}

/* 无障碍支持 */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 焦点样式 */
.btn:focus,
.control-group select:focus,
.chart-type-selector:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* 加载状态 */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 错误状态 */
.error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* 成功状态 */
.success {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

/* 性能优化 */
.chart-container {
    will-change: transform;
}

.chart {
    contain: layout style paint;
}

/* 触摸设备优化 */
@media (hover: none) {
    .chart-container:hover,
    .btn:hover,
    .control-group select:hover {
        transform: none;
    }
}