/* ===== 12315维权客服 - 微信风格样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: #f2f2f7; color: #111; font-size: 16px;
  user-select: none; -webkit-user-select: none;
}
#app { height: 100%; max-width: 520px; margin: 0 auto; position: relative; background: #f2f2f7; box-shadow: 0 0 20px rgba(0,0,0,.08); }

/* ---------- 视图切换 ---------- */
.view { position: absolute; inset: 0; display: none; flex-direction: column; background: #f2f2f7; }
.view.active { display: flex; }
.view-slide { z-index: 10; }

/* ---------- 导航栏 ---------- */
.navbar {
  height: calc(52px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px);
  background: #f7f7f8; border-bottom: .5px solid #d9d9de;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; flex-shrink: 0;
}
.navbar-title { position: absolute; left: 60px; right: 60px; text-align: center; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navbar-back { padding: 0 12px; height: 52px; display: flex; align-items: center; color: #111; cursor: pointer; position: relative; z-index: 2; }
.navbar-back:active { opacity: .4; }
.navbar-right { width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; color: #111; cursor: pointer; position: relative; z-index: 2; }
.navbar-right:active { opacity: .4; }

/* ---------- 登录 ---------- */
#view-login { background: #07C160 url('../assets/login-bg.webp') center/cover no-repeat; }
#view-login::before { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(14,196,106,.82) 0%, rgba(7,193,96,.78) 45%, rgba(5,144,72,.86) 100%); pointer-events: none; }
.login-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; position: relative; z-index: 1; }
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo h1 { color: #fff; font-size: 20px; letter-spacing: 1px; margin-top: 12px; line-height: 1.5; text-align: center; }
.login-logo p { color: rgba(255,255,255,.85); font-size: 14px; margin-top: 6px; letter-spacing: 2px; }
.login-form { width: 100%; max-width: 340px; }
.field { background: rgba(255,255,255,.96); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.field input { width: 100%; border: none; outline: none; padding: 15px 16px; font-size: 16px; background: transparent; }
.login-error { color: #ffe1e1; font-size: 13px; min-height: 20px; margin-bottom: 8px; text-align: center; }
.btn-primary {
  width: 100%; border: none; border-radius: 10px; padding: 15px;
  background: #fff; color: #07C160; font-size: 17px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { opacity: .5; }
.login-switch { text-align: center; margin-top: 18px; color: rgba(255,255,255,.9); font-size: 14px; }
.login-switch span { text-decoration: underline; cursor: pointer; margin-left: 4px; }
.login-server { position: absolute; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); color: rgba(255,255,255,.8); font-size: 12px; }
.login-server .link { text-decoration: underline; cursor: pointer; margin-left: 6px; }

/* ---------- 页面容器 ---------- */
.page-container { flex: 1; position: relative; overflow: hidden; }
.page { position: absolute; inset: 0; display: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page.active { display: block; }

.conn-banner { background: #ffe9a8; color: #7a5c00; text-align: center; font-size: 13px; padding: 6px 0; position: sticky; top: 0; z-index: 5; }

/* ---------- 会话列表 ---------- */
.conv-item { display: flex; align-items: center; padding: 12px 14px; background: #fff; cursor: pointer; }
.conv-item:active { background: #ececf1; }
.conv-item + .conv-item { border-top: .5px solid #f0f0f4; }
.conv-body { flex: 1; min-width: 0; margin-left: 12px; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; }
.conv-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 12px; color: #b2b2b8; margin-left: 8px; flex-shrink: 0; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; }
.conv-last { font-size: 14px; color: #8a8a90; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-tip { text-align: center; color: #b2b2b8; font-size: 14px; padding: 60px 0; display: none; }

.badge { min-width: 18px; height: 18px; border-radius: 9px; background: #fa5151; color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; padding: 0 5px; flex-shrink: 0; }
.conv-badge { margin-left: 8px; }

/* ---------- 头像 ---------- */
.avatar { width: 46px; height: 46px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 19px; font-weight: 600; flex-shrink: 0; position: relative; }
.avatar-lg { width: 62px; height: 62px; font-size: 26px; border-radius: 10px; }
.avatar-sm { width: 40px; height: 40px; font-size: 16px; border-radius: 6px; }
.online-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: #09BB07; border: 2px solid #fff; }

/* ---------- 通讯录 ---------- */
.contact-item { display: flex; align-items: center; padding: 10px 14px; background: #fff; cursor: pointer; }
.contact-item:active { background: #ececf1; }
.contact-item + .contact-item { border-top: .5px solid #f0f0f4; }
.contact-name { margin-left: 12px; font-size: 16px; }
.contact-status { margin-left: auto; font-size: 12px; color: #b2b2b8; }
.contact-status.online { color: #09BB07; }

/* ---------- 我 ---------- */
.me-header { display: flex; align-items: center; background: #fff; padding: 22px 16px; margin-bottom: 10px; }
.me-info { margin-left: 14px; min-width: 0; }
.me-nickname { font-size: 20px; font-weight: 600; }
.me-username { font-size: 13px; color: #8a8a90; margin-top: 4px; }
.me-signature { font-size: 13px; color: #8a8a90; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.cell-group { background: #fff; margin-bottom: 10px; }
.cell { display: flex; align-items: center; padding: 14px 16px; cursor: pointer; }
.cell:active { background: #ececf1; }
.cell + .cell { border-top: .5px solid #f0f0f4; }
.cell-icon { font-size: 18px; margin-right: 12px; }
.cell-label { font-size: 16px; }
.cell-value { margin-left: auto; font-size: 13px; color: #8a8a90; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-arrow { color: #c7c7cc; font-size: 20px; margin-left: auto; }
.cell-value + .cell-arrow { margin-left: 6px; }
.cell-danger .cell-label { color: #fa5151; }

/* ---------- 底部 Tab ---------- */
.tabbar {
  height: calc(56px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #f7f7f8; border-top: .5px solid #d9d9de;
  display: flex; flex-shrink: 0;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #8a8a90; cursor: pointer; position: relative; gap: 2px; }
.tab span { font-size: 11px; }
.tab.active { color: #07C160; }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 8px); }

/* ---------- 聊天页 ---------- */
.navbar-chat .navbar-title small { display: block; font-size: 11px; color: #8a8a90; font-weight: 400; }
.notify-tip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff8e1; color: #8a6d3b; font-size: 13px; border-bottom: 1px solid #f0e0b8; }
.notify-tip .nt-text { flex: 1; line-height: 1.4; }
.notify-tip button { border: none; background: #07c160; color: #fff; border-radius: 4px; padding: 4px 12px; font-size: 13px; flex-shrink: 0; }
.notify-tip .nt-close { padding: 0 2px; cursor: pointer; color: #b0a080; font-size: 18px; line-height: 1; flex-shrink: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px 12px; background: #ededf0; -webkit-overflow-scrolling: touch; }
.msg-row { display: flex; margin-bottom: 16px; align-items: flex-start; }
.msg-row.mine { flex-direction: row-reverse; }
.msg-row > *:first-child { flex-shrink: 0; }
.msg-bubble {
  max-width: 100%; padding: 10px 12px; border-radius: 6px; font-size: 16px; line-height: 1.45;
  background: #fff; position: relative; word-break: break-word; white-space: pre-wrap;
  user-select: text; -webkit-user-select: text;
  writing-mode: horizontal-tb; text-orientation: mixed; direction: ltr;
  text-align: left; -webkit-text-orientation: mixed;
  display: block; box-sizing: border-box;
}
.msg-row.mine .msg-bubble { background: #95ec69; }
.msg-bubble::before { content: ''; position: absolute; top: 12px; border: 6px solid transparent; }
.msg-row:not(.mine) .msg-bubble::before { left: -11px; border-right-color: #fff; }
.msg-row.mine .msg-bubble::before { right: -11px; border-left-color: #95ec69; }
.msg-avatar { margin: 0 10px; }
.msg-time { text-align: center; font-size: 12px; color: #a8a8ae; margin: 10px 0; }
.msg-status { font-size: 11px; color: #a8a8ae; margin-top: 4px; text-align: right; }

.chat-input-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  background: #f7f7f8; border-top: .5px solid #d9d9de; flex-shrink: 0;
  box-sizing: border-box; width: 100%; overflow: hidden;
}
.chat-input-bar input {
  /* min-width:0 + width:0 让输入框真正被 flex:1 压缩，否则手机窄屏会把发送按钮挤出屏幕 */
  flex: 1 1 0%; min-width: 0; width: 0;
  border: none; outline: none; border-radius: 6px; padding: 10px 10px; font-size: 16px; background: #fff;
  box-sizing: border-box;
}
.chat-input-bar button {
  border: none; border-radius: 6px; padding: 10px 14px; font-size: 15px;
  background: #07C160; color: #fff; cursor: pointer; flex-shrink: 0; box-sizing: border-box;
}
.chat-input-bar button:disabled { background: #b5e8c9; }
.btn-img { display: flex; align-items: center; padding: 4px; cursor: pointer; flex-shrink: 0; }
.btn-img:active { opacity: .5; }
.btn-icon { display: flex; align-items: center; padding: 4px; cursor: pointer; flex-shrink: 0; }
.btn-icon:active { opacity: .5; }
.btn-icon.active svg { stroke: #07C160; }
#btn-talk { flex: 1 1 0%; min-width: 0; border: none; outline: none; border-radius: 6px; padding: 10px 12px; font-size: 16px; background: #fff; color: #333; cursor: pointer; }
#btn-talk.recording { background: #d9d9de; }
/* 超窄屏（≤360px）进一步压缩图标间距，确保发送按钮始终可见 */
@media (max-width: 360px) {
  .chat-input-bar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .btn-icon, .btn-img { padding: 2px; }
  .chat-input-bar button { padding: 10px 10px; font-size: 14px; }
}
.msg-bubble.img-bubble { padding: 4px; background: transparent; }
.msg-bubble.img-bubble::before { display: none; }
.msg-bubble.img-bubble img { display: block; max-width: 200px; max-height: 240px; border-radius: 6px; cursor: pointer; }
#img-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 300; display: flex; align-items: center; justify-content: center; }
#img-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- 表情面板 ---------- */
.emoji-panel { grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px)); background: #f7f7f8; border-top: .5px solid #d9d9de; max-height: 216px; overflow-y: auto; flex-shrink: 0; }
.emoji-panel[style*="grid"] { display: grid; }
.emoji-item { font-size: 24px; text-align: center; padding: 5px 0; cursor: pointer; border-radius: 6px; line-height: 1.3; }
.emoji-item:active { background: #e0e0e6; }

/* ---------- 语音气泡 ---------- */
.voice-bubble { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.msg-row.mine .voice-bubble { flex-direction: row-reverse; }
.voice-bubble .voice-ico { font-size: 15px; }
.voice-bubble .voice-dur { font-size: 15px; }
.voice-bubble.playing .voice-ico { animation: voicepulse .8s infinite; }
@keyframes voicepulse { 50% { opacity: .25; } }
.msg-sender { font-size: 12px; color: #a8a8ae; margin: 0 0 2px 2px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; writing-mode: horizontal-tb; }

/* ---------- 录音提示 ---------- */
#voice-hint { position: fixed; inset: 0; z-index: 250; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#voice-hint .vh-box { background: rgba(0,0,0,.65); color: #fff; border-radius: 12px; padding: 22px 28px; text-align: center; font-size: 13px; }
#voice-hint .vh-mic { font-size: 42px; margin-bottom: 8px; }

/* ---------- 发起群聊 ---------- */
.group-member-list { max-height: 220px; overflow-y: auto; margin: 2px 0 10px; border: 1px solid #eee; border-radius: 8px; }
.group-member { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 15px; cursor: pointer; }
.group-member + .group-member { border-top: .5px solid #f0f0f4; }
.group-member input { width: auto !important; margin: 0 !important; padding: 0 !important; border: none !important; }

/* ---------- 联系人详情 ---------- */
.contact-detail { flex: 1; overflow-y: auto; }
.cd-header { background: #fff; padding: 24px 16px; display: flex; align-items: center; margin-bottom: 10px; }
.cd-info { margin-left: 14px; }
.cd-nickname { font-size: 20px; font-weight: 600; }
.cd-username { font-size: 13px; color: #8a8a90; margin-top: 4px; }
.cd-signature { background: #fff; padding: 14px 16px; font-size: 14px; color: #666; margin-bottom: 10px; }
.cd-signature .label { color: #b2b2b8; font-size: 12px; display: block; margin-bottom: 4px; }
.cd-action { display: block; width: calc(100% - 32px); margin: 10px auto; border: none; border-radius: 10px; padding: 14px; background: #07C160; color: #fff; font-size: 16px; cursor: pointer; }
.cd-action:active { opacity: .85; }
.cd-action.cd-danger { background: #fa5151; }

/* ---------- 弹层 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; width: 82%; max-width: 320px; padding: 20px; }
.modal h3 { font-size: 16px; margin-bottom: 14px; text-align: center; }
.modal input { width: 100%; border: 1px solid #e0e0e5; border-radius: 8px; padding: 11px 12px; font-size: 15px; outline: none; margin-bottom: 10px; }
.modal input:focus { border-color: #07C160; }
.modal .modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal .modal-btns button { flex: 1; border: none; border-radius: 8px; padding: 11px; font-size: 15px; cursor: pointer; }
.modal .btn-cancel { background: #f0f0f4; color: #333; }
.modal .btn-ok { background: #07C160; color: #fff; }
.modal .btn-ok.btn-danger { background: #fa5151; }
.modal .modal-tip { font-size: 13px; color: #8a8a90; text-align: center; line-height: 1.6; }

/* toast */
.toast { position: fixed; left: 50%; top: 45%; transform: translate(-50%,-50%); background: rgba(0,0,0,.72); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 200; }

/* ===== 好友弹窗样式 ===== */
.friend-modal { width: 340px; max-height: 70vh; }
.friend-modal .friend-title { font-size: 17px; font-weight: 600; margin-bottom: 14px; text-align: center; color: #222; }
.friend-search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.friend-search-row input { flex: 1; padding: 10px 12px; border: 1px solid #e5e5ea; border-radius: 8px; font-size: 15px; outline: none; }
.friend-search-row input:focus { border-color: #07C160; }
.friend-search-row button { padding: 0 16px; background: #07C160; color: #fff; border: none; border-radius: 8px; font-size: 14px; cursor: pointer; }
.friend-results { max-height: 360px; overflow-y: auto; }
.friend-empty { text-align: center; padding: 20px 10px; color: #8a8a90; font-size: 14px; line-height: 1.7; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-radius: 10px; cursor: pointer; margin-bottom: 6px; transition: background .15s; }
.friend-row:hover { background: #f5f5f7; }
.friend-row.selected { background: #e8f5e9; }
.friend-row .avatar { width: 42px; height: 42px; border-radius: 6px; color: #fff; font-size: 18px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-size: 15px; color: #222; font-weight: 500; }
.friend-sub { color: #8a8a90; font-size: 13px; font-weight: normal; }
.friend-sig { font-size: 12px; color: #8a8a90; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-actions { display: flex; gap: 6px; flex-shrink: 0; }
.friend-actions button { padding: 6px 12px; border-radius: 6px; border: none; font-size: 13px; cursor: pointer; }
.friend-actions .btn-primary { background: #07C160; color: #fff; }
.friend-actions .btn-secondary { background: #f0f0f4; color: #666; }
.friend-request-btn { margin-top: 14px; width: 100%; }

/* 联系人详情页 - 好友状态徽章 */
.contact-status-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; margin-left: 8px; }
.contact-status-badge.friend { background: #e8f5e9; color: #07C160; }
.contact-status-badge.pending-out { background: #fff3e0; color: #e67e22; }
.contact-status-badge.pending-in { background: #fff3e0; color: #e67e22; }
.contact-status-badge.not-friend { background: #f0f0f4; color: #8a8a90; }

/* ============ 音视频通话 ============ */
.navbar-call .btn-icon { margin-left: 6px; }
#call-overlay {
  position: fixed; inset: 0; z-index: 9999; display: none;
  flex-direction: column; align-items: center; justify-content: space-between;
  background: #2b2b33; color: #fff; padding: 60px 20px 48px;
}
#call-video-layer { position: absolute; inset: 0; }
#call-remote-video { width: 100%; height: 100%; object-fit: cover; background: #000; }
#call-local-video {
  position: absolute; right: 16px; top: 70px; width: 110px; height: 150px;
  object-fit: cover; border-radius: 10px; background: #000; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
#call-voice-layer {
  position: relative; z-index: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center; flex: 1; width: 100%;
}
#call-voice-layer .call-avatar { margin-bottom: 20px; }
#call-voice-layer .call-avatar .avatar {
  width: 110px; height: 110px; border-radius: 50%; font-size: 44px;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.call-name { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
#call-voice-layer .call-name { position: relative; z-index: 2; }
.call-status { font-size: 15px; color: rgba(255,255,255,.72); }
.call-actions {
  position: relative; z-index: 2; display: none; gap: 42px;
  justify-content: center; width: 100%; margin-top: auto; padding-bottom: 10px;
}
.call-act-item { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.8); }
.call-btn {
  width: 62px; height: 62px; border-radius: 50%; border: none; font-size: 24px;
  background: rgba(255,255,255,.22); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.call-btn:active { opacity: .8; }
#call-overlay.min-off {
  inset: auto; left: -9999px; top: 0; width: 2px; height: 2px;
  padding: 0; overflow: hidden;
}
.call-btn.call-danger { background: #fa5151; }
.call-btn.call-ok { background: #07C160; }
.call-btn.call-muted { background: #e6a23c; }
#call-video-layer + #call-voice-layer + #call-incoming-actions,
#call-video-layer + #call-voice-layer + #call-ongoing-actions { margin-top: 0; }

/* 通话悬浮窗 */
#call-float {
  position: fixed; right: 12px; top: 90px; z-index: 9998;
  display: flex; align-items: center; gap: 8px;
  background: rgba(43,43,51,.92); color: #fff;
  border-radius: 28px; padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  touch-action: none; user-select: none;
}
#call-float .cf-main { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#call-float .cf-avatar .avatar {
  width: 36px; height: 36px; border-radius: 50%; font-size: 15px;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
#call-float .cf-name { font-size: 13px; font-weight: 600; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#call-float .cf-status { font-size: 11px; color: #07C160; }
#call-float .cf-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; font-size: 14px;
  background: rgba(255,255,255,.22); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#call-float .cf-btn.cf-danger { background: #fa5151; }
#call-float .cf-btn.cf-muted { background: #e6a23c; }
