/* ===== 爱丽思智能助手 · 管理后台样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #6c5ce7;
  --primary-dark: #5a4bd1;
  --primary-light: #eef0ff;
  --accent: #a29bfe;
  --bg: #f5f6fb;
  --card: #ffffff;
  --text: #2d3436;
  --text-sub: #7f8c9b;
  --border: #e4e7f0;
  --ok: #00b894;
  --warn: #fdcb6e;
  --bad: #e17055;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---- 顶栏 ---- */
.topbar {
  height: 62px;
  background: linear-gradient(120deg, #6c5ce7, #8e7bf0 60%, #a29bfe);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; color: #fff;
  box-shadow: 0 2px 12px rgba(108, 92, 231, .35);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; letter-spacing: 1px;
  border: 1px solid rgba(255,255,255,.35);
}
.brand h1 { font-size: 18px; font-weight: 600; }
.brand p { font-size: 12px; opacity: .85; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: .95; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); display: inline-block; }
.status-dot.ok { background: #55efc4; box-shadow: 0 0 6px #55efc4; }
.status-dot.err { background: #ff7675; }

/* ---- 布局 ---- */
.layout { display: flex; min-height: calc(100vh - 62px); }
.sidebar {
  width: 210px; background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 12px; flex-shrink: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px 14px; margin-bottom: 6px;
  border: none; background: transparent; border-radius: 10px;
  font-size: 14px; color: var(--text); cursor: pointer;
  transition: all .15s;
}
.nav-item:hover { background: var(--primary-light); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(108,92,231,.3); }
.nav-icon { font-size: 16px; }
.badge {
  margin-left: auto; background: var(--bad); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
}
.badge.hidden { display: none; }

.content { flex: 1; padding: 22px; overflow-y: auto; }
.view { display: none; }
.view.active { display: block; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- 通用 ---- */
.btn {
  border: none; border-radius: 8px; padding: 8px 16px;
  font-size: 14px; cursor: pointer; transition: all .15s;
  background: #eef0f5; color: var(--text);
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff0ec; color: var(--bad); border: 1px solid #ffd9cf; }
.btn-danger:hover { background: #ffe4dd; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; padding: 10px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.empty { color: var(--text-sub); text-align: center; padding: 28px 10px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 16px; font-weight: 600; }
.panel-head .hint { font-size: 12px; color: var(--text-sub); }

/* ---- 知识库管理 ---- */
.kb-layout { display: flex; gap: 16px; height: calc(100vh - 110px); }
.kb-list-panel {
  width: 280px; background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 14px; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.doc-list { flex: 1; overflow-y: auto; margin-top: 4px; }
.doc-group-title {
  font-size: 12px; color: var(--text-sub); font-weight: 600;
  padding: 10px 6px 4px; letter-spacing: .5px;
}
.doc-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  margin-bottom: 4px; border: 1px solid transparent; transition: all .12s;
}
.doc-item:hover { background: var(--primary-light); }
.doc-item.active { background: var(--primary-light); border-color: var(--accent); }
.doc-item .t { font-size: 14px; font-weight: 500; }
.doc-item .m { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.kb-editor-panel { flex: 1; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.doc-editor { height: 100%; overflow-y: auto; padding: 20px 24px; }
.editor-empty { text-align: center; padding-top: 120px; color: var(--text-sub); }
.editor-empty p { font-size: 15px; }
.editor-empty .sub { font-size: 12px; margin-top: 8px; opacity: .7; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #444; }
.field input[type="text"], .field textarea, .field select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; line-height: 1.6; }
.field .sub-hint { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.editor-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.qa-item { background: #fafafe; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.qa-item input { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; margin-bottom: 5px; }
.qa-item .qa-rm { float: right; margin-top: -2px; }

/* ---- 调教 ---- */
.train-layout { display: flex; gap: 16px; height: calc(100vh - 110px); }
.chat-panel {
  flex: 1.4; background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden;
}
.chat-panel .panel-head { padding: 14px 18px 0; }
.mode-tag {
  font-size: 12px; background: var(--primary-light); color: var(--primary);
  padding: 3px 10px; border-radius: 20px; font-weight: 500;
}
.chat-box { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 88%; }
.msg-agent { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.msg-agent .msg-avatar { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.msg-user .msg-avatar { background: #b2bec3; }
.msg-body {
  background: var(--primary-light); border-radius: 12px 12px 12px 4px;
  padding: 10px 14px; line-height: 1.7; font-size: 14px;
  white-space: pre-wrap; word-break: break-word;
}
.msg-user .msg-body { background: var(--primary); color: #fff; border-radius: 12px 12px 4px 12px; }
.msg-meta { font-size: 11px; color: var(--text-sub); margin-top: 6px; }
.src-list { margin-top: 8px; font-size: 12px; color: var(--text-sub); }
.src-list b { color: var(--primary); }
.chat-input-row { display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.chat-input-row input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none;
}
.chat-input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(162,155,254,.2); }
.feedback-panel {
  flex: 1; background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 16px 18px; overflow-y: auto;
}
.feedback-target {
  font-size: 12px; color: var(--text-sub); background: #fafafe;
  border-radius: 8px; padding: 10px; margin-bottom: 14px;
  max-height: 72px; overflow: hidden; border: 1px dashed var(--border);
}
.fb-field { margin-bottom: 14px; }
.fb-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.fb-field textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical;
}
.star-row { display: flex; gap: 4px; }
.star { font-size: 26px; color: #d5d9e2; cursor: pointer; transition: transform .1s, color .1s; }
.star:hover { transform: scale(1.15); }
.star.on { color: #fdcb6e; text-shadow: 0 0 6px rgba(253,203,110,.5); }
.verdict-row { display: flex; gap: 8px; margin-top: 8px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 20px;
  padding: 5px 14px; font-size: 13px; cursor: pointer; transition: all .12s;
}
.chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ---- 反馈记录 ---- */
.fb-list { display: flex; flex-direction: column; gap: 10px; }
.fb-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: all .12s;
}
.fb-card:hover { border-color: var(--accent); box-shadow: 0 3px 10px rgba(108,92,231,.08); }
.fb-card .fb-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.fb-card .fb-q { font-weight: 600; font-size: 14px; flex: 1; }
.fb-card .fb-time { font-size: 12px; color: var(--text-sub); }
.fb-card .fb-body { font-size: 13px; color: #555; line-height: 1.6; }
.fb-card .fb-body .lbl { color: var(--text-sub); margin-right: 4px; }
.fb-card .fb-actions { margin-top: 10px; display: flex; gap: 8px; }
.verdict-badge { font-size: 12px; padding: 2px 10px; border-radius: 20px; }

/* ---- 工作日志 ---- */
.log-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 900px) { .log-stats { grid-template-columns: repeat(3, 1fr); } }
.log-stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 12px; text-align: center;
}
.log-stat-num { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.log-stat-label { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.log-trend {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}
.trend-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--text); }
.trend-bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bar {
  width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: 5px 5px 0 0; min-height: 4px; transition: height .3s;
}
.trend-num { font-size: 11px; color: var(--text-sub); margin-top: 4px; }
.trend-date { font-size: 10px; color: var(--text-sub); margin-top: 2px; }
.log-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.log-filter > span { font-size: 13px; color: var(--text-sub); }
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px;
}
.log-card:hover { border-color: var(--accent); }
.log-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.log-channel { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.log-ch-web { background: #eef2ff; color: #4f46e5; }
.log-ch-feishu { background: #e8f7f0; color: #059669; }
.log-ch-dingtalk { background: #fff4e6; color: #d97706; }
.log-user { font-size: 13px; font-weight: 600; color: var(--text); }
.log-time { font-size: 12px; color: var(--text-sub); }
.log-mode { font-size: 11px; color: var(--text-sub); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.log-q { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; line-height: 1.5; }
.log-a { font-size: 13px; color: #555; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.log-src { font-size: 12px; color: var(--text-sub); margin-top: 6px; }
.verdict-满意 { background: #e6fbf4; color: var(--ok); }
.verdict-一般 { background: #fff7e6; color: #d98e04; }
.verdict-不满意 { background: #fff0ec; color: var(--bad); }
.status-badge { font-size: 12px; padding: 2px 10px; border-radius: 20px; background: #eef0f5; color: var(--text-sub); }
.status-已入库 { background: #e6fbf4; color: var(--ok); }
.status-待入库 { background: #fff7e6; color: #d98e04; }
.fb-stats { display: flex; gap: 16px; font-size: 13px; color: var(--text-sub); }
.fb-stats b { color: var(--primary); font-size: 15px; }

/* ---- 配置 ---- */
.config-wrap { max-width: 860px; display: flex; flex-direction: column; gap: 16px; }
.config-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.config-card h3 { font-size: 15px; margin-bottom: 14px; color: #333; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.config-card label { display: block; font-size: 13px; font-weight: 600; color: #444; margin-bottom: 10px; }
.config-card label.checkbox { font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 8px; }
.config-card input[type="text"], .config-card input[type="password"], .config-card input[type="number"], .config-card textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; margin-top: 6px; font-family: inherit;
}
.config-card textarea { resize: vertical; }
.config-actions { display: flex; align-items: center; gap: 14px; }
.save-msg { font-size: 13px; color: var(--ok); }
.feishu-status {
  background: #fafafe; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 13px; line-height: 1.9; margin-bottom: 14px;
}
.feishu-status .ok { color: var(--ok); font-weight: 600; }
.feishu-status .err { color: var(--bad); font-weight: 600; }
.feishu-status .dim { color: var(--text-sub); }
.feishu-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ---- 知识库分类树 ---- */
.head-actions { display: flex; gap: 6px; }
.cat-tree {
  border-bottom: 1px solid var(--border); padding: 6px 0 6px; max-height: 32vh;
  overflow-y: auto; background: #fbfbfd;
}
.cat-item, .cat-sub {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  cursor: pointer; font-size: 13px; border-left: 3px solid transparent;
}
.cat-item:hover, .cat-sub:hover { background: #f1f3f9; }
.cat-item.active, .cat-sub.active { background: #eef2ff; border-left-color: #4c6ef5; color: #4c6ef5; font-weight: 600; }
.cat-sub { padding-left: 30px; font-size: 12.5px; color: var(--text-sub); }
.cat-name { flex: 1; }
.cat-count { color: var(--text-sub); font-size: 12px; background: #eef0f6; border-radius: 10px; padding: 1px 8px; }
.cat-item.active .cat-count, .cat-sub.active .cat-count { background: #dde5ff; color: #4c6ef5; }
.cat-toggle { color: var(--text-sub); font-size: 11px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---- 弹窗 / Toast ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 14px; width: 560px; max-width: 92vw;
  max-height: 82vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; overflow-y: auto; font-size: 13px; line-height: 1.7; }
.modal-body .blk { margin-bottom: 12px; }
.modal-body .blk b { color: var(--text-sub); display: block; margin-bottom: 3px; }
.toast {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%);
  background: #2d3436; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  transition: opacity .25s;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--bad); }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .kb-layout, .train-layout { flex-direction: column; height: auto; }
  .kb-list-panel, .chat-panel, .feedback-panel { width: 100%; }
}
