/* ═════════ YQKF 管理后台 · Ant Design Pro 视觉体系 ═════════
   基准：Ant Design 4 官方设计令牌（#1677ff / #f0f2f5 / #001529） */
:root {
  --ant-primary: #1677ff;
  --ant-bg-layout: #f0f2f5;
  --ant-sidebar: #001529;
  --ant-text: rgba(0, 0, 0, 0.88);
  --ant-secondary: rgba(0, 0, 0, 0.65);
  --ant-muted: rgba(0, 0, 0, 0.45);
  --ant-border: #f0f0f0;
  --ant-radius: 8px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ant-text);
  background: var(--ant-bg-layout);
  font-size: 14px;
}

/* ───────── 登录页（Ant Design Pro 风格） ───────── */
.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(22, 119, 255, 0.35), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(114, 46, 209, 0.28), transparent 55%),
    linear-gradient(160deg, #0a1636 0%, #0d2b66 55%, #0a1f4d 100%);
  padding: 24px;
}
.login-card {
  width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 40px 40px 28px;
  box-shadow: 0 24px 60px rgba(0, 21, 41, 0.45);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-logo .mark {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, #1677ff, #69b1ff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px;
}
.login-logo .name { font-size: 20px; font-weight: 600; color: var(--ant-text); }
.login-logo .sub { font-size: 12px; color: var(--ant-muted); margin-top: 2px; }
.login-feats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
  margin: 20px 0 24px; padding: 12px 16px;
  background: #f6f8fc; border-radius: 8px; font-size: 12px; color: var(--ant-secondary);
}
.login-demo { margin-top: 20px; font-size: 12px; color: var(--ant-muted); line-height: 2.1; }
.login-demo b { color: var(--ant-secondary); font-weight: 600; }
.login-demo a { color: var(--ant-primary); cursor: pointer; margin-left: 8px; }

