/* statistics.html 样式 */
:root {
    --tech-blue: #00a1f7;
    --tech-light-blue: rgba(24, 144, 255, 0.1);
    --tech-dark-blue: #00a1f7;
    --chart-bg: rgba(24, 144, 255, 0.05);
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    background-color: #f5f5f5;
}

/* 主容器布局 */
.dashboard-layout {
    height: 88vh;
    padding: 0 0 1rem 0;
    display: grid;
    grid-template-columns: 0.5fr 0.8fr 0.5fr 450px;
    grid-template-rows: calc(50% - 1rem) calc(50% - 1rem); /* 因为 gap 是 1rem */
    gap: 1rem;
    box-sizing: border-box;
}

/* 网格位置属性 - 使用data属性替代内联样式 */
[data-grid-position="1-3,1"] {
    grid-column: 1 / 3;
    grid-row: 1;
}

[data-grid-position="3,1"] {
    grid-column: 3;
    grid-row: 1;
}

[data-grid-position="1,2"] {
    grid-column: 1;
    grid-row: 2;
}

[data-grid-position="2,2"] {
    grid-column: 2;
    grid-row: 2;
}

[data-grid-position="3,2"] {
    grid-column: 3;
    grid-row: 2;
}

[data-grid-position="4,1-3"] {
    grid-column: 4;
    grid-row: 1 / 3;
}

/* 告警等级分布容器 */
.severity-distribution-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-right: 0;
    margin-left: 0;
}

canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain; /* 防止超出容器 */
}

.chart-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: 100%;
    position: relative;
}

/* 自动刷新区域样式 */
.refresh-controls {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
    gap: 10px;
    font-size: 12px;
}

.refresh-controls .form-label {
    margin-bottom: 0;
}

.refresh-controls .form-select-sm {
    width: 120px;
    font-size: 12px;
}

.refresh-controls .btn-sm {
    font-size: 12px;
}

.alert-line-1 {
    display: block;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

/* 第二行 */
.alert-line-2 {
    display: block;
    font-size: 13px;
    color: #666;
    padding-left: 10px;
}

.alert-level.not-classified {
    color: #c0c0c0;
}

.alert-level.information {
    color: #1890ff;
}

.alert-level.warning {
    color: #faad14;
}

.alert-level.average {
    color: #f56a00;
}

.alert-level.high {
    color: #f5222d;
}

.alert-level.disaster {
    color: #722ed1;
}

.alert-status {
    margin-left: 10px;
    font-weight: normal;
}

.alert-value {
    color: #d46b08;
    font-weight: 500;
}

/* 卡片样式 */
.alert-card {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

/* 标题栏 */
.card-title {
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
    padding-bottom: 0.5rem;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

/* 通用容器 */
.chart-container,
.trend-container,
.realtime-alerts {
    flex: 1;
    min-height: 0;
    width: 100%;
    position: relative;
}

/* chart.js 画布设置 */
canvas {
    width: 100% !important;
    height: 100% !important;
}

/* 时间选择器 */
.time-picker {
    display: flex;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.time-input {
    border: 1px solid #d9d9d9;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
}

/* 实时告警滚动区域 */
.scrolling-alerts {
    position: relative;
    height: calc(100% - 50px);
    overflow: hidden;
}

/* 滚动内容 */
.scrolling-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    animation: scrollUp linear infinite;
}

/* 告警条目样式 */
.scrolling-alert-item {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #f0f0f0;
    gap: 1rem;
    align-items: center;
    font-size: 0.9rem;
}

/* 不同等级样式 */
.alert-level {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.level-critical {
    background-color: #ff4d4f;
    color: white;
}

.level-warning {
    background-color: #faad14;
    color: white;
}

.level-info {
    background-color: #52c41a;
    color: white;
}

/* 动画暂停 */
.scrolling-content:hover {
    animation-play-state: paused;
}

/* 滚动动画 */
@keyframes scrollUp {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-100%);
    }
}

/* 最近7天实例TOP10告警项样式 */
.alert-item {
    background: var(--chart-bg);
    padding: 0.5rem 0;
    margin: 0.3rem 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    animation: slideDown 0.3s ease-out;
    height: 24px; /* 统一高度 */
    box-sizing: border-box; /* 包含 padding，避免总高度超出预期 */
    white-space: nowrap; /* 防止文本换行 */
    overflow: hidden; /* 隐藏溢出内容 */
}

.alert-rank {
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background-color: var(--tech-blue);
    color: white;
    border-radius: 50%;
    margin-left: 5px;
    margin-right: 8px;
    font-size: 0.75rem;
}

.alert-type {
    flex: 1;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.75rem;
}

.alert-time {
    color: #8c8c8c;
    font-size: 0.75rem;
    margin-right: 5px;
    white-space: nowrap;
}

/* 渐变进入动画 */
@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 空数据时的提示 */
.no-data {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 16px;
}

/* 告警总数区域样式 */
.alert-total-container {
    background: #53c41c;
    border: 0px solid #53c41c;
    border-radius: 4px;
    text-align: center;
    font-family: Arial, sans-serif;
}

.alert-total-time {
    font-size: 12px;
    color: #ffffff;
    margin-bottom: 8px;
}

.alert-total-count {
    font-size: 16px;
    color: #ffdb04;
    font-weight: bold;
}

.alert-total-count span {
    color: #1890ff;
}

/* 图表容器样式补充 */
.severity-chart-container {
    margin-top: -10px;
}

.alert-top10-chart {
    font-size: 14px;
    color: #1a1e21;
}

.alert-instance-top10 {
    font-size: 14px;
    margin-left: 0px;
    overflow-y: auto;
    max-height: 100%;
}

.alert-instance-top10 .alert-item {
    font-size: 14px;
    padding: 0.5rem 0;
    height: 24px;
}