/* 翻译结果布局修复 */

/* 确保消息容器有足够的宽度 */
.message-bubble-container {
  position: relative;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

/* 右侧消息（发送方）的翻译结果样式 */
.message-li.out .enhanced-message-text {
  width: 100%;
  display: block;
  position: relative;
}

.message-li.out .translation-result-simple {
  position: absolute;
  right: -20px;
  top: 0;
  margin-top: 2px;
  z-index: 100;
}

/* 左侧消息（接收方）的翻译结果样式 */
.message-li.in .enhanced-message-text {
  width: 100%;
  display: block;
  position: relative;
}

.message-li.in .translation-result-simple {
  position: absolute;
  left: -20px;
  top: 0;
  margin-top: 2px;
  z-index: 100;
}

/* 移动端特殊处理 */
@media (max-width: 768px) {
  /* 右侧消息翻译标签 */
  .message-li.out .translation-result-simple {
    position: fixed;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  /* 左侧消息翻译标签 */
  .message-li.in .translation-result-simple {
    position: fixed;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  /* 添加遮罩层 */
  .translation-result::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
    pointer-events: none;
  }
  
  /* 翻译结果内容优化 */
  .translation-result .translation-content {
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 翻译结果头部优化 */
  .translation-result .translation-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f8f9fa;
  }
  
  /* 翻译结果操作区优化 */
  .translation-result .translation-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: #f8f9fa;
    padding: 12px;
  }
  
  .translation-result .copy-translation {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border-radius: 8px;
  }
}

/* PC端优化 */
@media (min-width: 769px) {
  .message-li.out .translation-result {
    right: 0;
    transform: translateX(0);
  }
  
  .message-li.in .translation-result {
    left: 0;
    transform: translateX(0);
  }
  
  /* 添加箭头指示器 */
  .message-li.out .translation-result::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #e0e0e0;
  }
  
  .message-li.out .translation-result::after {
    content: '';
    position: absolute;
    top: -7px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
  }
  
  .message-li.in .translation-result::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #e0e0e0;
  }
  
  .message-li.in .translation-result::after {
    content: '';
    position: absolute;
    top: -7px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
  }
}

/* 确保翻译结果文本不会溢出 */
.translation-content {
  word-wrap: break-word !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  white-space: pre-wrap !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

/* 动画优化 */
.translation-result {
  animation: translateSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes translateSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 暗色模式适配 */
@media (prefers-color-scheme: dark) {
  .message-li.out .translation-result,
  .message-li.in .translation-result {
    background: #2c2c2e;
    border-color: #48484a;
    color: #ffffff;
  }
  
  .translation-result::after {
    border-bottom-color: #2c2c2e !important;
  }
}