/* 订单会话消息（打手端 / 商家端） */
.chat-wrap { padding: 0; overflow: hidden; }
.chat-list { display: flex; flex-direction: column; }
.chat-empty {
  padding: 48px 24px; text-align: center; color: var(--dim, #8a8f98);
  font-size: 14px; line-height: 1.9;
}
.chat-empty span { font-size: 12px; color: var(--mute, #a8adb5); }

.chat-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; background: none; border: 0; border-bottom: 1px solid var(--line, #eef0f3);
  text-align: left; cursor: pointer; color: inherit; font: inherit;
}
.chat-item:last-child { border-bottom: 0; }
.chat-item:active { background: var(--elev-2, rgba(0,0,0,.04)); }

.chat-av { position: relative; flex: 0 0 auto; width: 44px; height: 44px; }
.chat-av img, .chat-av-ph {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; display: block;
}
.chat-av-ph {
  display: flex; align-items: center; justify-content: center;
  background: var(--brand, #2fa36b); color: #fff; font-size: 18px; font-weight: 700;
}
.chat-dot {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; font-style: normal;
  line-height: 18px; text-align: center; font-weight: 700;
}

.chat-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-info b { font-size: 15px; font-weight: 600; }
.chat-last {
  font-size: 13px; color: var(--dim, #8a8f98);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-meta {
  font-size: 11px; color: var(--mute, #a8adb5);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-time { flex: 0 0 auto; font-size: 11px; color: var(--mute, #a8adb5); align-self: flex-start; margin-top: 3px; }

/* 聊天窗 */
.chat-room {
  display: flex; flex-direction: column;
  height: calc(100vh - 200px); min-height: 320px;
  position: relative; overflow: hidden;
}
@supports (height: 100dvh) { .chat-room { height: calc(100dvh - 200px - env(safe-area-inset-bottom, 0px)); } }
.chat-room.hidden { display: none; }
/* 关键修复：聊天窗显示时脱离文档流，直接吸附在顶栏底边与底部导航顶边之间。
   不再依赖“算高度”，因此不会再出现输入框与导航之间的整段空白。 */
.chat-room:not(.hidden) {
  position: fixed; left: 0; right: 0;
  top: var(--chat-top, 66px);
  bottom: var(--chat-bottom, 64px);
  height: auto; min-height: 0;
  z-index: 45;
  background: var(--surface, #fff);
}
/* 聊天窗打开时隐藏页脚，避免残留占位 */
body.chat-open .foot-note { display: none; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line, #eef0f3); flex: 0 0 auto;
  position: relative; z-index: 3; background: var(--surface, #fff);
}
.chat-head-txt { min-width: 0; display: flex; flex-direction: column; }
.chat-head-txt b { font-size: 15px; }
.chat-head-txt span {
  font-size: 11px; color: var(--mute, #a8adb5);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.chat-msgs {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  position: relative; z-index: 0;
}
.chat-tip { text-align: center; font-size: 11px; color: var(--mute, #a8adb5); }
.chat-bubble-row { display: flex; gap: 8px; align-items: flex-end; flex: 0 0 auto; width: 100%; max-width: 100%; box-sizing: border-box; }
.chat-bubble-row.mine { flex-direction: row-reverse; }
/* 关键修复：内层包裹块必须显式限宽，否则 max-width 百分比会退化为按内容收缩的最小宽度 */
.chat-bubble-row > div {
  flex: 0 1 auto; min-width: 0; max-width: 78%;
  display: flex; flex-direction: column; align-items: flex-start;
}
.chat-bubble-row.mine > div { align-items: flex-end; }
.chat-bubble {
  max-width: 100%; padding: 8px 12px; border-radius: 12px; font-size: 14px; line-height: 1.55;
  background: var(--elev-2, #f2f4f7); color: var(--text, #1f2329);
  word-break: break-word; white-space: pre-wrap;
  box-sizing: border-box; text-align: left;
}
.chat-bubble-row.mine .chat-bubble { background: var(--brand, #2fa36b); color: #fff; }
.chat-bubble img { display: block; max-width: 100%; border-radius: 8px; }
.chat-bubble-time { font-size: 10px; line-height: 1.4; color: var(--mute, #a8adb5); margin-top: 4px; white-space: nowrap; }

.chat-input {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line, #eef0f3);
  position: relative; z-index: 3; background: var(--surface, #fff);
}
.chat-input input[type="text"] {
  flex: 1 1 auto; min-width: 0; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line, #e6e8eb); background: var(--surface, #fff);
  color: var(--text, #1f2329); font-size: 14px;
}
.chat-img {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line, #e6e8eb); background: var(--surface, #fff);
  font-size: 18px; line-height: 1; cursor: pointer;
}
