/* ============================================================
 * 公共 UI 组件样式：统一弹窗 + 自研代码编辑器
 * 依赖变量：--admin-primary / --admin-border / --admin-text-*
 * ============================================================ */

/* ---------- 统一弹窗 <uc-modal> ---------- */
.uc-modal-mask {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(23, 30, 45, 0.42);
    z-index: 1000;
    padding: 16px;
    animation: uc-mask-in .2s ease;
}
@keyframes uc-mask-in { from { opacity: 0; } }

.uc-modal {
    width: 100%;
    max-width: 520px;
    max-height: 88dvh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: uc-modal-pop .28s var(--ease);
}
@keyframes uc-modal-pop {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
}

.uc-modal-head {
    position: relative;
    padding: 14px 48px 14px 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--admin-text-title);
    border-bottom: 1px solid var(--admin-border);
    background: #fff;
    flex: none;
}

.uc-modal-head .uc-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    color: var(--admin-text-muted);
    border-radius: 6px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all .2s;
}
.uc-modal-head .uc-modal-close:hover { background: #f2f3f5; color: var(--admin-text-title); }

.uc-modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c8cdd8 transparent;
}
.uc-modal-body::-webkit-scrollbar { width: 5px; }
.uc-modal-body::-webkit-scrollbar-thumb { background: #c8cdd8; border-radius: 3px; }

.uc-modal-foot {
    padding: 12px 20px;
    border-top: 1px solid var(--admin-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex: none;
}

/* ---------- 自研代码编辑器 <uc-code-editor> ---------- */
.uc-code-editor {
    display: flex;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    overflow: hidden;
    background: #fafbfc;
    transition: border-color .2s, box-shadow .2s;
    min-height: 120px;
}
.uc-code-editor.focused {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.08);
}

.uc-code-editor .uc-ce-gutter {
    flex: none;
    width: 44px;
    background: #f2f3f5;
    border-right: 1px solid var(--admin-border);
    padding: 10px 6px 10px 0;
    overflow: hidden;
    user-select: none;
    text-align: right;
    color: var(--admin-text-muted);
    font-size: 13px;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.uc-code-editor .uc-ce-gutter pre { margin: 0; }

.uc-code-editor .uc-ce-area {
    flex: 1;
    border: none;
    outline: none;
    resize: vertical;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: transparent;
    color: var(--admin-text-title);
    tab-size: 2;
    -moz-tab-size: 2;
}
.uc-code-editor .uc-ce-area::placeholder { color: var(--admin-text-muted); }

/* ---------- 页面级公共组件 ---------- */

/* 页头：标题 + 描述 + 右侧操作 */
.uc-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.uc-page-head h2 { font-size: 20px; font-weight: 700; color: var(--admin-text-title); letter-spacing: -.01em; line-height: 1.3; margin: 0; }
.uc-page-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--admin-text-muted); }
.uc-page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.uc-page-head .actions .layui-btn { height: 36px; line-height: 36px; border-radius: 4px; }

/* 卡片头部工具栏（筛选/搜索/操作） */
.uc-card-tools {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; min-height: 48px;
    border-bottom: 1px solid var(--admin-border);
    flex-wrap: wrap;
    box-sizing: border-box;
}
.uc-card-tools .layui-input,
.uc-card-tools .layui-select,
.uc-card-tools .xm-sel-wrap { height: 32px; line-height: 32px; font-size: 13px; box-sizing: border-box; }
.uc-card-tools .layui-input { max-width: 180px; padding-top: 0; padding-bottom: 0; }
/* 覆盖 layui 动态生成的下拉组件：让其占满壳并统一高度 */
.uc-card-tools .xm-sel-wrap { position: relative; display: inline-flex; align-items: center; width: auto; min-width: 120px; }
.uc-card-tools .xm-sel-wrap .layui-form-select { width: 100%; }
.uc-card-tools .xm-sel-wrap .layui-select-title .layui-input { height: 32px; line-height: 32px; width: 100%; max-width: none; }
.uc-card-tools .layui-btn,
.uc-card-tools .layui-btn-sm { height: 32px; line-height: 32px; padding: 0 14px; }

/* 表单（竖排 label + 控件，用于弹窗内部） */
.uc-form .uc-form-row { margin-bottom: 14px; }
.uc-form .uc-form-row:last-child { margin-bottom: 0; }
.uc-form .uc-form-row > label {
    display: block; font-size: 12.5px; font-weight: 600; color: var(--admin-text-body);
    margin-bottom: 6px; line-height: 1.4;
}
.uc-form .uc-form-row .layui-input,
.uc-form .uc-form-row .layui-textarea,
.uc-form .uc-form-row .layui-select { width: 100%; }
.uc-form .uc-form-row .layui-textarea { min-height: 80px; }
.uc-form .uc-form-row .uc-form-static {
    display: flex; align-items: center; min-height: 38px; line-height: 1.4;
    font-size: 13.5px; color: var(--admin-text-body);
}
.uc-form .uc-form-row .uc-form-static .muted { color: var(--admin-text-muted); font-size: 12px; margin-left: 8px; }

