/* 云桥客服 · 坐席工作台 */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #1f2430;
  --muted: #7a8194;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gray: #9ca3af;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%);
  padding: 24px;
}
.auth-card {
  background: #fff; border-radius: 16px; width: 400px; max-width: 100%;
  padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.brand { text-align: center; margin-bottom: 24px; }
.brand-logo { font-size: 40px; }
.brand-name { font-size: 22px; font-weight: 700; margin-top: 6px; }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 4px; margin-bottom: 20px; }
.tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 6px; color: var(--muted); }
.tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.auth-form label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.auth-form input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .15s;
}
.auth-form input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; margin-top: 20px; padding: 11px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); }
.form-error { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ---------- 工作台布局 ---------- */
.app { display: grid; grid-template-columns: 220px 340px 1fr; height: 100vh; }
.sidebar { background: #101828; color: #e5e7eb; display: flex; flex-direction: column; }
.side-head { padding: 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mini { font-weight: 700; font-size: 15px; }
.workspace-name { font-size: 12px; color: #9ca3af; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters { padding: 12px 8px; flex: 1; }
.filter {
  display: block; width: 100%; text-align: left; padding: 9px 12px; margin-bottom: 2px;
  background: transparent; border: none; border-radius: 8px; color: #cbd5e1; font-size: 14px;
}
.filter:hover { background: rgba(255,255,255,.06); }
.filter.active { background: var(--primary); color: #fff; font-weight: 600; }
.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.agent-info { font-size: 13px; color: #cbd5e1; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-ghost { width: 100%; padding: 7px; background: transparent; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; color: #cbd5e1; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }

/* ---------- 会话列表 ---------- */
.conv-list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.list-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.list-head span { font-weight: 600; }
#search-input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.conv-items { flex: 1; overflow-y: auto; }
.conv-item {
  padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s;
}
.conv-item:hover { background: #f8fafc; }
.conv-item.active { background: #eff6ff; }
.conv-item-top { display: flex; justify-content: space-between; align-items: center; }
.customer-name { font-weight: 600; font-size: 14px; }
.conv-time { font-size: 11px; color: var(--muted); }
.conv-subject { font-size: 13px; color: var(--text); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-last { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.badge.new { background: #fee2e2; color: var(--red); }
.badge.open { background: #dbeafe; color: var(--primary); }
.badge.pending { background: #fef3c7; color: var(--amber); }
.badge.resolved { background: #dcfce7; color: var(--green); }
.tag-pill { font-size: 11px; background: #f1f5f9; color: #475569; padding: 2px 8px; border-radius: 999px; }
.list-empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------- 会话详情 ---------- */
.conv-detail { background: var(--bg); display: flex; flex-direction: column; }
.detail-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.detail-empty-icon { font-size: 44px; margin-bottom: 10px; }
.detail-head {
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.detail-title { font-weight: 700; font-size: 16px; }
.detail-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.resolve { background: var(--green); border-color: var(--green); color: #fff; }
.btn.resolve:hover { opacity: .9; color: #fff; }
.btn.reopen { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.reopen:hover { opacity: .9; color: #fff; }
.btn.assign { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.assign:hover { opacity: .9; color: #fff; }
.btn.small { padding: 4px 8px; font-size: 12px; }

.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; padding: 10px 14px; border-radius: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg .msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg.customer { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.agent { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.agent .msg-meta { color: rgba(255,255,255,.75); }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 12px; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag-select { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 10px; }
.tag-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.tag-chip.on { background: #eff6ff; border-color: var(--primary); color: var(--primary); }
.reply-bar { padding: 12px 20px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 10px; }
#reply-input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; resize: none; outline: none; font-family: inherit; min-height: 42px;
}
#reply-input:focus { border-color: var(--primary); }
#send-btn { padding: 10px 20px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-weight: 600; }
#send-btn:hover { background: var(--primary-dark); }

@media (max-width: 900px) {
  .app { grid-template-columns: 160px 1fr; }
  .conv-list { display: none; }
  .conv-list.show { display: flex; grid-column: 1 / -1; }
}
