/**
 * mcp_server 插件样式 —— 徽章 + 令牌管理页 + 后台补遗
 * 仅使用主题 CSS 变量（--mn-*），随主题自动适配；PC / 移动端共用同一套标记。
 *
 * @file plugins/mcp_server/assets/style.css
 */

/* ===== 通用：等宽端点/令牌展示 ===== */
.mcp-endpoint {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0;
}
.mcp-code {
    flex: 1 1 260px;
    min-width: 0;
    padding: 8px 10px;
    background: var(--mn-code-bg, #f3f4f6);
    color: var(--mn-code-text, #111827);
    border: 1px solid var(--mn-border-light, #e5e7eb);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
}
.mcp-code-token {
    font-weight: 600;
}
.mcp-hint {
    color: var(--mn-text-muted, #9ca3af);
    font-size: 13px;
    margin: 4px 0 0;
    line-height: 1.6;
}

/* ===== 前台：令牌管理页 ===== */
.mcp-page {
    padding: 16px;
}
.mcp-page-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--mn-text, #1a1a2e);
}
.mcp-intro {
    margin: 0 0 16px;
    line-height: 1.7;
}
.mcp-card {
    background: var(--mn-bg-card, #fff);
    border: 1px solid var(--mn-border-light, #e5e7eb);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--mn-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.04));
}
.mcp-card-new {
    border-color: var(--mn-primary, #0ea5e9);
}
.mcp-card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px;
    color: var(--mn-text, #1a1a2e);
}
.mcp-form {
    display: block;
}
.mcp-field {
    margin-bottom: 14px;
}
.mcp-field > label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--mn-text, #1a1a2e);
}
.mcp-actions {
    margin-top: 8px;
}
.mcp-alert-warning {
    background: var(--mn-tag-warning-bg, #fef3c7);
    color: var(--mn-tag-warning-text, #d97706);
    border: 1px solid var(--mn-tag-warning-bg, #fef3c7);
}
.mcp-btn-danger {
    color: var(--mn-error, #ef4444);
}

/* ===== 表格（PC 常规 / 移动端转卡片） ===== */
.mcp-table-wrap {
    overflow-x: auto;
}
.mcp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.mcp-table th,
.mcp-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--mn-divider, #e8f1f9);
    vertical-align: middle;
}
.mcp-table th {
    font-weight: 600;
    color: var(--mn-text-secondary, #5f7282);
    white-space: nowrap;
}
.mcp-table td {
    color: var(--mn-text, #1a1a2e);
}

/* ===== 后台：审计单元格 / 分页 ===== */
.mcp-cell-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    max-width: 320px;
    word-break: break-all;
}

/* ----- 调用审计表（10 列 · 固定布局） -----
   核心 .admin-table 带一组「按第几列」的通用规则（admin.css:180-189）：
     td:nth-child(4) { max-width:180px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
     td:nth-child(1)(3)(5)(6)(7)(8) { white-space:nowrap }
     td:last-child { white-space:nowrap }
   那是按 4~6 列表设计的。本表 10 列，第 8 列正好是「参数」JSON：
     · 被 nth-child(8) 的 nowrap 钉死后整行横向撑爆；
     · 第 9 列「结果」又带 break-all → 自动布局把它的 min-content 算成 1 个字宽，
       于是被挤成一条竖排单字（截图里的那个样子），行高动辄几百像素。
   解法：table-layout:fixed + 显式列宽，并用 (0,3,1) 的 td:nth-child(n) 把上面
   那几条位置规则统一归零（不用 !important）。长 JSON 单行省略，完整值在 title 里。 */
.admin-table.mcp-audit-table {
    table-layout: fixed;
    width: 100%;
    min-width: 1080px;
}
.admin-table.mcp-audit-table th,
.admin-table.mcp-audit-table td:nth-child(n) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: none;
}
/* 列宽；第 8（参数）/ 第 9（结果）列不设宽 → 平分剩余空间 */
.admin-table.mcp-audit-table th:nth-child(1)  { width: 138px; }  /* 时间 */
.admin-table.mcp-audit-table th:nth-child(2)  { width: 84px; }   /* 用户 */
.admin-table.mcp-audit-table th:nth-child(3)  { width: 92px; }   /* 事件 */
.admin-table.mcp-audit-table th:nth-child(4)  { width: 108px; }  /* 工具 */
.admin-table.mcp-audit-table th:nth-child(5)  { width: 68px; }   /* 状态 */
.admin-table.mcp-audit-table th:nth-child(6)  { width: 96px; }   /* 错误码 */
.admin-table.mcp-audit-table th:nth-child(7)  { width: 96px; }   /* 耗时（含「重试 N 秒」小字） */
.admin-table.mcp-audit-table th:nth-child(10) { width: 116px; }  /* 来源（ip_hash 前 12 位，等宽字体） */
/* 参数 / 结果：等宽、单行、不拆词 */
.admin-table.mcp-audit-table td.mcp-cell-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    word-break: normal;
    overflow-wrap: normal;
}

.mcp-pager {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}
.mcp-pager-link {
    display: inline-block;
    min-width: 30px;
    padding: 4px 8px;
    text-align: center;
    border: 1px solid var(--mn-border-light, #e5e7eb);
    border-radius: 6px;
    color: var(--mn-text-secondary, #5f7282);
    text-decoration: none;
    font-size: 13px;
}
.mcp-pager-link.active {
    background: var(--mn-primary, #0ea5e9);
    border-color: var(--mn-primary, #0ea5e9);
    color: #fff;
}

/* ===== 后台：审计筛选条 ===== */
.mcp-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 14px;
    margin: 12px 0 16px;
    padding: 12px 14px;
    background: var(--mn-bg-tag, #f1f5f9);
    border: 1px solid var(--mn-border-light, #e5e7eb);
    border-radius: 8px;
}
.mcp-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}
.mcp-filter > label {
    font-size: 13px;
    color: var(--mn-text-secondary, #5f7282);
}
.mcp-filter .form-input {
    margin: 0;
    min-width: 150px;
}
.mcp-filter-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* ===== 后台：状态徽标（执行结果 / 令牌状态） ===== */
.mcp-st {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.7;
    white-space: nowrap;
    background: var(--mn-tag-bg, #f0f9ff);
    color: var(--mn-tag-text, #0284c7);
}
.mcp-st-ok {
    background: var(--mn-alert-success-bg, #dcfce7);
    color: var(--mn-alert-success-text, #15803d);
}
.mcp-st-error {
    background: var(--mn-comp-tag-danger-bg, #fee2e2);
    color: var(--mn-comp-tag-danger-text, #b91c1c);
}
.mcp-st-off {
    background: var(--mn-bg-tag, #f1f5f9);
    color: var(--mn-text-muted, #9ca3af);
}
.mcp-st-started {
    background: var(--mn-tag-warning-bg, #fef3c7);
    color: var(--mn-tag-warning-text, #d97706);
}
.mcp-st-when {
    display: block;
    margin-top: 2px;
    font-size: 12px;
}
.mcp-cell-nowrap {
    white-space: nowrap;
}
.mcp-code-biz {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--mn-code-bg, #f3f4f6);
    color: var(--mn-code-text, #111827);
}

/* ===== 帖子详情：MCP 发布徽章 ===== */
/* 「由 MCP 发布」徽章 —— 纯图标（机器人，FA U+F544）
   语义同首页 `icon('robot')` 表示的「AI 助手」。
   零内联：字号走这里，不在 HTML 上写 style。 */
.mcp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--mn-tag-bg, #f0f9ff);
    color: var(--mn-tag-text, #0284c7);
    font-size: 12px;
    line-height: 1.7;
    vertical-align: middle;
    white-space: nowrap;
}
.mcp-badge .fa {
    font-size: 12px;
    /* .fa 全局是 1.25em 宽（为了「图标+文字」对齐），单个图标可以稍微收一点 */
    width: 1em;
}

/* ===== 移动端：表格转卡片（标签取自 td[data-label]） ===== */
@media (max-width: 640px) {
    .mcp-table thead {
        display: none;
    }
    .mcp-table,
    .mcp-table tbody,
    .mcp-table tr,
    .mcp-table td {
        display: block;
        width: 100%;
    }
    .mcp-table tr {
        border: 1px solid var(--mn-border-light, #e5e7eb);
        border-radius: 8px;
        padding: 8px 10px;
        margin-bottom: 10px;
        background: var(--mn-bg-card, #fff);
    }
    .mcp-table td {
        border-bottom: none;
        padding: 4px 0;
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }
    .mcp-table td::before {
        content: attr(data-label);
        color: var(--mn-text-muted, #9ca3af);
        font-size: 13px;
        flex: 0 0 auto;
    }
}