/* ───────── 整体布局 ───────── */
.layout { height: 100%; display: flex; }
.sidebar {
  width: 216px; background: var(--ant-sidebar); flex-shrink: 0;
  display: flex; flex-direction: column;
}
.sidebar .logo {
  height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 16px;
  color: #fff; font-weight: 600; font-size: 15px; letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar .logo .mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #1677ff, #69b1ff);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 17px;
}
.sidebar .menu-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar .sidebar-foot {
  padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.45); font-size: 11px; line-height: 1.7;
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; display: flex; align-items: center;
  padding: 0 24px; gap: 16px; border-bottom: 1px solid var(--ant-border); flex-shrink: 0;
}
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .user-name { color: var(--ant-secondary); }
.content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* 页头 */
.page-head { margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.page-head .desc { color: var(--ant-secondary); font-size: 13px; margin-top: 4px; }

/* ───────── 仪表盘 ───────── */
.stat-card { position: relative; }
.stat-card .chip {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 21px;
}
.chip.blue   { background: #e6f4ff; color: #1677ff; }
.chip.orange { background: #fff7e6; color: #fa8c16; }
.chip.green  { background: #f6ffed; color: #52c41a; }
.panel-title { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.panel-sub { font-size: 12px; color: var(--ant-muted); font-weight: 400; margin-left: 8px; }
.trend-svg { width: 100%; }
.legend-row { display: flex; gap: 20px; font-size: 12px; color: var(--ant-secondary); margin-top: 8px; }
.legend-row .dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.channel-list { display: flex; flex-direction: column; gap: 14px; }
.channel-list .row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.channel-list .row .name { flex: 1; color: var(--ant-secondary); }
.channel-list .row b { font-size: 15px; }

/* ───────── 实时工作台 ───────── */
.workbench { display: flex; gap: 16px; height: calc(100vh - 56px - 40px); min-height: 520px; }
.wb-list {
  width: 300px; background: #fff; border-radius: var(--ant-radius);
  border: 1px solid var(--ant-border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}
.wb-list .filter { padding: 12px; border-bottom: 1px solid var(--ant-border); display: flex; flex-direction: column; gap: 10px; }
.wb-list .items { flex: 1; overflow-y: auto; }
.conv-item { padding: 12px 16px; border-bottom: 1px solid #f5f5f5; cursor: pointer; transition: background 0.12s; }
.conv-item:hover { background: #fafafa; }
.conv-item.active { background: #e6f4ff; box-shadow: inset 3px 0 0 var(--ant-primary); }
.conv-item .row1 { display: flex; align-items: center; gap: 8px; }
.conv-item .name { font-weight: 600; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .time { font-size: 11px; color: var(--ant-muted); flex-shrink: 0; }
.conv-item .row2 { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.conv-item .preview { flex: 1; font-size: 12px; color: var(--ant-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-chat {
  flex: 1; background: #fff; border-radius: var(--ant-radius); border: 1px solid var(--ant-border);
  display: flex; flex-direction: column; overflow: hidden; min-width: 0;
}
.wb-chat .head { padding: 12px 20px; border-bottom: 1px solid var(--ant-border); display: flex; align-items: center; gap: 10px; }
.wb-chat .body { flex: 1; overflow-y: auto; padding: 20px 24px; background: #fafafa; }
.wb-chat .input-bar { padding: 12px 16px; border-top: 1px solid var(--ant-border); }
.quick-replies { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-replies span {
  font-size: 12px; background: #f5f5f5; padding: 4px 12px; border-radius: 16px;
  cursor: pointer; color: var(--ant-secondary); transition: all 0.15s;
}
.quick-replies span:hover { background: #e6f4ff; color: var(--ant-primary); }
.chat-msg { display: flex; margin-bottom: 16px; gap: 10px; }
.chat-msg .avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff;
}
.chat-msg.visitor .avatar { background: #fa8c16; }
.chat-msg.ai .avatar { background: #1677ff; }
.chat-msg.agent .avatar { background: #52c41a; }
.chat-msg.system { justify-content: center; }
.chat-msg.system .bubble { background: transparent; color: var(--ant-muted); font-size: 12px; box-shadow: none; }
.chat-msg .bubble {
  max-width: 62%; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.7;
  background: #fff; border: 1px solid #f0f0f0; word-break: break-all;
}
.chat-msg.visitor .bubble { border-top-left-radius: 2px; }
.chat-msg.ai .bubble, .chat-msg.agent .bubble {
  background: var(--ant-primary); color: #fff; border: none; border-top-right-radius: 2px;
}
.chat-msg .meta { font-size: 11px; color: var(--ant-muted); margin-top: 4px; }
.chat-msg.ai .meta, .chat-msg.agent .meta { color: rgba(255, 255, 255, 0.75); }
/* 气泡列撑满剩余宽度，bubble 的 max-width 百分比才能以整栏为基准（否则短消息被时间行宽度挤压成一字一行） */
.chat-msg .msg-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.chat-msg.visitor .msg-col { align-items: flex-end; }
.wb-profile {
  width: 300px; background: #fff; border-radius: var(--ant-radius); border: 1px solid var(--ant-border);
  overflow-y: auto; flex-shrink: 0; padding-bottom: 16px;
}
.wb-profile .section { padding: 14px 16px; border-bottom: 1px solid var(--ant-border); }
.wb-profile .section h4 { margin: 0 0 10px; font-size: 13px; color: var(--ant-muted); font-weight: 600; }
.field-progress { display: flex; flex-direction: column; gap: 6px; }
.field-progress .fp { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.empty-center { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--ant-muted); flex-direction: column; gap: 12px; }
.empty-center .big { font-size: 40px; opacity: 0.45; }
.typing-dots { display: inline-flex; gap: 3px; padding: 12px 14px; background: #fff; border: 1px solid #f0f0f0; border-radius: 8px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: #bfbfbf; animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.25; } 35% { opacity: 1; } }

/* ───────── 通用 ───────── */
.table-card {
  background: #fff; border-radius: var(--ant-radius); border: 1px solid var(--ant-border);
  padding: 4px 20px 16px;
}
.filter-bar { display: flex; gap: 12px; margin: 16px 0; flex-wrap: wrap; align-items: center; }
.channel-grid-card { height: 100%; }
.code-block {
  background: #001529; color: #91caff; border-radius: 8px; padding: 14px 16px;
  font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px; line-height: 1.8; overflow-x: auto; white-space: pre;
}
.masked-tip { font-size: 12px; color: var(--ant-muted); }
.chat-context { max-height: 320px; overflow-y: auto; background: #fafafa; border: 1px solid #f0f0f0; border-radius: 8px; padding: 12px 16px; font-size: 13px; line-height: 2; }

/* antd 细节校准 */
.ant-card { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03); }
/* ── Ant 官方图标基础对齐（@ant-design/icons 自带样式的本地补齐）── */
.anticon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  font-style: normal;
  line-height: 0;
  text-align: center;
  vertical-align: -0.125em;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.anticon > svg { display: block; width: 1em; height: 1em; fill: currentColor; }
.ant-btn .anticon { vertical-align: middle; }
.ant-btn { display: inline-flex; align-items: center; justify-content: center; }
.ant-btn > .anticon + span, .ant-btn > span + .anticon { margin-inline-start: 6px; }
.ant-menu-item .anticon, .ant-menu-submenu-title .anticon { font-size: 15px; }
.chip .anticon, .lf .anticon { vertical-align: baseline; font-size: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bfbfbf; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────── 视觉打磨第二轮 ───────── */
/* 侧栏菜单未读徽标：绝对定位右侧，不压图标文字 */
.ant-menu-item.nav-item { position: relative; padding-right: 52px; }
.nav-badge { position: absolute !important; right: 14px; top: 50%; transform: translateY(-50%); }
.ant-menu-dark .ant-menu-item-group-title { color: rgba(255, 255, 255, 0.38); font-size: 11px; letter-spacing: 1px; }

/* 登录页卖点图标 chips */
.login-feats span { display: flex; align-items: center; gap: 8px; }
.lf {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px;
}
.lf.blue   { background: #e6f4ff; color: #1677ff; }
.lf.orange { background: #fff7e6; color: #fa8c16; }
.lf.green  { background: #f6ffed; color: #52c41a; }
.lf.cyan   { background: #e6fffb; color: #08979c; }
.login-demo .ld-head { margin-bottom: 6px; }
.login-demo .ld-row { display: flex; align-items: center; justify-content: space-between; }
.login-demo .ld-row a { margin-left: 12px; }

/* 工作台：访客消息右对齐（IM 惯例） */
.chat-msg.visitor { flex-direction: row-reverse; }
.chat-msg.visitor .bubble { border-top-left-radius: 8px; border-top-right-radius: 2px; }
.chat-msg.visitor .meta { text-align: right; }

/* 渠道卡片图标 chip */
.channel-grid-card .chip {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* 机器人表单控件撑满 */
#admin .ant-form-item .ant-select, .ant-form-item .ant-picker { width: 100%; }

/* 访客档案增强 */
.wb-profile .vcard { background: linear-gradient(180deg, #f7f9ff, #fff); }
.wb-profile .muted { color: rgba(0, 0, 0, 0.45); }
.wb-profile .src-val { font-size: 12px; word-break: break-all; display: inline-block; max-width: 200px; }
.stat-line { display: flex; gap: 8px; }
.stat-line .sl { flex: 1; text-align: center; background: #fafafa; border-radius: 8px; padding: 8px 4px; }
.stat-line .sl b { display: block; font-size: 17px; }
.stat-line .sl span { font-size: 11px; color: rgba(0, 0, 0, 0.45); }
.wb-profile .ant-descriptions-item-label { color: rgba(0, 0, 0, 0.45); }

/* 表单控件撑满卡片宽度（机器人配置页） */
.ant-form .ant-select { width: 100%; }

/* 访问路径 */
.path-list { display: flex; flex-direction: column; gap: 6px; }
.path-item { display: flex; align-items: center; gap: 10px; background: #fafafa; border-radius: 8px; padding: 7px 10px; }
.path-no { width: 20px; height: 20px; border-radius: 50%; background: #e6f4ff; color: #1677ff; font-size: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.path-body { flex: 1; min-width: 0; }
.path-title { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
