/* 消息气泡尺寸缩小 */

/* 移动端消息气泡缩小 */
@media (max-width: 768px) {
  /* 缩小消息气泡的最大宽度 */
  .message-bubble-container {
    max-width: 55% !important;
    width: fit-content !important;
    min-width: auto !important;
    transform: scale(0.8) !important;
    transform-origin: top left !important;
    display: inline-block !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
  }
  
  /* 右侧消息气泡 */
  .message-li.out .message-bubble-container {
    transform: scale(0.8) !important;
    transform-origin: top right !important;
    margin-left: auto !important;
    max-width: 50% !important;
  }
  
  /* 左侧消息气泡 */
  .message-li.in .message-bubble-container {
    transform: scale(0.8) !important;
    transform-origin: top left !important;
    margin-right: auto !important;
    max-width: 50% !important;
  }
  
  /* 缩小消息文本字体 */
  .message-text-container .text {
    font-size: 12px !important;
    line-height: 1.2 !important;
  }
  
  /* 缩小消息内边距 */
  .message-bubble-container {
    padding: 6px 8px !important;
  }
  
  /* 调整消息间距 */
  .message-li {
    margin-bottom: 8px !important;
  }
  
  /* 缩小头像尺寸 */
  .message-avatar {
    width: 35px !important;
    height: 35px !important;
  }
  
  /* 调整消息时间戳 */
  .message-timestamp {
    font-size: 11px !important;
    margin: 4px 0 !important;
  }
  
  /* 缩小表情符号 */
  .emoji {
    width: 18px !important;
    height: 18px !important;
  }
  
  /* 调整消息工具栏 */
  .message-tool {
    transform: scale(0.9) !important;
  }
  
  /* 优化翻译标签位置 */
  .message-li.out .translation-result-simple {
    left: -20px !important;
    top: -6px !important;
  }
  
  .message-li.in .translation-result-simple {
    right: -20px !important;
    top: -6px !important;
  }
  
  .message-li.out .translation-indicator {
    left: -20px !important;
    top: -6px !important;
  }
  
  .message-li.in .translation-indicator {
    right: -20px !important;
    top: -6px !important;
  }
}

/* 超小屏幕进一步缩小 */
@media (max-width: 375px) {
  .message-bubble-container {
    max-width: 45% !important;
    transform: scale(0.75) !important;
  }
  
  .message-li.out .message-bubble-container {
    max-width: 40% !important;
  }
  
  .message-li.in .message-bubble-container {
    max-width: 40% !important;
  }
  
  .message-text-container .text {
    font-size: 11px !important;
  }
  
  .message-bubble-container {
    padding: 5px 6px !important;
  }
  
  .message-avatar {
    width: 28px !important;
    height: 28px !important;
  }
  
  .message-li.out .translation-result-simple,
  .message-li.out .translation-indicator {
    left: -16px !important;
  }
  
  .message-li.in .translation-result-simple,
  .message-li.in .translation-indicator {
    right: -16px !important;
  }
}

/* 特大屏幕适配 */
@media (max-width: 320px) {
  .message-bubble-container {
    max-width: 35% !important;
    transform: scale(0.7) !important;
  }
  
  .message-li.out .message-bubble-container {
    max-width: 32% !important;
  }
  
  .message-li.in .message-bubble-container {
    max-width: 32% !important;
  }
  
  .message-text-container .text {
    font-size: 10px !important;
  }
  
  .message-bubble-container {
    padding: 4px 5px !important;
  }
}

/* 确保缩放后的气泡仍然可点击 */
.message-bubble-container {
  pointer-events: auto !important;
  cursor: pointer !important;
}

/* 优化长按效果 */
.message-bubble-container.long-pressing {
  transform: scale(0.75) !important;
}

.message-li.out .message-bubble-container.long-pressing {
  transform: scale(0.75) !important;
  transform-origin: top right !important;
}

.message-li.in .message-bubble-container.long-pressing {
  transform: scale(0.75) !important;
  transform-origin: top left !important;
}

/* 保持翻译标签正常大小 */
.translation-result-simple,
.translation-indicator {
  transform: none !important;
  font-size: 7px !important;
}

/* 调整消息列表整体布局 */
@media (max-width: 768px) {
  .tui-message-list {
    padding: 10px 15px !important;
  }
  
  /* 减少消息之间的间距 */
  .message-li + .message-li {
    margin-top: 6px !important;
  }
  
  /* 优化消息对齐 */
  .message-li.out {
    text-align: right !important;
    padding-left: 40px !important;
    padding-right: 10px !important;
  }
  
  .message-li.in {
    text-align: left !important;
    padding-right: 40px !important;
    padding-left: 10px !important;
  }
}

/* 确保输入框等其他元素不受影响 */
.message-input-container,
.chat-header,
.message-tool {
  transform: none !important;
}

/* 优化滚动性能 */
.tui-message-list {
  will-change: scroll-position !important;
  -webkit-overflow-scrolling: touch !important;
}

/* 让气泡尺寸刚好包含文字内容 */
@media (max-width: 768px) {
  /* 紧凑布局 */
  .message-bubble-container {
    white-space: nowrap !important;
    overflow: visible !important;
  }
  
  /* 对于长文本允许换行但限制宽度 */
  .message-text-container {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    max-width: 100% !important;
    display: inline-block !important;
  }
  
  /* 调整消息列表布局 */
  .message-li.out {
    text-align: right !important;
    padding-left: 25px !important;
    padding-right: 8px !important;
  }
  
  .message-li.in {
    text-align: left !important;
    padding-right: 25px !important;
    padding-left: 8px !important;
  }
  
  /* 确保翻译标签有足够空间 */
  .message-li.out .enhanced-message-text {
    position: relative !important;
    display: inline-block !important;
  }
  
  .message-li.in .enhanced-message-text {
    position: relative !important;
    display: inline-block !important;
  }
}