/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: 700;
}

.status-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #666;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: #27ae60;
    box-shadow: 0 0 10px rgba(39, 174, 96, 0.5);
}

/* 仪表板样式 */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 采集点选择器 */
.sensor-selector {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.sensor-selector h2 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 25px;
    font-weight: 600;
    text-align: center;
}

.sensor-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.sensor-tab {
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid #e9ecef;
    border-radius: 15px;
    padding: 15px 25px;
    font-size: 1rem;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.sensor-tab:hover {
    background: rgba(52, 152, 219, 0.1);
    border-color: #3498db;
    transform: translateY(-2px);
}

.sensor-tab.active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-color: #3498db;
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
}

/* 采集点详情 */
.sensor-detail {
    display: none;
    flex-direction: column;
    gap: 30px;
}

.sensor-detail.active {
    display: flex;
}

/* 概览部分 */
.overview-section,
.chart-section,
.analysis-section,
.test-section,
.offline-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.overview-section h2,
.chart-section h2,
.analysis-section h2,
.test-section h2,
.offline-section h2 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 25px;
    font-weight: 600;
}

/* 概览网格 */
.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.overview-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 25px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.overview-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #27ae60, #3498db);
}

.overview-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.overview-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.overview-content h3 {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
}

.overview-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.overview-unit {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 15px;
}

.overview-status {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-block;
}

.overview-status.good {
    background: #d4edda;
    color: #155724;
}

.overview-status.moderate {
    background: #fff3cd;
    color: #856404;
}

.overview-status.poor {
    background: #f8d7da;
    color: #721c24;
}

/* 图表网格布局 */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
    margin: 20px 0;
}

/* 图表项目容器 */
.chart-container.chart-item {
    height: 320px;
    position: relative;
    overflow: hidden;
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 0;
}

/* 图表标题 */
.chart-container.chart-item h3 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #2c3e50;
    text-align: center;
    font-weight: 500;
}

/* 图表容器通用样式 */
.chart-container {
    height: 400px;
    position: relative;
    overflow: hidden;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* 移动端响应式 */
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        gap: 15px;
    }
    
    .chart-container.chart-item {
        height: 270px;
        padding: 12px;
    }
    
    .chart-container.chart-item h3 {
        font-size: 13px;
        margin-bottom: 10px;
    }
}

/* 分析网格 */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.analysis-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 25px;
    border: 1px solid #e9ecef;
}

.analysis-card h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.3s ease;
}

.analysis-card h3:hover {
    color: #3498db;
}

/* 时间段分析样式 */
.period-analysis {
    min-height: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.period-analysis:hover {
    background: rgba(52, 152, 219, 0.05);
    border-radius: 8px;
}

/* 加载状态样式 */
.loading-indicator {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

.loading-indicator::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 无数据状态样式 */
.no-data {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

.no-data-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.6;
}

.no-data-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #666;
}

.no-data-desc {
    font-size: 14px;
    color: #999;
}

/* 错误状态样式 */
.error {
    text-align: center;
    padding: 30px 20px;
    color: #e74c3c;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.error-text {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.error-desc {
    font-size: 14px;
    color: #c0392b;
}

/* 数据不足警告样式 */
.insufficient-data {
    text-align: center;
    padding: 20px;
    color: #f39c12;
}

.warning-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.warning-text {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #e67e22;
}

.data-info {
    font-size: 14px;
    margin-bottom: 10px;
    color: #f39c12;
}

.suggestion {
    font-size: 12px;
    color: #95a5a6;
    font-style: italic;
}

/* 数据状态指示器样式 */
.data-status-indicator {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    font-size: 14px;
    border: 1px solid #e9ecef;
}

/* 改进的图表容器样式 */
.chart-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chart-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.chart-container h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

/* 改进的分析卡片样式 */
.analysis-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.analysis-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-color: #3498db;
}

.analysis-card h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

/* 分析结果样式 */
.analysis-content {
    padding: 15px;
}

.overall-score {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 15px;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    color: white;
    margin: 0 auto 10px;
    background: #3498db;
}

