/* BinoLink 客服工作台样式 — 蓝白配色（主色 #4F46E5，与主站 admin 一致） */
:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --primary-light: #EEF2FF;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --border: #E5E9F2;
  --text: #1E2433;
  --text-sub: #6B7280;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --warn: #D97706;
  --warn-light: #FFFBEB;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(30, 36, 51, .06), 0 4px 14px rgba(30, 36, 51, .05);
  /* 主站式侧边栏变量 */
  --sidebar-w: 230px;
  --sidebar-bg: #FFFFFF;
  --sidebar-hover: #F0F4FF;
  --sidebar-active-bg: #EEF2FF;
  --sidebar-active-border: #4F46E5;
  --sidebar-text: #5A6978;
  --sidebar-text-hover: #1E293B;
  --sidebar-text-active: #4F46E5;
  --sidebar-divider: #E8ECF0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 500;
  padding: 8px 16px;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn-ghost { background: transparent; color: var(--text-sub); }
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- 登录页 ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F7FB 50%, #E0E7FF 100%);
}
.login-card {
  width: 380px; max-width: 92vw;
  background: var(--card); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(79, 70, 229, .12);
  padding: 36px 32px;
}
.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo h1 { font-size: 24px; margin-top: 10px; color: var(--text); }
.login-sub { color: var(--text-sub); margin-top: 4px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.login-msg { min-height: 20px; margin-bottom: 10px; font-size: 13px; }
.login-msg.error { color: var(--danger); }
.login-foot { text-align: center; color: #9CA3AF; font-size: 12px; margin-top: 22px; }

/* ---------- 顶栏：统一由 css/sidebar.css 负责（56px logo+标题+状态，全站同款） ---------- */

/* ---------- 左侧导航：统一由 css/sidebar.css 负责（主站后台式框架） ---------- */
/* 工作台主体为侧边栏让位（sidebar.css 的 .sidebar-content 不适用于双栏工作台，此处单独定义） */
/* 双白卡：容器露出统一灰底，两块面板各自独立白卡（#307） */
.workbench {
  display: flex; gap: 14px; padding: 14px;
  height: calc(100vh - 56px);
  max-width: 1400px; margin-left: var(--sidebar-w);
  box-sizing: border-box;
}

/* ---------- 左：会话列表（白卡） ---------- */
.session-panel {
  width: 300px; min-width: 280px;
  background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.session-filter { padding: 12px 12px 8px; border-bottom: 1px solid var(--border); }
.session-filter input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none;
}
.session-filter input:focus { border-color: var(--primary); }
.session-tabs { display: flex; gap: 6px; margin-top: 10px; }
.tab {
  flex: 1; padding: 6px 0; font-size: 13px;
  border: none; background: transparent; border-radius: 6px;
  color: var(--text-sub); cursor: pointer;
}
.tab.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.session-list { flex: 1; overflow-y: auto; }
.session-item {
  padding: 12px 14px; border-bottom: 1px solid #F0F2F7;
  cursor: pointer; transition: background .12s;
  position: relative;
}
.session-item:hover { background: #FAFBFF; }
.session-item.active { background: var(--primary-light); border-left: 3px solid var(--primary); }
.session-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session-item-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.session-item-time { font-size: 11px; color: #9CA3AF; flex-shrink: 0; }
.session-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase;
}
.badge.note { background: #FEF3C7; color: #B45309; font-size: 12px; padding: 1px 6px; }
.session-item-msg {
  font-size: 12px; color: var(--text-sub); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}
.session-item-badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
}
.badge.pending { background: var(--warn-light); color: var(--warn); }
.badge.active { background: var(--primary-light); color: var(--primary); }
.badge.claimed { background: var(--success-light); color: var(--success); }
.badge.closed { background: #F3F4F6; color: #6B7280; }
.badge.unread {
  background: var(--danger); color: #fff; border-radius: 999px;
  min-width: 18px; text-align: center; padding: 1px 6px; font-weight: 600;
}
.badge.assignee { background: #F3F4F6; color: var(--text-sub); }
.badge.domain {
  background: #E0E7FF; color: var(--primary-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.session-item-msg.preview { color: var(--text); }
.session-item-msg.url {
  color: var(--text-sub);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}
.list-empty { padding: 30px; text-align: center; color: #9CA3AF; font-size: 13px; }
.session-more { padding: 8px 12px; border-top: 1px solid var(--border); }
.session-more .btn { width: 100%; }

/* ---------- 会话备注编辑条 ---------- */
.note-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  background: #FFFBEB;
}
.note-bar input {
  flex: 1; padding: 6px 10px;
  border: 1px solid #FDE68A; border-radius: 8px; font-size: 13px; outline: none;
  background: #fff;
}
.note-bar input:focus { border-color: var(--primary); }
.chat-head-actions .btn.has-note {
  background: #FEF3C7; color: #B45309; border-color: #FDE68A;
}

/* ---------- 图标按钮（聊天头操作 / 模板按钮，30px 方形） ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text-sub);
  cursor: pointer; flex-shrink: 0;
  transition: all .15s ease;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--primary-light); color: var(--primary); border-color: #C7D2FE; }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.icon-btn-danger { color: var(--danger); }
.icon-btn-danger:hover { background: var(--danger-light); color: var(--danger); border-color: #FECACA; }
.icon-btn.has-note {
  background: #FEF3C7; color: #B45309; border-color: #FDE68A;
}
.icon-btn.has-note:hover { background: #FDE68A; color: #B45309; }

/* ---------- 右：聊天窗（白卡） ---------- */
.chat-panel {
  flex: 1; display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #9CA3AF; gap: 8px;
}
.chat-empty .sub { font-size: 12px; color: #C0C6D2; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.chat-head-title { font-size: 15px; font-weight: 600; }
.chat-head-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
/* 标题区可点击唤起会话详情（#314 信息简化） */
.chat-head-info {
  cursor: pointer; border-radius: 8px; padding: 4px 8px; margin-left: -8px;
  transition: background .12s ease; min-width: 0;
}
.chat-head-info:hover { background: var(--primary-light); }
.chat-head-info:active { background: #E0E7FF; }
.chat-head-info .chat-head-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; display: inline-block; vertical-align: bottom; }
.chat-head-info .chat-head-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.chat-head-actions { display: flex; align-items: center; gap: 10px; }
/* 状态徽章：纯色圆点 + 浅色光晕（#313 去文字，颜色+title 表达状态） */
.status-badge {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0; display: inline-block;
}
.status-badge.pending { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-light); }
.status-badge.active { background: var(--success); box-shadow: 0 0 0 3px var(--success-light); }
.status-badge.closed { background: #9CA3AF; box-shadow: 0 0 0 3px #F3F4F6; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px 20px;
  background: #FAFBFF;
  display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; max-width: 75%; flex-direction: column; }
.msg.visitor { align-self: flex-start; }
.msg.admin { align-self: flex-end; align-items: flex-end; }
.msg-meta { font-size: 11px; color: #9CA3AF; margin-bottom: 4px; }
.msg-bubble {
  padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
}
.msg.visitor .msg-bubble { background: #fff; border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.admin .msg-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.msg-system {
  align-self: center; font-size: 12px; color: #9CA3AF;
  background: #F3F4F6; padding: 3px 12px; border-radius: 999px;
}
.msg-load-more { align-self: center; font-size: 12px; color: var(--primary); cursor: pointer; padding: 4px 10px; }

.chat-input {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 12px; align-items: flex-end;
}
.chat-input textarea {
  flex: 1; resize: none; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none; line-height: 1.5;
  max-height: 120px;
}
.chat-input textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

/* ---------- 快捷回复模板 ---------- */
.template-bar { position: relative; padding: 8px 20px 0; display: flex; }
.template-dropdown {
  position: absolute; left: 20px; bottom: 100%; z-index: 30;
  width: 320px; max-height: 280px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15,23,42,.15); padding: 6px;
}
.template-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.template-item:hover { background: #F1F0FF; }
.template-title { font-size: 13px; font-weight: 600; color: var(--text); }
.template-preview { font-size: 12px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.template-empty { font-size: 12px; color: var(--text-sub); padding: 10px; text-align: center; }
.template-manage {
  margin-top: 4px; padding: 8px 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--primary); cursor: pointer; text-align: center;
}
.template-manage:hover { background: #F1F0FF; border-radius: 8px; }

/* ---------- 客户评分 ---------- */
.session-rating {
  font-size: 13px; letter-spacing: 1px; color: #F59E0B;
  background: #FFFBEB; border: 1px solid #FDE68A;
  padding: 2px 8px; border-radius: 999px;
}
.session-item-rating { font-size: 12px; color: #F59E0B; letter-spacing: 1px; }

/* ---------- 会话详情弹窗（#314 信息简化：详情点击弹窗展示） ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-panel {
  width: 420px; max-width: 100%;
  background: var(--card); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px; border: none; background: transparent;
  font-size: 22px; line-height: 1; color: var(--text-sub); cursor: pointer; border-radius: 8px;
}
.modal-close:hover { background: rgba(0,0,0,.05); color: var(--text); }
.modal-body { padding: 16px 20px; }
.info-grid { display: grid; grid-template-columns: 84px 1fr; gap: 10px 14px; font-size: 13px; }
.info-grid .info-label { color: var(--text-sub); }
.info-grid .info-value { color: var(--text); word-break: break-all; line-height: 1.45; }
.info-grid .info-value.url { color: var(--primary); text-decoration: none; }
.info-grid .info-value.url:hover { text-decoration: underline; }
.info-grid .info-badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--primary-light); color: var(--primary);
}
.info-grid .info-badge.closed { background: #F3F4F6; color: var(--text-sub); }

/* ---------- 移动端适配 ---------- */
/* ≤768：会话列表变左侧抽屉（默认隐藏），聊天面板全屏——移动端优先聊天口 */
#session-list-btn { display: none; }
@media (max-width: 768px) {
  .workbench { margin-left: 0; padding: 0; gap: 0; }
  .session-panel {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 120;
    width: 300px; min-width: 280px; height: auto;
    border-right: 1px solid var(--border);
    box-shadow: 0 0 30px rgba(15, 23, 42, .18);
    transform: translateX(-105%); transition: transform .22s ease;
    background: var(--card);
    border-radius: 0 12px 12px 0;
  }
  .workbench.sessions-open .session-panel { transform: translateX(0); }
  .chat-panel { width: 100%; border-radius: 0; border: none; box-shadow: none; }
  .msg { max-width: 88%; }
  .topbar-title { display: none; }
  .chat-head-actions { gap: 6px; }
  .chat-head-actions .status-badge { width: 8px; height: 8px; }
  .chat-head-actions .icon-btn { width: 28px; height: 28px; }
  .chat-head-actions .icon-btn svg { width: 15px; height: 15px; }
  .chat-head-actions .btn { font-size: 12px; padding: 4px 8px; }
  .session-item-msg { max-width: 180px; }
}
@media (max-width: 600px) {
  .workbench { margin-left: 0; }
  .session-panel { left: 0; width: min(86vw, 320px); }
  .topbar-badge { display: none; }
  .chat-head-title { font-size: 14px; }
  .chat-head-sub { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------- 移动端会话唤起按钮（≤768：顶栏右上角与 LOGO 水平对齐，避免与发送键重叠） ---------- */
#sessions-fab { display: none; }
@media (max-width: 768px) {
  #sessions-fab {
    display: inline-flex; position: relative;
    width: 30px; height: 30px; border-radius: 8px;
    border: none; cursor: pointer;
    background: var(--primary);
    color: #fff; box-shadow: 0 3px 10px rgba(79, 70, 229, .35);
    align-items: center; justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
    flex-shrink: 0;
  }
  #sessions-fab:active { transform: scale(.92); }
  #sessions-fab svg { width: 17px; height: 17px; }
  #sessions-fab .fab-badge {
    position: absolute; top: -5px; right: -5px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: #DC2626; color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
    border: 2px solid #fff;
  }
  #sessions-fab .fab-badge.hidden { display: none; }
}

/* ---------- 设置面板（已改为独立单页 settings.html，样式内联） ---------- */
/* ---------- 账户管理（已移至 settings.html 内联） ---------- */
.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
.badge.pending { background: var(--warn-light); color: var(--warn); }
.badge.claimed { background: var(--success-light); color: var(--success); }
