/* WS/WSS 检测页样式。
   与 tool.css 的分工：tool.css 是各工具页共用的表单 / 结果面板基础样式，
   这里只放本页独有的结果概览、测速卡片、进度条与事件日志。

   ★ 版式口径与 ssl.css 一致（2026-11-10 全站收敛后的基线）：
     输入框 44px / 圆角 2px / 等宽 13px，按钮 44px / 圆角 3px / 15px。
     本页只有一颗主按钮 + 一颗次按钮，右栏 200px 与 ssl 页同宽。 */

/* ⚠️ 本页多处用 hidden 属性控制显隐，而 #result-area 设了 display:flex ——
   display 会盖掉 [hidden] 的 display:none（同 fingerprint.css / speed.css 的处理）。
   统一在页面容器上兜底，避免以后新增的 flex/grid 容器再踩一次。 */
.ws-page [hidden] {
    display: none !important;
}

/* ===== 表单 ===== */
.ws-form-body {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    /* 覆盖 .form-row 默认的 align-items:flex-end：说明文字在输入框下方，
       底对齐会把按钮压到提示行下面。 */
    align-items: flex-start;
}

.ws-form-main {
    flex: 1 1 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.ws-form-side {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-self: flex-start;
}

/* 地址用等宽字体：核对 wss://a.example/socket 这类地址里的形近字符更可靠。
   ⚠️ 前缀必须与 workspace.css 的
   `.tool-page>.tool-form .form-group input`（(0,3,1)）同级或更高，
   否则 44px / 2px 会退回基线的 13px 字与默认外观。
   padding-right 40px 是给右侧「清空」按钮留位（target-history.js 动态插入）。 */
.tool-page>.tool-form .form-row .ws-form-main input[type="text"] {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 12px;
    border: 1px solid #d9e0e6;
    border-radius: 2px;
    font-family: Menlo, Consolas, "Microsoft YaHei", monospace;
    font-size: 13px;
    color: #44525c;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

.tool-page>.tool-form .form-row .ws-form-main input[type="text"]:hover {
    border-color: #c2d2da;
}

.tool-page>.tool-form .form-row .ws-form-main input[type="text"]:focus {
    border-color: #4285ed;
    box-shadow: 0 0 0 2px rgba(66, 133, 237, .15);
    outline: none;
}

/* ⚠️ 必须带 `.tool-page > .tool-form .form-row` 前缀：workspace.css 的
   `.tool-page>.tool-form .form-row .btn`、`.tool-page>.tool-form .btn`、
   `.tool-page>.tool-form .btn-lg` 都是 (0,4,0)~(0,4,1)，裸写
   `.ws-form-side .btn` 压不住 —— 按钮会停在 44px 高但保留
   `.btn-lg` 的 padding:12px 32px，文字被挤扁。 */
.tool-page>.tool-form .form-row .ws-form-side .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    box-sizing: border-box;
    /* 纵向 padding 必须为 0：按钮是 inline-flex + align-items:center，
       上下留白交给 flex 居中。 */
    padding: 0 14px;
    border-radius: 3px;
    font-size: 15px;
    line-height: 1;
}

.tool-page>.tool-form .form-row .ws-form-side .btn .btn-icon {
    margin-right: 6px;
}

/* 次按钮「重置」：白底细边，避免与主按钮争视觉重心。 */
.tool-page>.tool-form .form-row .ws-form-side .ws-btn-ghost {
    border: 1px solid #d9e0e6;
    background: #fff;
    color: #5b6b76;
}

.tool-page>.tool-form .form-row .ws-form-side .ws-btn-ghost:hover {
    border-color: #c2d2da;
    background: #f7fafc;
    color: #44525c;
}

.ws-hint {
    margin: 0;
    color: #7a8b96;
    font-size: 13px;
    line-height: 1.75;
}

.ws-hint code {
    padding: 1px 5px;
    border-radius: 3px;
    background: #f2f6f9;
    color: #3d5a6c;
    font-family: Menlo, Consolas, monospace;
    font-size: 12px;
}

/* 常显提示：本页最容易犯的错是把「浏览器直连的结果」读成「多地探测的结论」。
   这条不可折叠、不可关闭 —— 结论的适用边界必须与结论同时可见。 */
.ws-disclaimer {
    margin: 0 0 18px;
    padding: 12px 16px;
    border-left: 3px solid #e6a23c;
    border-radius: 6px;
    background: #fdf6ec;
    color: #7a5b21;
    font-size: 13px;
    line-height: 1.75;
}

.ws-disclaimer strong {
    color: #8a5a00;
}

/* ===== 结果区 ===== */
.ws-result-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ws-panel {
    margin-bottom: 10px;
    border: 1px solid #dce2e9;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(31, 53, 75, .07);
}

.ws-panel-head {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border-bottom: 1px solid #e7ebee;
    color: #637582;
}

.ws-panel-head .class-hr {
    display: inline-block;
    width: 3px;
    height: 24px;
    background: #4285ed;
}

.ws-panel-head h2 {
    margin: 0 8px 0 2px;
    color: #526675;
    font-size: 15px;
    font-weight: 400;
}

/* 状态徽章：与结论同步变化，因此固定在最右侧（margin-left:auto）。 */
.ws-state-badge {
    margin-left: auto;
    padding: 3px 10px;
    border: 1px solid #d9e0e6;
    border-radius: 999px;
    background: #f7fafc;
    color: #7a8b96;
    font-size: 12px;
    line-height: 18px;
    white-space: nowrap;
}

.ws-state-badge.is-pending {
    border-color: #d7e3f6;
    background: #f1f6fe;
    color: #3d6fbf;
}

.ws-state-badge.is-ok {
    border-color: #cfe8dd;
    background: #f1faf6;
    color: #2c8f6b;
}

.ws-state-badge.is-warn {
    border-color: #f2e2c4;
    background: #fdf6ec;
    color: #a9741d;
}

.ws-state-badge.is-error {
    border-color: #f0d5d5;
    background: #fdf3f3;
    color: #c25a5a;
}

/* 概览：目标地址独占一行（可能很长，必须可断行），指标四列。 */
.ws-summary {
    padding: 14px 16px 4px;
}

.ws-summary-target {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}

.ws-summary-target strong {
    color: #254150;
    font-family: Menlo, Consolas, "Microsoft YaHei", monospace;
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
}

.ws-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.ws-metric {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid #eef2f5;
    border-radius: 3px;
    background: #fbfcfd;
    min-width: 0;
}

.ws-metric-label {
    display: block;
    width: 100%;
    margin-bottom: 2px;
    color: #7a8b96;
    font-size: 12px;
}

.ws-metric-value {
    color: #254150;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

/* 文本型指标（协议名）用 13px：20px 的 "未协商" 会把格子撑破。 */
.ws-metric-value.ws-metric-text {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
}

.ws-metric-unit {
    color: #91a0a9;
    font-size: 12px;
}

.ws-summary-note {
    margin: 0;
    padding: 0 16px 14px;
    color: #6d7d88;
    font-size: 13px;
    line-height: 1.7;
}

/* ===== 连接质量区 =====
   本页不做宽带测速（下行 / 上行吞吐属于 /tool/speed.html），
   这里只放延迟、抖动与稳定度。 */
.ws-quality-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* 手动重测按钮：与结果面板里的次级操作同一口径（28px / 3px / 13px），
   不复用  的大尺寸 —— 它们在标题栏里会把 48px 的标题行撑高。 */
.ws-quality-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    padding: 0 12px;
    border: 1px solid #d6e0e6;
    border-radius: 3px;
    background: #fff;
    color: #5b6b76;
    font-size: 13px;
    line-height: 1;
}

.ws-quality-actions .btn:hover:not(:disabled) {
    border-color: #4285ed;
    color: #2f6fd0;
}

.ws-quality-actions .btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.ws-quality-hint {
    margin: 0;
    padding: 12px 16px 0;
    color: #7a8b96;
    font-size: 13px;
    line-height: 1.7;
}

.ws-progress {
    padding: 12px 16px 0;
}

.ws-progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    color: #6d7d88;
    font-size: 12px;
}

