/* 现代统计区域样式 */
.stats-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-radius: 20px !important;
    padding: 40px !important;
    margin: 40px 0 !important;
    box-shadow: 0 15px 45px rgba(102, 126, 234, 0.3) !important;
    animation: fadeIn 0.8s ease-out !important;
    position: relative !important;
    overflow: hidden !important;
}

/* 背景装饰 */
.stats-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
    z-index: 0;
}

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

.stats-section h2, .section-title {
    font-size: 36px !important;
    font-weight: 700 !important;
    color: #fff !important;
    margin-bottom: 30px !important;
    padding-bottom: 20px !important;
    border-bottom: 3px solid rgba(255, 255, 255, 0.2) !important;
    text-align: center !important;
    letter-spacing: 1px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* 统计卡片网格 */
.stats-cards {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
    gap: 25px !important;
    margin-bottom: 40px !important;
    position: relative !important;
    z-index: 1 !important;
}

/* 统一的统计卡片样式 */
.stat-card, .stats-card {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 16px !important;
    padding: 25px !important;
    text-align: center !important;
    transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1) !important;
    position: relative !important;
    overflow: hidden !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    z-index: 1 !important;
}

.stat-card::before, .stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    z-index: 2;
}

.stat-card:hover, .stats-card:hover {
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.2) !important;
    background: rgba(255, 255, 255, 1) !important;
}

/* 统计卡片图标 */
.stats-card-icon {
    width: 60px !important;
    height: 60px !important;
    margin: 0 auto 20px !important;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    font-size: 0 !important;
    padding: 0 !important;
}

.stats-card-icon i {
    font-size: 28px !important;
    color: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 统计卡片内容 */
.stats-card-content {
    text-align: center !important;
    flex: none !important;
    width: 100% !important;
}

.stat-number, .stats-card-value {
    font-size: 42px !important;
    font-weight: 800 !important;
    margin-bottom: 10px !important;
    font-variant-numeric: tabular-nums !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    letter-spacing: -1px !important;
    line-height: 1.2 !important;
}

.stat-label, .stats-card-title {
    font-size: 16px !important;
    color: #666 !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin: 0 !important;
}

/* 图表容器样式 */
.stats-charts {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 25px !important;
    margin-top: 10px !important;
    position: relative !important;
    z-index: 1 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

.chart-container {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 16px !important;
    padding: 15px 20px !important; /* 调整内边距 */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    overflow: hidden !important; /* 防止内容溢出 */
    min-height: 260px !important; /* 调整最小高度 */
    display: flex !important;
    flex-direction: column !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    z-index: 1 !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* 确保图表容器内容占据所有可用空间 */
.chart-container > * {
    flex: 1 1 auto !important;
}

/* 每日趋势图表特定样式 */
#daily-chart {
    width: 100% !important;
    height: 300px !important;
    min-height: 300px !important;
    display: block !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    overflow: hidden !important;
}

/* 每日柱状图容器样式 */
.daily-bar-chart {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-around !important;
    padding: 20px 10px !important;
    position: relative !important;
    background: transparent !important;
}

/* 独立统计页面专用样式 */
.stats-container {
    max-width: 1200px !important;
    margin: 0 auto !important;
}

/* 筛选器区域样式 */
.filters {
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 16px !important;
    padding: 25px !important;
    margin-bottom: 25px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    position: relative !important;
    overflow: hidden !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 1rem !important;
    align-items: center !important;
}

/* 时间范围按钮样式 */
.time-range-buttons {
    display: flex !important;
    gap: 0.5rem !important;
    flex-wrap: wrap !important;
}

.time-btn {
    padding: 0.5rem 1rem !important;
    border: 1px solid #d1d5db !important;
    border-radius: 0.375rem !important;
    background: white !important;
    color: #374151 !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    outline: none !important;
}

.time-btn:hover {
    background: #f9fafb !important;
    border-color: #9ca3af !important;
}

.time-btn.active,
.time-btn.bg-blue-50 {
    background: #eff6ff !important;
    border-color: #3b82f6 !important;
    color: #2563eb !important;
}

.time-btn.text-blue-600 {
    color: #2563eb !important;
}

.time-btn.border-blue-500 {
    border-color: #3b82f6 !important;
}

.filters::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.filter-group {
    min-width: 150px !important;
}

.filter-group label {
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 0.5rem !important;
    display: block !important;
}

.filter-group select {
    width: 100% !important;
    padding: 0.75rem !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    background: white !important;
    font-size: 0.875rem !important;
    transition: all 0.3s ease !important;
}

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

.refresh-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 0.75rem 1.5rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3) !important;
}

.refresh-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4) !important;
}

.refresh-btn i {
    margin-right: 0.5rem !important;
}

/* 统计卡片网格布局 */
.stats-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important;
    gap: 25px !important;
    margin-bottom: 25px !important;
}

.charts-row {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)) !important;
    gap: 25px !important;
    margin-bottom: 25px !important;
}

/* 平台趋势图网格 */
.platform-trends-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
    gap: 25px !important;
}

.platform-trend-card {
    background: white !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
    padding: 25px !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.platform-trend-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15) !important;
}

/* 数据来源样式 */
.data-source {
    font-size: 0.75rem !important;
    color: #999 !important;
    text-align: right !important;
    margin-top: 10px !important;
    font-style: italic !important;
}

/* 加载指示器样式 */
.loading-indicator {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    height: 200px !important;
    color: #666 !important;
    font-size: 1rem !important;
}

