/* =============================================================================
 * 企微IT智能服务台 — 坐席工作台全局样式
 * =============================================================================
 * 说明：全局基础样式，包括：
 *   1. CSS 变量（主题色、间距等）
 *   2. 全局重置样式
 *   3. 通用工具类
 *   4. 坐席工作台专用样式
 * ============================================================================= */

/* --------------------------------------------------------------------------
 * CSS 变量 — 统一管理主题色和间距（同步原型 v5.3）
 * 色值体系来源：Tailwind / shadcn-ui 色板，原型 v5.3 定义
 * -------------------------------------------------------------------------- */
:root {
  /* ---- 浅色主题背景色 — 企微风格（更柔和的灰） ---- */
  --bg-primary: #f7f7f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #ededed;
  --bg-hover: #e8ecf1;
  --bg-active: #dce3ec;
  --bg-accent-soft: rgba(7, 193, 96, 0.1);

  /* ---- 浅色主题文字色 — 企微风格 ---- */
  --text-primary: #191919;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-muted: #999999;         /* 同 text-tertiary，原型命名 */
  --text-placeholder: #c0c4cc;

  /* ---- 浅色主题边框色 — 企微风格（更淡） ---- */
  --border: #e5e5e5;             /* 原型命名 */
  --border-color: #e5e5e5;       /* 兼容旧引用 */
  --border-light: #f0f0f0;

  /* ---- 主色调 — 企微绿 ---- */
  --accent: #07C160;
  --accent-hover: #06ae56;
  --accent-soft: rgba(7, 193, 96, 0.1);

  /* ---- 语义色 — 企微风格 ---- */
  --color-primary: #07C160;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #60a5fa;

  /* 语义色 soft 版（标签/徽章背景） */
  --success-soft: #dcfce7;
  --warning-soft: #fef3c7;
  --danger-soft: #fee2e2;
  --accent-soft: rgba(7, 193, 96, 0.1);

  /* 扩展色 */
  --purple: #8b5cf6;
  --purple-soft: #ede9fe;
  --orange: #f97316;
  --orange-soft: #fff7ed;

  /* VIP 标记色 */
  --color-vip: #ef4444;
  /* 招手标记色 */ /* 修改：术语替换 举手→招手 */
  --color-hand-raise: #f59e0b;
  /* 需介入标记色 */
  --color-need-intervene: #ef4444;
  /* 情绪标记色 */
  --color-emotion-neutral: #94a3b8;
  --color-emotion-worried: #f59e0b;
  --color-emotion-angry: #ef4444;
  --color-emotion-urgent: #ef4444;

  /* AI 标记色 */
  --color-ai: #22c55e;

  /* ---- 圆角 — 企微风格偏圆润 ---- */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* ---- 间距 ---- */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* ---- 阴影 ---- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

  /* ---- 过渡 ---- */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- 三栏布局尺寸 ---- */
  --sidebar-width: 280px;
  --assistant-panel-width: 320px;
}

/* ---- 深色主题覆盖（同步原型 v5.3） ---- */
[data-theme="dark"] {
  --bg-primary: #0f1923;
  --bg-secondary: #151f2b;
  --bg-tertiary: #1a2736;
  --bg-hover: #1e3044;
  --bg-active: #243b52;
  --bg-accent-soft: #2b5f8a;

  --text-primary: #e8edf2;
  --text-secondary: #8ba1b7;
  --text-tertiary: #5c7185;
  --text-muted: #5c7185;
  --text-placeholder: #3d5568;

  --border: #1e3044;
  --border-color: #1e3044;
  --border-light: #2a3f56;

  --accent: #4da6ff;
  --accent-hover: #73b9ff;
  --accent-soft: #2b5f8a;

  --color-primary: #4da6ff;
  --color-success: #34d399;
  --color-warning: #fbbf24;
  --color-danger: #f87171;
  --color-info: #60a5fa;

  --success-soft: #1a3a2a;
  --warning-soft: #3a2f10;
  --danger-soft: #3a1a1a;
  --accent-soft: #2b5f8a;

  --purple: #a78bfa;
  --purple-soft: #2d2060;
  --orange: #fb923c;
  --orange-soft: #3d1f08;

  --color-vip: #f87171;
  --color-hand-raise: #fbbf24;
  --color-need-intervene: #f87171;
  --color-emotion-neutral: #8ba1b7;
  --color-emotion-worried: #fbbf24;
  --color-emotion-angry: #f87171;
  --color-emotion-urgent: #f87171;
  --color-ai: #34d399;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35);
}

/* --------------------------------------------------------------------------
 * 全局重置
 * -------------------------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s, color 0.3s;
}

#app {
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------------------------
 * 通用工具类
 * -------------------------------------------------------------------------- */

/* 文本省略 */
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flex 布局 */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 标签样式 */
.tag-vip {
  color: var(--color-vip);
  font-weight: bold;
}

