/* ping.177117.xyz 首页样式：深色主题，两栏卡片布局，适配窄屏单栏。 */

/* ── 全局重置与基础 ───────────────────────────────────────────── */
/* 盒模型统一为 border-box，并清空外边距/内边距 */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    /* 优先使用系统字体栈，回退到通用 sans-serif */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #0d1117;   /* 深蓝黑底色 */
    color: #c9d1d9;        /* 主文字色 */
    min-height: 100vh;     /* 至占满整屏高，避免短页底部露白 */
}

/* ── 页头：标题与状态栏 ─────────────────────────────────────── */
header {
    background: #161b22;
    border-bottom: 1px solid #30363d;
    padding: 16px 24px;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #f0f6fc;       /* 近白，标题最亮 */
}

/* h1 后的副标题“网络延迟监控 (15min)” */
.subtitle {
    font-size: 14px;
    font-weight: 400;
    color: #8b949e;      /* 次级灰 */
    margin-left: 8px;
}

/* 状态栏：绿/红圆点 + 更新时间 */
.status-bar {
    margin-top: 8px;
    font-size: 13px;
    color: #8b949e;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;      /* 窄屏可换行 */
}

/* 状态圆点：默认绿色表示正常 */
.status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #3fb950;
    display: inline-block;
}

/* 拉取失败时由 JS 切换为 error 类，变红 */
.status-dot.error { background: #f85149; }

/* ── 主体内容区：限宽居中 ───────────────────────────────────── */
main {
    padding: 20px 24px;
    max-width: 1200px;    /* 大屏限宽，避免卡片过宽 */
    margin: 0 auto;       /* 水平居中 */
}

/* ── 两栏卡片网格 ─────────────────────────────────────────── */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;  /* 默认两等分列 */
    gap: 16px;
}

/* 单卡片：深色底 + 边框 + 圆角 */
.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 16px;
}

/* .full 让卡片跨满整行（图表卡片用） */
.full { grid-column: 1 / -1; }

/* 卡片标题：小号、大写、字间距 */
.card-header {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b949e;
    margin-bottom: 12px;
}

/* ── 图表容器：固定高度，canvas 拉满 ─────────────────────── */
.chart-wrap {
    position: relative;
    height: 300px;
}

/* Chart.js 默认会按内部尺寸渲染，这里强制填满容器 */
.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── 各目标统计行 ─────────────────────────────────────────── */
/* 单行：名称 | 平均延迟 | 丢包率 */
.stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #21262d;
    font-size: 13px;
}

/* 最后一行去掉分隔线 */
.stat-item:last-child { border-bottom: none; }

/* 名称区：圆点 + 文本 */
.stat-name {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 名称前的颜色圆点，由 JS 设 background */
.stat-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* 平均延迟：右对齐加粗 */
.stat-rtt {
    text-align: right;
    font-weight: 600;
}

/* 丢包率：右对齐、小号、红色 */
.stat-loss {
    text-align: right;
    font-size: 12px;
    color: #f85149;
    min-width: 40px;     /* 保证多行对齐 */
}

/* ── 报告列表：垂直排列的链接卡 ─────────────────────────── */
.report-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 单个报告链接：两端对齐（左时间，右“查看详情”） */
.report-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #21262d;
    border-radius: 6px;
    text-decoration: none;
    color: #c9d1d9;
    font-size: 13px;
    transition: background 0.2s;   /* 悬停过渡 */
}

/* 悬停时背景变亮，提示可点 */
.report-link:hover { background: #30363d; }

/* 右侧“查看详情”文字：更次级 */
.report-link .time { color: #8b949e; font-size: 12px; }

/* 占位提示“暂无…数据”：次级灰、小号 */
.report-detail {
    font-size: 12px;
    color: #8b949e;
    margin-top: 4px;
}

/* ── 响应式：窄屏单栏 ─────────────────────────────────────── */
@media (max-width: 700px) {
    .grid { grid-template-columns: 1fr; }
}

/* ── 钉钉告警开关 ─────────────────────────────────────────── */
/* 状态栏内的开关容器：紧随更新时间之后，左间距隔开 */
.dingtalk-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    margin-left: 8px;
}

/* 隐藏原生复选框，仅用轨道/圆球呈现，避免各浏览器样式不一致 */
.dingtalk-switch input[type="checkbox"] {
    position: absolute;
    width: 0; height: 0;
    opacity: 0;
}

/* 轨道：默认深灰底；勾选时变绿 */
.switch-track {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    background: #21262d;
    border-radius: 999px;
    transition: background 0.2s;
}

/* 圆球：默认左侧；勾选时右移 */
.switch-thumb {
    position: absolute;
    top: 2px; left: 2px;
    width: 14px; height: 14px;
    background: #c9d1d9;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

/* 勾选态：轨道变绿，圆球右移并变白 */
.dingtalk-switch input:checked + .switch-track {
    background: #3fb950;
}
.dingtalk-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(16px);
    background: #f0f6fc;
}

/* 禁用态（未配置 webhook 或提交中）：降低不透明度并取消可点指针 */
.dingtalk-switch input:disabled + .switch-track {
    opacity: 0.4;
}
.dingtalk-switch input:disabled ~ .switch-label,
.dingtalk-switch:has(input:disabled) {
    cursor: not-allowed;
}

/* 开关文字：与状态栏同色同号 */
.switch-label {
    font-size: 13px;
    color: #8b949e;
}
