/**
 * Stat页面专用样式
 * @description 包含系统概览、CPU热力图、网络设备、图表容器等所有样式
 * @file static/css/pages/stat.css
 */

/* ==================== 工具类 ==================== */

/* metric-unit - 单位字体样式 */
.metric-unit {
    color: inherit;
    font-size: 0.875em;
    opacity: 0.8;
}

/* metric-unit-compact - 紧凑单位样式 */
.metric-unit-compact {
    font-size: 0.65em;
    opacity: 0.7;
    margin-left: 0.05em;
    font-weight: normal;
    vertical-align: baseline;
}

/* Tab面板显示控制 */
.tab-panel {
    display: block;
}

.tab-panel.hidden {
    display: none;
}

/* Tabler Icons 尺寸类 */
.ti.md-14 {
    font-size: 14px;
}

.ti.md-12 {
    font-size: 12px;
}

/* ==================== 图表容器 ==================== */

/* 并排图表高度一致性 */
.chart-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 1024px) {
    .chart-grid-container {
        grid-template-columns: 1fr;
    }
}

.chart-grid-container .card {
    display: flex;
    flex-direction: column;
}

.chart-grid-container .card > div:last-child {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 隐藏并排布局中不需要的元素 */
#granularity-selector,
#custom-time-range-selector {
    display: none !important;
}

/* 外置 Legend 容器样式 */
#stat-network-legend {
    min-height: 100px;
    max-height: 280px;
    position: relative;
    overflow: visible;
}

/* 滚动条样式 - Webkit */
#stat-network-legend > div > div:first-of-type::-webkit-scrollbar {
    width: 4px;
}

#stat-network-legend > div > div:first-of-type::-webkit-scrollbar-track {
    background: transparent;
}

#stat-network-legend > div > div:first-of-type::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.2);
    border-radius: 2px;
}

#stat-network-legend > div > div:first-of-type::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.4);
}

/* 滚动条样式 - Firefox */
#stat-network-legend > div > div:first-of-type {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.2) transparent;
}

/* ==================== 系统概览卡片 ==================== */

.overview-cards-container {
    display: grid;
    gap: 1rem;
    width: 100%;
}

