/* ============ BOSS 聊天记录查看器 ============ */
:root {
  --bg:        #eef0f4;
  --panel:     #ffffff;
  --line:      #e6e8ec;
  --line-soft: #f0f2f5;
  --text:      #1f2329;
  --sub:       #8b9198;
  --brand:     #00bebd;
  --brand-dk:  #00a5a4;
  --in-bg:     #ffffff;
  --out-bg:    #00bebd;
  --warn:      #ff7a45;
  --radius:    12px;
  --shadow:    0 1px 3px rgba(20, 26, 33, .06), 0 8px 24px rgba(20, 26, 33, .04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须始终生效（否则会被下面的 display:flex 覆盖） */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Hiragino Sans GB", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input  { font-family: inherit; }

/* ==================== 登录 ==================== */
.login-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eafaf9 0%, #eef0f4 45%, #e9f1fb 100%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: #fff; border-radius: 18px; padding: 36px 30px 30px;
  box-shadow: 0 12px 40px rgba(20, 26, 33, .10);
  text-align: center;
}
.login-logo {
  width: 62px; height: 62px; margin: 0 auto 18px;
  border-radius: 18px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; letter-spacing: .5px;
  box-shadow: 0 8px 20px rgba(0, 190, 189, .35);
}
.login-card h1 { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.login-sub { margin: 0 0 22px; color: var(--sub); font-size: 13px; }
.login-card input {
  width: 100%; height: 46px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
  background: #fafbfc;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,190,189,.14); background:#fff; }
.login-card button {
  width: 100%; height: 46px; margin-top: 14px;
  border: 0; border-radius: 10px; background: var(--brand); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: 2px;
  transition: background .15s, transform .08s;
}
.login-card button:hover  { background: var(--brand-dk); }
.login-card button:active { transform: scale(.985); }
.login-card button:disabled { opacity: .6; cursor: default; }
.login-err { min-height: 18px; margin-top: 10px; color: #e64545; font-size: 12.5px; }

/* ==================== 布局 ==================== */
.app { display: flex; height: 100%; overflow: hidden; }

/* -------- 侧栏 -------- */
.sidebar {
  width: 372px; flex: 0 0 372px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
}
.side-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px rgba(0,190,189,.16); }
.side-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: transparent; color: var(--sub); font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--line-soft); color: var(--text); }
.icon-btn.back { display: none; font-size: 24px; }

/* 统计 */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; padding: 0 14px 12px;
}
.stat {
  background: #f7f9fa; border-radius: 10px; padding: 8px 4px;
  text-align: center; border: 1px solid #f0f2f4;
}
.stat b { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; }
.stat span { font-size: 11px; color: var(--sub); }
.stat.warn b { color: var(--warn); }

/* 搜索 */
.side-search { padding: 0 14px 10px; }
.side-search input {
  width: 100%; height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #f7f8fa; outline: none; font-size: 13.5px;
  transition: border-color .15s, background .15s;
}
.side-search input:focus { border-color: var(--brand); background: #fff; }

/* 过滤 tab */
.tabs { display: flex; gap: 4px; padding: 0 14px 10px; }
.tab {
  flex: 1; height: 30px; border: 0; border-radius: 8px;
  background: transparent; color: var(--sub); font-size: 12.5px;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--line-soft); color: var(--text); }
.tab.active { background: rgba(0,190,189,.12); color: var(--brand-dk); font-weight: 600; }

/* 会话列表 */
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; min-height: 0; }
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: #d8dce1; border-radius: 3px; }

.conv {
  display: flex; gap: 10px; padding: 11px 10px; border-radius: 10px;
  cursor: pointer; position: relative; transition: background .12s;
}
.conv:hover { background: #f6f8f9; }
.conv.active { background: rgba(0,190,189,.10); }
.conv.active::before {
  content: ''; position: absolute; left: 2px; top: 14px; bottom: 14px;
  width: 3px; border-radius: 2px; background: var(--brand);
}

.avatar {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 15px; user-select: none;
}
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 6px; }
.conv-name {
  font-weight: 600; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 9em;
}
.conv-time { margin-left: auto; font-size: 11px; color: var(--sub); flex: 0 0 auto; }
.conv-company {
  font-size: 12px; color: #5d646d; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-bottom { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.conv-preview {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge {
  flex: 0 0 auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #ff4d4f; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
.pill {
  flex: 0 0 auto; font-size: 10.5px; padding: 1px 6px; border-radius: 6px;
  background: #eef1f4; color: #6b7280;
}
.pill.pos { background: rgba(0,190,189,.12); color: var(--brand-dk); }

.side-foot {
  border-top: 1px solid var(--line-soft); padding: 9px 16px;
  font-size: 12px; color: var(--sub);
}
.switch { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--brand); width: 14px; height: 14px; }