.ws-bar {
    height: 6px;
    overflow: hidden;
    border-radius: 3px;
    background: #eef2f5;
}

.ws-bar>i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #6aa5f2, #4285ed);
    transition: width .2s linear;
}

.ws-quality-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px 16px;
}

.ws-metric-card {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid #eef2f5;
    border-left: 3px solid #d9e0e6;
    border-radius: 3px;
    background: #fbfcfd;
    min-width: 0;
}

.ws-metric-card.is-latency { border-left-color: #4285ed; }
.ws-metric-card.is-sample { border-left-color: #2c8f6b; }

.ws-metric-card .ws-metric-label {
    color: #7a8b96;
    font-size: 12px;
}

.ws-metric-card .ws-metric-value {
    font-size: 22px;
}

/* 延迟的 "最小 / 中位 / 最大" 三个数字较长，用 15px 避免换行成两截。 */
.ws-metric-card.is-latency .ws-metric-value {
    font-size: 15px;
}

/* 稳定度是文字档位（很稳定 / 稳定 / 有波动 / 波动较大），
   按档位上色而不是按数值渐变 —— 同一档位应该是同一种观感。 */
.ws-metric-card .ws-metric-value.is-ok { color: #2c8f6b; }
.ws-metric-card .ws-metric-value.is-warn { color: #a9741d; }
.ws-metric-card .ws-metric-value.is-error { color: #c25a5a; }

.ws-metric-sub {
    display: block;
    width: 100%;
    margin-top: 2px;
    color: #91a0a9;
    font-size: 12px;
    line-height: 1.6;
    word-break: break-all;
}

/* 明细表：与全站 kv 表同口径（浅灰表头列 + 细线分隔），但不带外框 ——
   外框由 .ws-panel 提供，避免「框中框」。 */
.ws-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    border-top: 1px solid #eef2f5;
    font-size: 13px;
}

.ws-table th,
.ws-table td {
    padding: 9px 16px;
    border-bottom: 1px solid #f2f5f7;
    text-align: left;
    vertical-align: top;
    line-height: 1.65;
}

.ws-table tr:last-child th,
.ws-table tr:last-child td {
    border-bottom: 0;
}

.ws-table th {
    width: 160px;
    color: #7a8b96;
    font-weight: 400;
    background: #fbfcfd;
    white-space: nowrap;
}

.ws-table td {
    color: #44525c;
    word-break: break-all;
}

/* ===== 事件日志 ===== */
.ws-log-copy {
    margin-left: auto;
    padding: 0;
    border: 0;
    background: none;
    color: #7f8f9a;
    font-size: 12px;
    cursor: pointer;
}

.ws-log-copy:hover {
    color: #4285ed;
}

.ws-log {
    margin: 0;
    padding: 10px 16px;
    max-height: 240px;
    overflow-y: auto;
    list-style: none;
    font-family: Menlo, Consolas, "Microsoft YaHei", monospace;
    font-size: 12px;
    line-height: 1.9;
    color: #526675;
}

.ws-log-item {
    display: flex;
    gap: 10px;
}

.ws-log-time {
    flex: 0 0 auto;
    color: #a9b6bf;
}

.ws-log-text {
    word-break: break-all;
}

.ws-log-item.is-ok .ws-log-text { color: #2c8f6b; }
.ws-log-item.is-warn .ws-log-text { color: #a9741d; }
.ws-log-item.is-error .ws-log-text { color: #c25a5a; }

/* ===== 说明 ===== */
.ws-help {
    margin-top: 20px;
    padding: 14px 18px;
    border: 1px solid #e7edf2;
    border-radius: 6px;
    background: #fbfcfd;
}

.ws-help h2 {
    margin: 0 0 8px;
    color: #44525c;
    font-size: 15px;
    font-weight: 600;
}

.ws-help ul {
    margin: 0;
    padding-left: 18px;
    color: #6d7d88;
    font-size: 13px;
    line-height: 1.85;
}

.ws-help code {
    padding: 1px 5px;
    border-radius: 3px;
    background: #eef3f7;
    color: #3d5a6c;
    font-family: Menlo, Consolas, monospace;
    font-size: 12px;
}

/* ===== 窄屏 ===== */
@media (max-width: 900px) {
    .ws-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ws-quality-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ws-form-side {
        flex: 1 1 100%;
        flex-direction: row;
    }

    .ws-table th {
        width: 110px;
        white-space: normal;
    }
}