/* 大屏幕：4列布局 */
@media (min-width: 1200px) {
    .overview-cards-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 中等屏幕：双列布局 */
@media (min-width: 600px) and (max-width: 1199px) {
    .overview-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 确保所有卡片高度一致 */
    .overview-cards-container > .card {
        min-height: 180px;
    }

    /* 统一左侧内容区域的最小宽度 */
    .overview-cards-container .flex-1.pr-3 {
        min-width: 0;
        flex: 1 1 60%;
    }

    /* 确保圆环区域宽度固定 */
    .overview-cards-container .chart-container {
        flex: 0 0 7rem;
    }
}

/* 小屏幕：单列布局 */
@media (max-width: 599px) {
    .overview-cards-container {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }
}

/* 卡片基础样式 */
.overview-cards-container > .card {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* 圆形进度条容器 */
.overview-cards-container .chart-container {
    width: 7rem;
    height: 7rem;
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overview-cards-container .chart-container svg {
    width: 100%;
    height: 100%;
}

/* 确保内容区域最小高度一致 */
.overview-cards-container .card > div {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* 确保内容区域垂直居中对齐 */
.overview-cards-container .card .flex.justify-between {
    flex: 1;
    align-items: center;
}

/* 中小屏幕调整 (421px - 600px) */
@media (min-width: 421px) and (max-width: 600px) {
    .overview-cards-container .chart-container {
        width: 5.5rem;
        height: 5.5rem;
    }

    .overview-cards-container .text-3xl {
        font-size: 1.75rem;
        line-height: 1.2;
    }

    .overview-cards-container .text-2xl {
        font-size: 1.5rem;
    }

    .overview-cards-container .card .p-4 {
        padding: 0.875rem;
    }

    .overview-cards-container .network-card .grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* 单列布局调整 (< 420px) */
@media (max-width: 420px) {
    .overview-cards-container .chart-container {
        width: 6rem;
        height: 6rem;
    }

    .overview-cards-container .text-3xl {
        font-size: 2rem;
        line-height: 1.2;
    }

    .overview-cards-container .text-2xl {
        font-size: 1.625rem;
    }

    .overview-cards-container .text-lg {
        font-size: 1rem;
    }

    .overview-cards-container .space-y-2 > div {
        margin-bottom: 0.5rem;
    }

    .overview-cards-container .network-card .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* 优化百分号显示 */
.overview-cards-container .text-3xl .text-lg,
.overview-cards-container .text-2xl .text-sm {
    font-size: 0.6em;
    margin-left: 0.1em;
}

/* 优化详细信息中的单位显示 */
.overview-cards-container .text-xs .metric-unit {
    font-size: 0.875em;
}

/* 内存卡片内容区域调整 */
.overview-cards-container .memory-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
}

/* 月度流量进度条样式 */
#monthly-progress-overview {
    transition: width 0.3s ease-out;
}

/* ==================== CPU 热力图 ==================== */

.cpu-cores-heatmap {
    grid-template-columns: repeat(auto-fill, minmax(20px, 1fr));
    max-width: 100%;
}

/* 1-8核：4列 */
.cpu-cores-heatmap[data-cores="1"],
.cpu-cores-heatmap[data-cores="2"],
.cpu-cores-heatmap[data-cores="3"],
.cpu-cores-heatmap[data-cores="4"],
.cpu-cores-heatmap[data-cores="5"],
.cpu-cores-heatmap[data-cores="6"],
.cpu-cores-heatmap[data-cores="7"],
.cpu-cores-heatmap[data-cores="8"] {
    grid-template-columns: repeat(4, 1fr);
}

/* 9-16核：8列 */
.cpu-cores-heatmap[data-cores="9"],
.cpu-cores-heatmap[data-cores="10"],
.cpu-cores-heatmap[data-cores="11"],
.cpu-cores-heatmap[data-cores="12"],
.cpu-cores-heatmap[data-cores="13"],
.cpu-cores-heatmap[data-cores="14"],
.cpu-cores-heatmap[data-cores="15"],
.cpu-cores-heatmap[data-cores="16"] {
    grid-template-columns: repeat(8, 1fr);
}

/* 17-32核：8列 */
.cpu-cores-heatmap[data-cores="17"],
.cpu-cores-heatmap[data-cores="18"],
.cpu-cores-heatmap[data-cores="19"],
.cpu-cores-heatmap[data-cores="20"],
.cpu-cores-heatmap[data-cores="21"],
.cpu-cores-heatmap[data-cores="22"],
.cpu-cores-heatmap[data-cores="23"],
.cpu-cores-heatmap[data-cores="24"],
.cpu-cores-heatmap[data-cores="25"],
.cpu-cores-heatmap[data-cores="26"],
.cpu-cores-heatmap[data-cores="27"],
.cpu-cores-heatmap[data-cores="28"],
.cpu-cores-heatmap[data-cores="29"],
.cpu-cores-heatmap[data-cores="30"],
.cpu-cores-heatmap[data-cores="31"],
.cpu-cores-heatmap[data-cores="32"] {
    grid-template-columns: repeat(8, 1fr);
}

/* 33-64核：16列 */
.cpu-cores-heatmap[data-cores^="3"]:not([data-cores="3"]),
.cpu-cores-heatmap[data-cores^="4"],
.cpu-cores-heatmap[data-cores^="5"],
.cpu-cores-heatmap[data-cores="60"],
.cpu-cores-heatmap[data-cores="61"],
.cpu-cores-heatmap[data-cores="62"],
.cpu-cores-heatmap[data-cores="63"],
.cpu-cores-heatmap[data-cores="64"] {
    grid-template-columns: repeat(16, 1fr);
}

/* 超过64核：自动填充 */
.cpu-cores-heatmap[data-cores="65"],
.cpu-cores-heatmap[data-cores="66"],
.cpu-cores-heatmap[data-cores="67"],
.cpu-cores-heatmap[data-cores="68"],
.cpu-cores-heatmap[data-cores="69"],
.cpu-cores-heatmap[data-cores^="7"],
.cpu-cores-heatmap[data-cores^="8"],
.cpu-cores-heatmap[data-cores^="9"],
.cpu-cores-heatmap[data-cores^="10"],
.cpu-cores-heatmap[data-cores^="11"],
.cpu-cores-heatmap[data-cores^="12"] {
    grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
}

/* 热力块样式 */
.cpu-core-cell {
    min-width: 12px;
    min-height: 12px;
    max-width: 30px;
    max-height: 30px;
}

/* 确保热力图容器不会溢出 */
.cpu-cores-heatmap-container {
    max-width: 100%;
    overflow: auto;
}

/* CPU核心迷你图表样式 */
.cpu-cores-chart {
    background-color: rgba(156, 163, 175, 0.1);
    border-radius: 2px;
    padding: 2px;
}

.cpu-cores-chart > div {
    position: relative;
}

@media (max-width: 640px) {
    .cpu-cores-chart {
        height: 2.5rem;
    }
}

.cpu-cores-chart > div > div {
    transition: height 0.3s ease;
}

/* ==================== 网络设备表格 ==================== */

/* 网络设备数值专用样式 - 等宽字体 */
.network-metric {
    font-family: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* 网络设备移动端列宽控制 */
@media (max-width: 639px) {
    #network-devices-table tr {
        width: 100%;
    }

    #network-devices-table tr td:nth-child(1) {
        flex: 0 0 40%;
        min-width: 0;
    }

    #network-devices-table tr td:nth-child(2),
    #network-devices-table tr td:nth-child(3) {
        flex: 0 0 30%;
        min-width: 0;
    }
}

/* ==================== 硬盘使用详情 ==================== */

/* 硬盘使用详情移动端列宽控制 */
@media (max-width: 639px) {
    #disk-usage-table tr {
        width: 100%;
    }

    /* 挂载点列：40% */
    #disk-usage-table tr td:nth-child(1) {
        flex: 0 0 40%;
        min-width: 0;
    }

    /* 使用率列：60% */
    #disk-usage-table tr td:nth-child(6) {
        flex: 0 0 60%;
        min-width: 0;
    }
}
