/* ==========================================================================
   客服消息模块 · 样式（配合 h5-chat.js，嵌入 #page-message）
   所有类名统一 kf- 前缀，避免污染宿主 H5 的样式
   ========================================================================== */

/* ---------- 会话列表（占据 #page-message 的正文区） ---------- */
#kf-conv-list { background: #fff; min-height: 240px; }

.kf-conv {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 15px; border-bottom: 1px solid #f4f4f4;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.kf-conv:active { background: #f7f7f7; }
.kf-conv-av { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #eef1f6; flex: none; }
.kf-conv-main { flex: 1; min-width: 0; }
.kf-conv-r1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kf-conv-name {
  font-size: 15px; font-weight: 600; color: #222;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.kf-conv-time { font-size: 11px; color: #bbb; flex: none; }
.kf-conv-r2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.kf-conv-last {
  font-size: 13px; color: #999; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.kf-conv-unread {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ff3b30; color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.kf-tag-group {
  flex: none; font-size: 10px; line-height: 16px; padding: 0 4px; border-radius: 3px;
  background: #eef3ff; color: #2f7bff;
}

/* 官方金色徽章：客服名字旁 */
.kf-badge {
  display: inline-block; flex: none; padding: 0 5px; border-radius: 3px;
  background: linear-gradient(135deg, #f7d56a, #d4a017);
  color: #5a3b00; font-size: 11px; font-weight: 600; line-height: 16px;
  vertical-align: 1px;
}

.kf-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 90px 0 40px; }
.kf-empty i { font-size: 64px; color: #e2e5ea; margin-bottom: 16px; }
.kf-empty p { font-size: 14px; color: #aaa; }

.kf-list-loading { text-align: center; font-size: 13px; color: #bbb; padding: 40px 0; }

/* ---------- 会话窗口（全屏覆盖，压住底部导航） ---------- */
#kf-room {
  position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 300;
  display: none; flex-direction: column;
  background: #f2f3f5; overflow: hidden;
}
#kf-room.on { display: flex; }

.kf-room-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #fff; border-bottom: 1px solid #eee;
  padding-top: calc(8px + env(safe-area-inset-top));
}
.kf-back {
  width: 32px; height: 32px; flex: none; border: 0; background: none;
  font-size: 18px; color: #333; cursor: pointer; padding: 0;
}
.kf-room-who { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.kf-room-av { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #eef1f6; flex: none; }
.kf-room-tx { min-width: 0; }
.kf-room-name {
  font-size: 15px; font-weight: 600; color: #222; line-height: 1.25;
  display: flex; align-items: center; gap: 5px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.kf-room-sub { font-size: 11px; color: #999; line-height: 1.3; }

/* 订单进度条 */
.kf-order { flex: none; background: #fff; border-bottom: 1px solid #eee; padding: 8px 12px 10px; }
.kf-order-title {
  font-size: 12px; color: #666; margin-bottom: 8px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.kf-order-title b { color: #e06436; }
.kf-steps { display: flex; }
.kf-step {
  flex: 1; text-align: center; font-size: 11px; color: #aaa; position: relative; padding-top: 18px;
}
.kf-step::before {
  content: ""; position: absolute; top: 0; left: 50%; margin-left: -7px;
  width: 14px; height: 14px; border-radius: 50%; background: #e2e2e2; z-index: 1;
}
.kf-step::after {
  content: ""; position: absolute; top: 6px; left: -50%; width: 100%; height: 2px; background: #e2e2e2;
}
.kf-step:first-child::after { display: none; }
.kf-step.done { color: #b87b4d; }
.kf-step.done::before, .kf-step.done::after { background: #d79e71; }
.kf-step.cur { color: #e06436; font-weight: 600; }
.kf-step.cur::before { background: #e06436; box-shadow: 0 0 0 3px rgba(224, 100, 54, .22); }
.kf-step.cur::after { background: #d79e71; }

/* 消息区 */
.kf-msgs { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px; -webkit-overflow-scrolling: touch; }
.kf-more {
  display: none; margin: 0 auto 10px; background: none; border: 0;
  color: #999; font-size: 12px; cursor: pointer; padding: 4px 10px;
}
.kf-row { display: flex; gap: 8px; margin-bottom: 14px; }
.kf-row.me { flex-direction: row-reverse; }
.kf-av { flex: none; width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #e6e9ef; }
.kf-bd { max-width: 72%; display: flex; flex-direction: column; align-items: flex-start; }
.kf-row.me .kf-bd { align-items: flex-end; }
.kf-nm { font-size: 11px; color: #999; margin-bottom: 3px; display: flex; align-items: center; gap: 4px; }
.kf-bub {
  padding: 9px 12px; border-radius: 10px; background: #fff; color: #222;
  font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.kf-row.me .kf-bub { background: #ffe7e7; }
.kf-img {
  max-width: 168px; max-height: 220px; border-radius: 8px; cursor: zoom-in;
  background: #eef1f6; min-width: 64px; min-height: 64px; display: block;
}
.kf-vid {
  width: 176px; height: 108px; border-radius: 8px; background: #23262b; color: #fff;
  border: 0; cursor: pointer; font-size: 13px;
}
.kf-vid-on { max-width: 240px; border-radius: 8px; display: block; background: #000; }
.kf-card {
  display: flex; gap: 10px; width: 244px; padding: 9px; background: #fff;
  border: 1px solid #ececec; border-radius: 10px; cursor: pointer;
}
.kf-card img { flex: none; width: 64px; height: 64px; border-radius: 6px; object-fit: cover; background: #eef1f6; }
.kf-card .kf-ct {
  font-size: 13px; color: #222; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all;
}
.kf-card .kf-cp { color: #ff0000; font-weight: 700; font-size: 15px; margin-top: 3px; }
.kf-card .kf-cp::before { content: ''; }
.kf-card .kf-ck { font-size: 11px; color: #999; margin-top: 2px; }
.kf-card-ph { flex: none; width: 64px; height: 64px; border-radius: 6px; background: #f0f2f5; }
.kf-meta { font-size: 11px; color: #b5b5b5; margin-top: 3px; }
.kf-rd { margin-left: 6px; color: #22a45d; }
.kf-sys {
  text-align: center; font-size: 12px; color: #999; margin: 12px 8px;
  background: rgba(0, 0, 0, .04); border-radius: 4px; padding: 4px 8px; width: fit-content;
  margin-left: auto; margin-right: auto;
}

.kf-tip {
  display: none; flex: none; text-align: center; font-size: 12px; color: #f60;
  background: #fff8f0; padding: 4px 8px;
}

/* 输入栏 */
.kf-bar {
  flex: none; display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid #eee;
}
.kf-att {
  width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%;
  background: #f2f3f5; color: #555; font-size: 15px; cursor: pointer; padding: 0;
}
.kf-input {
  flex: 1; min-height: 34px; max-height: 92px; resize: none; outline: none;
  border: 1px solid #e6e6e6; border-radius: 8px; padding: 7px 10px;
  font: inherit; font-size: 14px; line-height: 1.4; background: #fafafa;
  -webkit-appearance: none;
}
.kf-input:focus { border-color: #ffb3b3; background: #fff; }
.kf-send {
  height: 34px; flex: none; padding: 0 14px; border: 0; border-radius: 8px;
  background: #ee0000; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.kf-send:disabled { background: #f3b6b6; cursor: not-allowed; }

/* 上传进度 */
.kf-upload-mask {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center; z-index: 5;
}
.kf-upload-mask[hidden] { display: none; }
.kf-upload-box {
  width: 200px; background: #fff; border-radius: 10px; padding: 16px; text-align: center;
  font-size: 12px; color: #666;
}
.kf-upload-bar { height: 6px; border-radius: 3px; background: #eee; overflow: hidden; margin-bottom: 8px; }
.kf-upload-bar i { display: block; height: 100%; width: 0; background: #ee0000; transition: width .2s; }

/* 图片大图预览 */
#kf-viewer {
  position: fixed; inset: 0; z-index: 400; background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center;
}
#kf-viewer[hidden] { display: none; }
#kf-viewer img { max-width: 96vw; max-height: 92vh; object-fit: contain; }

/* 简易输入弹窗（改昵称等） */
#kf-prompt {
  position: fixed; inset: 0; z-index: 400; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
}
#kf-prompt[hidden] { display: none; }
.kf-prompt-box { width: 76%; max-width: 300px; background: #fff; border-radius: 12px; overflow: hidden; }
.kf-prompt-box h4 { margin: 0; padding: 18px 16px 6px; font-size: 15px; text-align: center; }
.kf-prompt-box input {
  display: block; width: calc(100% - 32px); margin: 8px 16px 16px; padding: 9px 10px;
  border: 1px solid #e6e6e6; border-radius: 8px; font: inherit; font-size: 14px; outline: none;
}
.kf-prompt-btns { display: flex; border-top: 1px solid #f0f0f0; }
.kf-prompt-btns button {
  flex: 1; padding: 13px 0; border: 0; background: #fff; font-size: 15px; cursor: pointer;
}
.kf-prompt-btns button:first-child { color: #888; border-right: 1px solid #f0f0f0; }
.kf-prompt-btns button:last-child { color: #ee0000; font-weight: 600; }

/* 底部导航未读红点（由组件动态插入 #nav-message） */
#kf-nav-dot {
  position: absolute; top: -3px; right: 22%;
  min-width: 8px; height: 8px; padding: 0 2px; border-radius: 4px;
  background: #ee0000; border: 1px solid #fff; font-size: 0; line-height: 0;
}

/* 轻提示 */
.kf-toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 70%; padding: 10px 16px; border-radius: 8px;
  background: rgba(0, 0, 0, .8); color: #fff; font-size: 13px; line-height: 1.5;
  z-index: 500; opacity: 0; transition: opacity .2s; pointer-events: none; text-align: center;
}
.kf-toast.on { opacity: 1; }
