/* ========== 仿微信通用样式 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --wx-bg: #EDEDED;          /* 聊天背景 */
  --wx-nav: #EDEDED;         /* 导航栏 */
  --wx-green: #95EC69;       /* 微信绿气泡 */
  --wx-green-deep: #07C160;  /* 微信主绿 */
  --wx-white: #FFFFFF;
  --wx-red: #FA5151;
  --wx-orange: #FA9D3B;
  --wx-text: #191919;
  --wx-gray: #B2B2B2;
  --wx-line: #DCDCDC;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px; color: var(--wx-text); background: #F7F7F7;
  user-select: none;
}

/* ---------- 顶部导航栏（微信经典） ---------- */
.wx-navbar {
  position: sticky; top: 0; z-index: 100;
  height: 48px; background: var(--wx-nav);
  display: flex; align-items: center; padding: 0 12px;
  border-bottom: 1px solid var(--wx-line);
}
.wx-navbar .nav-title { flex: 1; text-align: center; font-size: 17px; font-weight: 500; }
.nav-btn {
  min-width: 60px; height: 32px; padding: 0 8px; border: none; background: transparent;
  font-size: 14px; color: var(--wx-green-deep); cursor: pointer; border-radius: 4px;
}
.nav-btn.danger { color: var(--wx-red); }
.nav-btn:active { background: rgba(0,0,0,.06); }

/* ---------- 聊天窗口 ---------- */
.chat-page { display: flex; flex-direction: column; height: 100vh; background: var(--wx-bg); }
.msg-list { flex: 1; overflow-y: auto; padding: 12px 12px 20px; -webkit-overflow-scrolling: touch; }
.msg-row { display: flex; margin-bottom: 16px; align-items: flex-start; }
.msg-row.self { flex-direction: row-reverse; }
.avatar {
  width: 40px; height: 40px; border-radius: 5px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; font-weight: 500;
}
.avatar.customer { background: #5B8FF9; }
.avatar.admin { background: var(--wx-green-deep); }
.bubble-wrap { max-width: 62%; margin: 0 10px; display: flex; flex-direction: column; }
.msg-row.self .bubble-wrap { align-items: flex-end; }
.bubble {
  position: relative; padding: 9px 13px; border-radius: 6px;
  font-size: 16px; line-height: 1.45; word-break: break-word; user-select: text;
  max-width: 100%;
}
.bubble.white { background: var(--wx-white); float: left; }
.bubble.green { background: var(--wx-green); float: right; }
.msg-row:not(.self) .bubble::before { /* 左侧小三角 */
  content: ''; position: absolute; left: -5px; top: 12px;
  border: 5px solid transparent; border-right-color: var(--wx-white); border-left: 0;
}
.msg-row.self .bubble::after { /* 右侧小三角 */
  content: ''; position: absolute; right: -5px; top: 12px;
  border: 5px solid transparent; border-left-color: var(--wx-green); border-right: 0;
}
.msg-time-divider { text-align: center; color: #B2B2B2; font-size: 12px; margin: 8px 0 16px; }
.msg-time-divider span { background: rgba(0,0,0,.06); padding: 3px 8px; border-radius: 3px; }

/* ---------- 底部输入栏 ---------- */
.input-bar {
  display: flex; align-items: center; gap: 8px;
  background: #F7F7F7; border-top: 1px solid var(--wx-line); padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}
.input-bar input {
  flex: 1; height: 36px; border: none; outline: none; border-radius: 5px;
  background: #fff; padding: 0 12px; font-size: 16px; color: var(--wx-text);
}
.send-btn {
  height: 34px; padding: 0 16px; border: none; border-radius: 5px;
  background: var(--wx-green-deep); color: #fff; font-size: 15px; cursor: pointer;
}
.send-btn:disabled { background: #C8C8C8; }

/* ---------- 清空弹窗（微信 Dialog 风格） ---------- */
.wx-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999;
  display: none; align-items: center; justify-content: center;
}
.wx-mask.show { display: flex; }
.wx-dialog {
  width: 300px; background: #fff; border-radius: 12px; overflow: hidden;
  animation: dialogIn .18s ease-out;
}
@keyframes dialogIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.wx-dialog .dlg-title { text-align: center; font-size: 16px; font-weight: 600; padding: 24px 24px 8px; }
.wx-dialog .dlg-body { text-align: center; font-size: 14px; color: #888; padding: 0 24px 20px; line-height: 1.6; }
.wx-dialog .dlg-btns { display: flex; border-top: 1px solid var(--wx-line); }
.wx-dialog .dlg-btns button {
  flex: 1; height: 46px; border: none; background: #fff; font-size: 16px; cursor: pointer;
}
.wx-dialog .dlg-btns button + button { border-left: 1px solid var(--wx-line); }
.wx-dialog .dlg-btns .primary { color: var(--wx-green-deep); font-weight: 500; }
.wx-dialog .dlg-btns .danger { color: var(--wx-red); }

/* ---------- Toast ---------- */
.wx-toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.75); color: #fff; font-size: 14px;
  padding: 12px 22px; border-radius: 8px; z-index: 1000; display: none; max-width: 70%;
  text-align: center; line-height: 1.5;
}

/* ---------- 会话列表（后台左栏 / 客户列表页通用） ---------- */
.session-list { overflow-y: auto; background: #fff; }
.session-item {
  display: flex; align-items: center; padding: 12px 12px; gap: 10px;
  border-bottom: .5px solid #E7E7E7; cursor: pointer; position: relative;
  transition: transform .18s ease; touch-action: pan-y;
}
.session-item.active { background: #E5E5E5; }
.session-item .s-avatar {
  width: 44px; height: 44px; border-radius: 5px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; font-weight: 500; background: #5B8FF9;
}
.s-main { flex: 1; min-width: 0; }
.s-line1 { display: flex; align-items: center; }
.s-name { flex: 1; font-size: 16px; color: var(--wx-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-time { font-size: 12px; color: var(--wx-gray); flex-shrink: 0; margin-left: 8px; }
.s-line2 { display: flex; align-items: center; margin-top: 3px; }
.s-preview { flex: 1; font-size: 13px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--wx-red); color: #fff; font-size: 11px; line-height: 18px;
  text-align: center; flex-shrink: 0;
}
.dot-online {
  width: 8px; height: 8px; border-radius: 50%; background: var(--wx-green-deep);
  flex-shrink: 0; margin-right: 4px;
}
.dot-offline { background: #C8C8C8; }
.swipe-clear-btn {
  position: absolute; right: 0; top: 0; bottom: 0; width: 78px;
  background: var(--wx-red); color: #fff; border: none; font-size: 14px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: #C9C9C9; border-radius: 2px; }