/* 提示文字（表单说明） */
.uc-hint {
    font-size: 12px; color: var(--admin-text-muted); line-height: 1.6;
    padding: 8px 12px; background: var(--admin-bg); border-radius: 4px; margin-bottom: 12px;
}

/* 弹窗底部按钮 */
.uc-modal-btns {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 14px; margin-top: 6px; border-top: 1px solid var(--admin-border);
}
.uc-modal-btns .layui-btn { height: 34px; line-height: 34px; border-radius: 4px; }

/* Tab 切换 */
.uc-tabs { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--admin-border); padding: 0 16px; }
.uc-tabs .uc-tab {
    position: relative; padding: 12px 14px; font-size: 13.5px; color: var(--admin-text-muted);
    cursor: pointer; user-select: none; transition: color .2s;
}
.uc-tabs .uc-tab:hover { color: var(--admin-primary); }
.uc-tabs .uc-tab.on { color: var(--admin-primary); font-weight: 600; }
.uc-tabs .uc-tab.on::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
    background: var(--admin-primary); border-radius: 2px 2px 0 0;
}

/* 表格页脚 */
.uc-table-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.uc-table-foot .total { font-size: 12.5px; color: var(--admin-text-muted); }

/* 空态 */
.uc-empty { text-align: center; padding: 48px 0; color: var(--admin-text-muted); font-size: 13px; }

/* 行内操作按钮 */
.uc-row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* webhook 回调地址单元格（URL 较长，等宽字体 + 省略 + 复制按钮） */
.uc-webhook-cell { display: flex; align-items: center; gap: 6px; max-width: 320px; }
.uc-webhook-url {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--admin-primary, #1677ff);
}

/* 辅助色 */
.uc-muted { color: var(--admin-text-muted); font-size: 12px; margin-left: 6px; }

/* 代码编辑器占位 */
.uc-code-editor { min-height: 160px; }

/* 结果展示 pre 块 */
.uc-pre-light,
.uc-pre-danger,
.uc-pre-logs {
    background: #f5f7fa; border: 1px solid var(--admin-border); border-radius: 4px;
    padding: 10px 12px; max-height: 180px; overflow: auto;
    white-space: pre-wrap; word-break: break-all;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
}
.uc-pre-danger { background: #fff5f5; border-color: #ffccc7; color: var(--admin-danger); }
.uc-pre-logs { max-height: 120px; font-size: 12px; }

@media (max-width: 768px) {
    .uc-modal { max-width: 100%; }
    .uc-modal-mask { padding: 12px; }
    .uc-page-head { align-items: flex-start; flex-direction: column; }
    .uc-card-tools { height: auto; padding: 10px 12px; line-height: normal; }
    .uc-card-tools .layui-input { max-width: none; width: 100%; }
}

/* ---------- 补充 layui 未内置的图标 ----------
 * 背景：layui 2.9 图标集不含 robot / unlock，页面引用后不渲染任何字形，
 *       导致后台与用户中心的「机器人运营」菜单、各启停按钮出现空白图标位。
 * 方案：SVG mask 补齐，不依赖额外字体文件
 *   - background: currentColor  → 自动继承文字颜色，与 layui-icon 表现一致
 *   - 尺寸 1em + vertical-align → 沿用 layui-icon 的对齐规则
 *   - 本文件在 admin / user 入口均于 layui.css 之后引入，可正常覆盖 :before
 */
.layui-icon-robot:before,
.layui-icon-unlock:before {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    background: currentColor;
    -webkit-mask-repeat: no-repeat;
            mask-repeat: no-repeat;
    -webkit-mask-position: center;
            mask-position: center;
    -webkit-mask-size: contain;
            mask-size: contain;
}

/* 机器人：实心头部轮廓，眼部用 evenodd 挖空 */
.layui-icon-robot:before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a1.6 1.6 0 0 1 1.6 1.6V6H16a3 3 0 0 1 3 3v7.5a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3V9a3 3 0 0 1 3-3h2.4V3.6A1.6 1.6 0 0 1 12 2Zm-3.2 8.2a1.35 1.35 0 1 0 0 2.7 1.35 1.35 0 0 0 0-2.7Zm6.4 0a1.35 1.35 0 1 0 0 2.7 1.35 1.35 0 0 0 0-2.7Z'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a1.6 1.6 0 0 1 1.6 1.6V6H16a3 3 0 0 1 3 3v7.5a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3V9a3 3 0 0 1 3-3h2.4V3.6A1.6 1.6 0 0 1 12 2Zm-3.2 8.2a1.35 1.35 0 1 0 0 2.7 1.35 1.35 0 0 0 0-2.7Zm6.4 0a1.35 1.35 0 1 0 0 2.7 1.35 1.35 0 0 0 0-2.7Z'/%3E%3C/svg%3E");
}

/* 开锁：锁梁开口朝右上，与 layui-icon-lock 的闭合锁梁形成配对 */
.layui-icon-unlock:before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.5 10V7a3.6 3.6 0 0 1 6.8-1.6' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Crect x='5' y='10' width='14' height='10' rx='2'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8.5 10V7a3.6 3.6 0 0 1 6.8-1.6' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3Crect x='5' y='10' width='14' height='10' rx='2'/%3E%3C/svg%3E");
}