.score-circle.good { background: #27ae60; }
.score-circle.moderate { background: #f39c12; }
.score-circle.poor { background: #e74c3c; }
.score-circle.offline { background: #95a5a6; }

.score-label {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.score-info {
    font-size: 14px;
    color: #7f8c8d;
}

.data-count {
    color: #3498db;
    font-weight: 500;
}

/* 指标分析样式 */
.metrics-analysis {
    display: grid;
    gap: 15px;
}

.metric-item {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 15px;
    border-left: 4px solid #3498db;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.metric-label {
    font-weight: 600;
    color: #2c3e50;
}

.metric-status, .metric-rating {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.metric-status.offline { background: #95a5a6; color: white; }
.metric-rating.good { background: #27ae60; color: white; }
.metric-rating.moderate { background: #f39c12; color: white; }
.metric-rating.poor { background: #e74c3c; color: white; }

.metric-details {
    display: grid;
    gap: 8px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.detail-label {
    color: #7f8c8d;
}

.detail-value {
    color: #2c3e50;
    font-weight: 500;
}

.detail-time {
    color: #95a5a6;
    font-size: 12px;
}

.detail-score {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.detail-score.good { background: #27ae60; color: white; }
.detail-score.moderate { background: #f39c12; color: white; }
.detail-score.poor { background: #e74c3c; color: white; }

/* 污染时段样式 */
.pollution-periods {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

.periods-title {
    font-weight: 600;
    color: #e74c3c;
    margin-bottom: 10px;
    font-size: 14px;
}

.period-item {
    background: rgba(231, 76, 60, 0.1);
    color: #c0392b;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 13px;
    text-align: center;
}

/* 质量评估 */
.quality-assessment {
    text-align: center;
}

.quality-score {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 15px;
    border-radius: 50%;
    width: 120px;
    height: 120px;
    line-height: 120px;
    margin: 0 auto 20px;
    color: white;
}

.quality-score.good {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.quality-score.moderate {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.quality-score.poor {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.quality-text {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 25px;
    font-weight: 500;
}

.quality-breakdown {
    text-align: left;
}

.quality-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    margin-bottom: 15px;
}

.item-label {
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
}

.item-score {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 4px 12px;
    border-radius: 15px;
    display: inline-block;
    width: fit-content;
}

.item-score.good {
    background: #d4edda;
    color: #155724;
}

.item-score.moderate {
    background: #fff3cd;
    color: #856404;
}

.item-score.poor {
    background: #f8d7da;
    color: #721c24;
}

.item-desc {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* 趋势分析 */
.trend-analysis {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.trend-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
}

.trend-label {
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
}

.trend-value {
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1rem;
    display: inline-block;
    width: fit-content;
}

.trend-value.improving {
    background: #d4edda;
    color: #155724;
}

.trend-value.stable {
    background: #d1ecf1;
    color: #0c5460;
}

.trend-value.declining {
    background: #f8d7da;
    color: #721c24;
}

.trend-desc {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* 离线状态 */
.offline-section {
    text-align: center;
}

.offline-content {
    max-width: 500px;
    margin: 0 auto;
}

.offline-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    opacity: 0.6;
}

.offline-content h3 {
    font-size: 1.8rem;
    color: #6c757d;
    margin-bottom: 15px;
    font-weight: 600;
}

.offline-content p {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 30px;
    line-height: 1.5;
}

.offline-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.8);
    color: #495057;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #3498db;
    transform: translateY(-2px);
}

/* 测试表单 */
.test-form {
    max-width: 600px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.submit-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(52, 152, 219, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .overview-section,
    .chart-section,
    .analysis-section,
    .test-section,
    .offline-section {
        padding: 20px;
    }
    
    .overview-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 20px;
    }
    
    .analysis-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .analysis-card h3 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .period-analysis {
        min-height: 150px;
    }
    
    .score-circle {
        width: 60px;
        height: 60px;
        font-size: 1.2rem;
    }
    
    .metric-item {
        padding: 12px;
    }
    
    .metric-header {
        margin-bottom: 10px;
    }
    
    .metric-label {
        font-size: 0.9rem;
    }
    
    .metric-rating {
        font-size: 0.7rem;
        padding: 3px 8px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .quality-score {
        font-size: 3rem;
        width: 100px;
        height: 100px;
        line-height: 100px;
    }
    
    .sensor-tabs {
        flex-direction: column;
        align-items: center;
    }
    
    .sensor-tab {
        width: 100%;
        max-width: 200px;
    }
    
    .offline-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .overview-section h2,
    .chart-section h2,
    .analysis-section h2,
    .test-section h2,
    .offline-section h2 {
        font-size: 1.5rem;
    }
    
    .overview-card {
        padding: 20px;
    }
    
    .overview-value {
        font-size: 2rem;
    }
    
    .overview-icon {
        font-size: 2.5rem;
    }
    
    .quality-item {
        padding: 12px;
    }
    
    .trend-item {
        padding: 15px;
    }
}

/* 数据量不足提示样式 */
.insufficient-data {
    text-align: center;
    padding: 20px;
    color: #856404;
}

.insufficient-data .warning-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.insufficient-data .warning-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #856404;
}

.insufficient-data .data-info {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 12px;
    margin: 15px 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.insufficient-data .suggestion {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* 数据点数量显示 */
.data-count {
    font-size: 0.8rem;
    color: #666;
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 5px;
}

.score-info {
    text-align: center;
    margin-top: 10px;
}

.metric-info {
    text-align: center;
    margin-top: 10px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .insufficient-data {
        padding: 15px;
    }
    
    .insufficient-data .warning-icon {
        font-size: 1.5rem;
        margin-bottom: 8px;
    }
    
    .insufficient-data .warning-text {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .insufficient-data .data-info {
        padding: 10px;
        margin: 12px 0;
        font-size: 0.8rem;
    }
    
    .insufficient-data .suggestion {
        font-size: 0.8rem;
    }
    
    .data-count {
        font-size: 0.7rem;
        padding: 1px 6px;
    }
}