.empty { padding: 40px 16px; text-align: center; color: var(--sub); font-size: 13px; }

/* -------- 聊天区 -------- */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

.chat-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--sub); gap: 12px;
}
.ce-icon { font-size: 48px; opacity: .35; }
.chat-empty p { margin: 0; font-size: 14px; }

.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.ch-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 40px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 15px;
}
.ch-info { flex: 1; min-width: 0; }
.ch-name { font-weight: 600; font-size: 15px; }
.ch-sub { font-size: 12px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-tools { display: flex; gap: 8px; flex: 0 0 auto; }

.ghost-btn {
  height: 30px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: #4c545d;
  font-size: 12.5px; transition: all .15s;
}
.ghost-btn:hover { border-color: var(--brand); color: var(--brand-dk); background: rgba(0,190,189,.06); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 20px 22px 28px;
  background:
    radial-gradient(circle at 12% 8%, rgba(0,190,189,.05), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(64,128,255,.05), transparent 42%),
    var(--bg);
}
.chat-body::-webkit-scrollbar { width: 8px; }
.chat-body::-webkit-scrollbar-thumb { background: #d3d8dd; border-radius: 4px; }

.load-more { text-align: center; margin-bottom: 14px; }

.day-sep { text-align: center; margin: 16px 0 14px; }
.day-sep span {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  background: rgba(31,35,41,.08); color: #6b7280; font-size: 11.5px;
}

.msg { display: flex; margin-bottom: 14px; gap: 9px; align-items: flex-start; }
.msg.out { flex-direction: row-reverse; }

.m-avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff; user-select: none;
}
.m-col { max-width: min(66%, 620px); display: flex; flex-direction: column; }
.msg.out .m-col { align-items: flex-end; }

.bubble {
  padding: 9px 13px; border-radius: 12px;
  white-space: pre-wrap; word-break: break-word;
  font-size: 14px; line-height: 1.6;
  box-shadow: 0 1px 2px rgba(20,26,33,.05);
}
.msg.in  .bubble { background: var(--in-bg);  color: var(--text);  border-top-left-radius: 3px; }
.msg.out .bubble { background: var(--out-bg); color: #fff;        border-top-right-radius: 3px; }

.meta {
  font-size: 11px; color: var(--sub); margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
}
.tag-bot {
  background: rgba(0,190,189,.13); color: var(--brand-dk);
  padding: 0 6px; border-radius: 6px; font-size: 10.5px;
}
.tag-rep { background: rgba(255,122,69,.13); color: #d4521c; padding: 0 6px; border-radius: 6px; font-size: 10.5px; }

/* 回复记录抽屉 */
.reply-drawer {
  position: absolute; top: 62px; right: 16px; width: 420px; max-width: calc(100% - 32px);
  max-height: calc(100% - 90px);
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(20,26,33,.16);
  display: flex; flex-direction: column; z-index: 20; overflow: hidden;
}
.rd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
  font-weight: 600; font-size: 13.5px;
}
.rd-body { overflow-y: auto; padding: 12px 14px; }
.rd-item {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; background: #fcfdfd;
}
.rd-line { font-size: 12.5px; margin-bottom: 5px; display: flex; gap: 6px; }
.rd-line .lb { color: var(--sub); flex: 0 0 auto; }
.rd-line .vl { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.rd-foot { font-size: 11px; color: var(--sub); margin-top: 6px; }

/* ==================== 移动端 ==================== */
@media (max-width: 860px) {
  .sidebar { width: 100%; flex: 1 1 100%; border-right: 0; }
  .chat {
    position: fixed; inset: 0; z-index: 30;
    transform: translateX(100%); transition: transform .22s ease;
    background: var(--bg);
  }
  .app.show-chat .chat { transform: translateX(0); }
  .chat-empty { display: none; }
  .icon-btn.back { display: inline-flex; }
  .reply-drawer { right: 8px; left: 8px; width: auto; }
  .m-col { max-width: 74%; }
  .chat-body { padding: 14px 12px 22px; }
  .chat-head { padding: 10px 12px; }
}
