/* yanxin:im-wx-chat-layout-hotpatch v2 — WeChat 聊天气泡/列表布局 */

/* chat-container */
.im-shell .im-msg-scroll.yx-wx-chat-container,
.im-shell .im-msg-scroll {
  flex: 1;
  min-height: 0;
  background-color: var(--wx-bg-chat, #ededed) !important;
}

.im-shell .im-msg-scroll.yx-wx-chat-container .vue-recycle-scroller,
.im-shell .im-msg-scroll .vue-recycle-scroller {
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: auto;
}

.im-shell .im-msg-scroll.yx-wx-chat-container .vue-recycle-scroller::-webkit-scrollbar,
.im-shell .im-msg-scroll .vue-recycle-scroller::-webkit-scrollbar {
  display: none;
}

.im-shell .im-dynamic-scroller .vue-recycle-scroller__item-wrapper {
  padding: 16px;
  box-sizing: border-box;
}

/* chat-scroll-area / msg-row — 左右分列：对方左、自己右（勿用 row-reverse） */
.im-shell .im-msg-row,
.im-shell .im-msg-row--wx-pc {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px !important;
  flex-direction: row;
}

.im-shell .im-msg-row:not(.self),
.im-shell .im-msg-row--wx-pc:not(.self) {
  justify-content: flex-start;
}

.im-shell .im-msg-row.self,
.im-shell .im-msg-row--wx-pc.self {
  justify-content: flex-end !important;
  flex-direction: row !important;
}

.im-shell .im-msg-row:not(.self) .im-msg-col,
.im-shell .im-msg-row--wx-pc:not(.self) .im-msg-col {
  align-items: flex-start;
}

.im-shell .im-msg-row.self .im-msg-col,
.im-shell .im-msg-row--wx-pc.self .im-msg-col {
  align-items: flex-end !important;
}

.im-shell .im-msg-row.self .im-msg-bubble-stack,
.im-shell .im-msg-row--wx-pc.self .im-msg-bubble-stack {
  align-items: flex-end !important;
}

.im-shell .message-bubble {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 100%;
}

.im-shell .message-bubble:not(.message-bubble--self) {
  flex-direction: row;
  justify-content: flex-start;
}

.im-shell .message-bubble--self {
  flex-direction: row;
  justify-content: flex-end;
}

.im-shell .im-msg-row .im-msg-col,
.im-shell .message-bubble__col {
  max-width: 65% !important;
}

/* avatar */
.im-shell .im-avatar--msg,
.im-shell .message-bubble .im-avatar--msg {
  width: 40px !important;
  height: 40px !important;
  border-radius: 6px !important;
  flex-shrink: 0;
  box-shadow: none !important;
  border: none !important;
  margin-top: 0 !important;
}

/* bubble base */
.im-shell .im-bubble.im-bubble--wx-pc,
.im-shell .message-bubble__body {
  max-width: 100%;
  padding: 10px 12px !important;
  font-size: 15px !important;
  line-height: 1.5 !important;
  word-break: break-word;
  position: relative;
}

/* 对方气泡 */
.im-shell .im-msg-row:not(.self) .im-bubble.im-bubble--wx-pc.im-bubble--peer,
.im-shell .message-bubble--peer .message-bubble__body {
  background-color: var(--wx-card, #ffffff) !important;
  color: var(--wx-text-primary, #111111) !important;
  border: none !important;
  border-top-left-radius: 2px !important;
  border-top-right-radius: 6px !important;
  border-bottom-left-radius: 6px !important;
  border-bottom-right-radius: 6px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* 自己气泡 */
.im-shell .im-msg-row.self .im-bubble.im-bubble--wx-pc.im-bubble--self-wx,
.im-shell .message-bubble--self .message-bubble__body {
  background: var(--wx-bubble-green, #95ec69) !important;
  background-image: none !important;
  color: #000 !important;
  border: none !important;
  border-top-left-radius: 6px !important;
  border-top-right-radius: 2px !important;
  border-bottom-left-radius: 6px !important;
  border-bottom-right-radius: 6px !important;
  box-shadow: none !important;
}

.im-shell .im-msg-row.self .im-bubble--self-wx .im-bubble-text,
.im-shell .im-msg-row.self .im-bubble--self-wx .im-bubble-text--rich,
.im-shell .im-msg-row.self .im-bubble--self-wx .im-file {
  color: #000 !important;
}

.im-shell .im-bubble-text,
.im-shell .im-bubble-text--rich .im-rich-text-body {
  font-size: 15px !important;
  line-height: 1.5 !important;
}

/* 图片消息：固定框 + 防跳动（配合 scroll-stable） */
.im-shell .im-img-frame[data-yx-sized],
.im-shell .im-img-frame {
  border-radius: 4px;
  overflow: hidden;
  display: block;
}

.im-shell .im-img-frame .im-img,
.im-shell .im-img-frame img,
.im-shell .im-img-frame .el-image__inner {
  border-radius: 4px;
  display: block;
  object-fit: cover;
  width: 100%;
  height: 100%;
}

/* 语音消息 — 微信布局：图标 + 波纹 + 秒数，严格裁剪不溢出 */
.im-shell .yx-voice-bubble-wrap,
.im-shell .message-bubble__body:has(.im-voice-bubble),
.im-shell .im-bubble:has(.im-voice-bubble) {
  overflow: hidden !important;
  max-width: 100% !important;
}

.im-shell .yx-voice-bubble-wrap.message-bubble__body,
.im-shell .yx-voice-bubble-wrap.im-bubble {
  padding: 8px 10px !important;
}

.im-shell .im-voice-bubble {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 2px !important;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  box-sizing: border-box !important;
  overflow: hidden !important;
  contain: layout paint !important;
  min-width: 96px !important;
  max-width: min(200px, 52vw) !important;
  width: auto !important;
  padding: 6px 10px !important;
  border-radius: 6px !important;
  background: #fff !important;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  flex-shrink: 1 !important;
}

.im-shell .message-bubble__body .im-voice-bubble,
.im-shell .im-bubble .im-voice-bubble {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-width: 88px !important;
}

.im-shell .im-msg-row.self .im-voice-bubble,
.im-shell .message-bubble--self .im-voice-bubble {
  background: var(--wx-bubble-self, #95ec69) !important;
  box-shadow: none;
}

.im-shell .message-bubble--self .message-bubble__body .im-voice-bubble {
  background: transparent !important;
}

.im-shell .im-voice-bubble__play {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

.im-shell .im-voice-bubble__play .el-icon {
  font-size: 16px !important;
  width: 16px !important;
  height: 16px !important;
}

.im-shell .im-voice-bubble__body {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 100% !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 4px !important;
}

.im-shell .im-msg-row:not(.self) .im-voice-bubble,
.im-shell .message-bubble:not(.message-bubble--self) .im-voice-bubble {
  flex-direction: row-reverse !important;
}

.im-shell .im-msg-row:not(.self) .im-voice-bubble__body,
.im-shell .message-bubble:not(.message-bubble--self) .im-voice-bubble__body {
  flex-direction: row-reverse !important;
}

.im-shell .im-voice-bubble__wave {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 72px !important;
  height: 14px !important;
  overflow: hidden !important;
  display: flex !important;
  align-items: flex-end !important;
  justify-content: flex-start !important;
  gap: 2px !important;
}

.im-shell .im-voice-bubble__bar {
  flex: 0 0 2px !important;
  width: 2px !important;
  height: 6px !important;
  max-height: 12px !important;
  border-radius: 1px !important;
  background: rgba(0, 0, 0, 0.28) !important;
}

.im-shell .im-voice-bubble__bar:nth-child(odd) {
  height: 9px !important;
}

.im-shell .im-voice-bubble__bar:nth-child(3n) {
  height: 11px !important;
}

.im-shell .im-voice-bubble__bar:nth-child(n + 9) {
  display: none !important;
}

.im-shell .im-msg-row.self .im-voice-bubble__bar,
.im-shell .message-bubble--self .im-voice-bubble__bar {
  background: rgba(0, 0, 0, 0.22) !important;
}

.im-shell .im-voice-bubble__dur {
  flex: 0 0 auto !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: #111 !important;
  min-width: 14px !important;
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap !important;
}

.im-shell .im-msg-row:not(.self) .im-voice-bubble__dur,
.im-shell .message-bubble:not(.message-bubble--self) .im-voice-bubble__dur {
  text-align: left !important;
}

.im-shell .im-voice-bubble.is-playing .im-voice-bubble__bar {
  animation: yx-wx-voice-bar 0.55s ease-in-out infinite alternate;
}

@keyframes yx-wx-voice-bar {
  from {
    transform: scaleY(0.55);
    opacity: 0.65;
  }
  to {
    transform: scaleY(1.15);
    opacity: 1;
  }
}

.im-shell .im-voice-bubble__play.is-playing,
.im-shell .im-voice-bubble.is-playing .im-voice-bubble__play {
  animation: yx-wx-voice-pulse 0.75s ease-in-out infinite alternate;
}

.yx-voice-unread-dot {
  position: absolute;
  top: -3px;
  left: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fa5151;
  box-shadow: 0 0 0 1px #fff;
  pointer-events: none;
}

.im-shell .im-msg-row.self .yx-voice-unread-dot,
.im-shell .message-bubble--self .yx-voice-unread-dot {
  display: none !important;
}

@keyframes yx-wx-voice-pulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.08); opacity: 0.82; }
}

.im-shell .im-dynamic-scroller.yx-scroll-smooth .vue-recycle-scroller {
  scroll-behavior: smooth;
}