.tag-hand-raise {
  color: var(--color-hand-raise);
  font-weight: bold;
}

.tag-need-intervene {
  color: var(--color-need-intervene);
  font-weight: bold;
}

.tag-ai {
  color: var(--color-ai);
  font-weight: bold;
}

/* --------------------------------------------------------------------------
 * 坐席工作台专用样式
 * -------------------------------------------------------------------------- */

/* 三栏布局容器：纵向（顶栏 + 三栏区域） */
.workspace-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* 三栏区域：顶栏下方，横向排列左/中/右栏 */
.workspace-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* 左栏：会话列表（v5.4: 去掉 border-right，拖拽手柄替代） */
.workspace-sidebar {
  width: var(--sidebar-width);
  min-width: 200px;
  height: 100%;
  border-right: none;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 中栏：对话区 */
.workspace-main {
  flex: 1;
  height: 100%;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0; /* 防止 flex 子元素溢出 */
}

/* 右栏：AI助手面板（v5.4: 去掉 border-left，拖拽手柄替代） */
.workspace-assistant {
  width: var(--assistant-panel-width);
  min-width: 220px;
  height: 100%;
  border-left: none;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ===== v5.4: 拖拽手柄（栏间调整宽度） ===== */
.resize-handle {
  width: 6px;
  cursor: col-resize;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
  z-index: 10;
}
.resize-handle:hover,
.resize-handle.dragging {
  background: var(--accent);
}
.resize-handle::after {
  content: '⋮';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}
.resize-handle:hover::after,
.resize-handle.dragging::after {
  opacity: 1;
}

/* 顶部标题栏 */
.workspace-header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* 侧边栏搜索框 */
.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* 会话列表滚动区 */
.conversation-list-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 消息列表滚动区 */
.message-list-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}

/* 消息气泡通用样式 */
.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

/* 员工消息气泡 — 靠左灰底 */
.message-employee {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  align-self: flex-start;
  border-top-left-radius: 2px;
}

/* 坐席消息气泡 — 靠右蓝底白字 */
.message-agent {
  background-color: var(--accent);
  color: var(--bg-secondary);
  align-self: flex-end;
  border-top-right-radius: 2px;
}

/* AI消息气泡 — 靠左绿底 */
.message-ai {
  background-color: var(--bg-accent-soft);
  color: var(--text-primary);
  align-self: flex-start;
  border-top-left-radius: 2px;
  border: 1px solid var(--border-light);
}

/* 系统消息气泡 — 居中灰字 */
.message-system {
  background-color: transparent;
  color: var(--text-tertiary);
  align-self: center;
  font-size: 12px;
  padding: 4px 12px;
}

/* 消息行 */
.message-row {
  display: flex;
  margin-bottom: 16px;
  flex-direction: column;
}

.message-row-employee {
  align-items: flex-start;
}

.message-row-agent {
  align-items: flex-end;
}

.message-row-ai {
  align-items: flex-start;
}

.message-row-system {
  align-items: center;
}

/* 消息发送者名称 */
.message-sender-name {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

/* 消息时间戳 */
.message-time {
  font-size: 11px;
  color: var(--text-placeholder);
  margin-top: 4px;
}

/* AI标签 */
.ai-tag {
  display: inline-block;
  background-color: var(--color-ai);
  color: var(--bg-secondary);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* 会话项（v5.4: flex 布局含头像+内容+缩略头像） */
.conversation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 1px 6px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: var(--radius);
  border: 1px solid transparent;
  position: relative;
}

.conversation-item:hover {
  background-color: var(--bg-hover);
}

.conversation-item.active {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}

.conversation-item.resolved {
  opacity: 0.6;
}

.conversation-item.resolved .conversation-name {
  color: var(--text-tertiary);
}

/* ===== v5.4: 会话头像容器（含新消息圆点） ===== */
.conv-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

/* 会话项头像 — 渐变色圆形 */
.conversation-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
/* 渐变色变体 */
.conversation-avatar.av-blue   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.conversation-avatar.av-green  { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.conversation-avatar.av-orange { background: linear-gradient(135deg, #f97316, #eab308); }
.conversation-avatar.av-purple { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.conversation-avatar.av-red    { background: linear-gradient(135deg, #ef4444, #f97316); }
.conversation-avatar.av-teal   { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.conversation-avatar.av-pink   { background: linear-gradient(135deg, #ec4899, #f43f5e); }

/* ===== v5.4: 新消息圆点（在头像右上角） ===== */
.new-msg-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
  z-index: 2;
}
.new-msg-dot.dot-urgent { background: var(--color-danger); }
.new-msg-dot.dot-normal { background: var(--accent); }
.new-msg-dot.dot-muted  { background: var(--text-muted); }

/* ===== v5.4: 处理对象缩略头像（会话项右侧） ===== */
.conv-target-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  margin-left: auto;
}
.conv-target-avatar.ta-blue   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.conv-target-avatar.ta-green  { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.conv-target-avatar.ta-orange { background: linear-gradient(135deg, #f97316, #eab308); }
.conv-target-avatar.ta-purple { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.conv-target-avatar.ta-red    { background: linear-gradient(135deg, #ef4444, #f97316); }
.conv-target-avatar.ta-teal   { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.conv-target-avatar.ta-pink   { background: linear-gradient(135deg, #ec4899, #f43f5e); }

/* 会话项信息区（v5.4: flex:1 中间内容区） */
.conversation-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.conversation-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.conversation-summary {
  font-size: 12px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.conversation-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.conversation-time {
  font-size: 11px;
  color: var(--text-placeholder);
}

/* 分区标题 */
.section-title {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-tertiary);
  background-color: var(--bg-primary);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.section-title:hover {
  background-color: var(--bg-hover);
}

/* ===== v5.4: 待办事项缩略头像 ===== */
.todo-item .ki-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  margin-left: auto;
}
.ki-avatar.ka-blue   { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.ki-avatar.ka-green  { background: linear-gradient(135deg, #22c55e, #14b8a6); }
.ki-avatar.ka-orange { background: linear-gradient(135deg, #f97316, #eab308); }
.ki-avatar.ka-purple { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.ki-avatar.ka-red    { background: linear-gradient(135deg, #ef4444, #f97316); }

/* 标签徽章 — 使用语义色变量，深浅色自动适配 */
.tag-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1.5;
  font-weight: 500;
}

.tag-badge-vip {
  background-color: var(--danger-soft);
  color: var(--color-danger);
  border: 1px solid var(--danger-soft);
}

.tag-badge-hand-raise {
  background-color: var(--warning-soft);
  color: var(--color-warning);
  border: 1px solid var(--warning-soft);
}

.tag-badge-need-intervene {
  background-color: var(--danger-soft);
  color: var(--color-danger);
  border: 1px solid var(--danger-soft);
}

.tag-badge-emotion-urgent {
  background-color: var(--danger-soft);
  color: var(--color-danger);
  border: 1px solid var(--danger-soft);
}

.tag-badge-emotion-angry {
  background-color: var(--danger-soft);
  color: var(--color-danger);
  border: 1px solid var(--danger-soft);
}

.tag-badge-emotion-worried {
  background-color: var(--warning-soft);
  color: var(--color-warning);
  border: 1px solid var(--warning-soft);
}

/* 紧急度星级 */
.urgency-stars {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.urgency-star {
  font-size: 12px;
  color: var(--color-warning);
}

.urgency-star.empty {
  color: var(--text-placeholder);
}

/* 回复输入框区域 */
.reply-box {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  flex-shrink: 0;
}

/* 输入框在 flex 容器里占满宽度 */
.reply-box > div:first-child {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.reply-box .el-input {
  flex: 1;
  min-width: 0;
}

/* 输入框 textarea 最大高度限制 + 滚动 */
.reply-box .el-textarea__inner {
  max-height: 200px;
  overflow-y: auto;
}

/* 操作步骤卡片 */
.step-card {
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 6px;
  background-color: var(--bg-primary);
  border-left: 3px solid var(--accent);
}

/* 登录页样式 */
.login-container {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  width: 400px;
  padding: 40px;
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.login-title {
  text-align: center;
  margin-bottom: 32px;
}

.login-title h1 {
  font-size: 24px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-title p {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-placeholder);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
 * IT 等级徽标（7 级）
 * -------------------------------------------------------------------------- */
.it-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--bg-secondary);
  flex-shrink: 0;
}

.it-badge.bronze   { background: linear-gradient(135deg, #cd7f32, #a0522d); }
.it-badge.silver   { background: linear-gradient(135deg, #c0c0c0, #8e8e8e); }
.it-badge.gold     { background: linear-gradient(135deg, #ffd700, #daa520); }
.it-badge.platinum { background: linear-gradient(135deg, #e5e4e2, #b0b0b0); }
.it-badge.diamond  { background: linear-gradient(135deg, #b9f2ff, #00bfff); color: #0a2540; }
.it-badge.star     { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.it-badge.king     { background: linear-gradient(135deg, #f093fb, #f5576c, #ffd700); animation: king-glow 2s ease-in-out infinite; }

/* 王者发光动画 */
@keyframes king-glow {
  0%, 100% {
    box-shadow: 0 0 4px rgba(245, 87, 108, 0.4);
  }
  50% {
    box-shadow: 0 0 12px rgba(245, 87, 108, 0.8), 0 0 20px rgba(240, 147, 251, 0.4);
  }
}

/* 响应式：小屏幕下右栏可折叠 */
@media (max-width: 1024px) {
  .workspace-assistant {
    position: absolute;
    right: 0;
    top: 0;
    z-index: 100;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .workspace-assistant.visible {
    transform: translateX(0);
  }
}