.loading-indicator i {
    margin-right: 0.75rem !important;
    animation: spin 1s linear infinite !important;
    font-size: 1.25rem !important;
    color: #667eea !important;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* 关键词趋势样式 */
.trending-content {
    max-height: 500px !important;
    overflow-y: auto !important;
}

.trend-item {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1rem !important;
    border-bottom: 1px solid #f0f0f0 !important;
    transition: all 0.2s ease !important;
}

.trend-item:last-child {
    border-bottom: none !important;
}

.trend-item:hover {
    background-color: #f9f9f9 !important;
    transform: translateX(5px) !important;
}

.trend-rank {
    font-weight: 700 !important;
    color: #667eea !important;
    margin-right: 1rem !important;
    min-width: 24px !important;
    text-align: center !important;
    font-size: 1.125rem !important;
}

.trend-rank:nth-child(1) {
    color: #ff6b6b !important;
}

.trend-rank:nth-child(2) {
    color: #feca57 !important;
}

.trend-rank:nth-child(3) {
    color: #ff9ff3 !important;
}

.trend-content {
    flex: 1 !important;
}

.trend-title {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    color: #333 !important;
    margin-bottom: 0.25rem !important;
    line-height: 1.4 !important;
}

.trend-meta {
    font-size: 0.75rem !important;
    color: #999 !important;
}

.trend-change {
    display: flex !important;
    align-items: center !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    min-width: 60px !important;
    justify-content: flex-end !important;
}

.trend-change.positive {
    color: #10ac84 !important;
}

.trend-change.negative {
    color: #ee5a24 !important;
}

.trend-change i {
    margin-right: 0.25rem !important;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .charts-row {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .stats-grid {
        gap: 20px !important;
    }
    
    .filters {
        padding: 20px !important;
    }
    
    .filter-group {
        min-width: 100% !important;
        margin-bottom: 1rem !important;
    }
    
    .refresh-btn {
        margin-left: 0 !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    .platform-trends-grid {
        grid-template-columns: 1fr !important;
    }
    
    .time-range-buttons {
        width: 100% !important;
        justify-content: space-between !important;
    }
    
    .time-btn {
        flex: 1 !important;
        text-align: center !important;
        padding: 0.5rem 0.75rem !important;
    }
}

/* 打印友好样式 */
@media print {
    .stats-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid !important;
    }
    
    .filters {
        display: none !important;
    }
    
    .chart-container {
        page-break-inside: avoid !important;
        height: 400px !important;
    }
}

.chart-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    z-index: 2;
}

.chart-container:hover {
    transform: translateY(-5px) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15) !important;
}

.chart-container h3, .chart-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #333 !important;
    margin-bottom: 15px !important; /* 增加底部边距 */
    text-align: center !important; /* 确保标题居中 */
    position: relative !important;
    padding-bottom: 5px !important;
    border: none !important;
    margin-top: 5px !important;
}

.chart-container h3::after, .chart-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 2px;
}

/* 图表容器 - 优化饼图显示 */
#platform-chart {
    width: 100% !important;
    height: 300px !important; /* 增加固定高度 */
    flex: 1 !important;
    position: relative !important;
    overflow: visible !important; /* 避免内容被截断 */
    box-sizing: border-box !important;
    margin: 0 auto !important; /* 水平居中 */
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* 为平台图表容器添加额外样式以适应底部图例 */
.chart-container.platform-chart-container {
    min-height: 350px !important; /* 增加最小高度 */
}

#daily-chart {
    max-height: 240px !important;
    width: 100% !important;
    flex: 1 !important;
    position: relative !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* 确保图表容器内的canvas元素不会产生额外空白 */
#platform-chart canvas {
    display: block !important;
    margin: 0 auto !important; /* 居中 */
    padding: 0 !important;
    max-width: 100% !important;
    max-height: 280px !important; /* 增加最大高度 */
}

#daily-chart canvas {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-height: 200px !important; /* 调整高度 */
    width: 100% !important;
}

/* 图表加载状态 */
.chart-loading {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    height: 200px !important;
    color: #666 !important;
    animation: pulse 1.5s infinite !important;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* 响应式设计 - 平板和小屏幕 */
@media (max-width: 768px) {
    .stats-section {
        padding: 25px 20px !important;
    }
    
    .stats-section h2, .section-title {
        font-size: 28px !important;
    }
    
    .stats-cards {
        gap: 20px !important;
    }
    
    .stats-charts {
        grid-template-columns: 1fr !important;
        gap: 25px !important;
    }
    
    .chart-container {
        min-height: 300px !important;
        padding: 20px 15px !important; /* 减少内边距 */
    }
    
    #platform-chart, #daily-chart {
        max-height: 240px !important;
    }
}

/* 响应式设计 - 手机小屏幕 */
@media (max-width: 480px) {
    .stats-section {
        padding: 20px 15px !important;
        margin: 20px 0 !important;
    }
    
    .stats-section h2, .section-title {
        font-size: 24px !important;
    }
    
    .stats-cards {
        gap: 15px !important;
    }
    
    .chart-container {
        min-height: 280px !important;
        padding: 15px 10px !important; /* 进一步减少内边距 */
        width: calc(100% - 20px) !important; /* 考虑容器边距 */
        margin: 0 auto !important; /* 居中显示 */
    }
    
    .chart-container h3, .chart-title {
        font-size: 16px !important;
        margin-bottom: 15px !important;
    }
    
    #platform-chart, #daily-chart {
        max-height: 220px !important;
        width: 100% !important;
    }
    
    /* 确保画布在小屏幕上不会超出容器 */
    .chart-container canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}