/* 移动端增强样式 */

/* 改善触摸体验 - 扩展到整个消息气泡 */
.message-bubble-container {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  position: relative;
  padding: 4px;
  margin: -4px;
  border-radius: 12px;
}

.message-bubble-container:active {
  background-color: rgba(0, 0, 0, 0.05);
  transform: scale(0.98);
}

/* 长按反馈效果 */
.message-bubble-container.long-pressing {
  transform: scale(0.96);
  background-color: rgba(0, 0, 0, 0.08);
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* PC端悬停效果 */
@media (min-width: 769px) {
  .message-bubble-container:hover {
    background-color: rgba(0, 0, 0, 0.02);
    transform: scale(1.01);
  }
}

/* 修复右侧消息翻译结果显示问题 */
.message-li.out .enhanced-message-text {
  width: 100%;
  max-width: 100%;
}

.message-li.out .translation-result {
  position: relative;
  right: 0;
  left: auto;
  max-width: calc(100vw - 80px);
  margin-left: auto;
  margin-right: 0;
  box-sizing: border-box;
}

.message-li.in .translation-result {
  max-width: calc(100vw - 80px);
  margin-left: 0;
  margin-right: auto;
}

/* 确保翻译内容不会溢出 */
.translation-result {
  overflow: hidden;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}

.translation-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* 优化消息工具栏在移动端的显示 */
@media (max-width: 768px) {
  .message-tool {
    position: fixed !important;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    background: white;
    padding: 0;
    max-width: 90vw;
  }
  
  .message-tool::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
  }
  
  .dialog-item-list-h5 {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    max-width: none;
  }
  
  .dialog-item-list-h5 .list-item {
    flex: 0 0 auto;
    min-width: 70px;
    padding: 16px 12px;
    border-radius: 12px;
    background: #f8f9fa;
    transition: all 0.2s ease;
  }
  
  .dialog-item-list-h5 .list-item:active {
    background: #e9ecef;
    transform: scale(0.95);
  }
  
  .dialog-item-list-h5 .list-item .list-item-text {
    font-size: 12px;
    margin-top: 6px;
    font-weight: 500;
  }
}

/* 翻译结果优化 */
.translation-result {
  animation: slideInUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 触摸友好的按钮样式 */
.touch-friendly-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.touch-friendly-btn:active {
  transform: scale(0.95);
}

/* 改善滚动性能 */
.tui-message-list {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* 优化输入框在移动端的体验 */
@media (max-width: 768px) {
  .message-input-container {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  .translation-result {
    background: #2c2c2e;
    border-color: #48484a;
    color: #ffffff;
  }
  
  .translation-header {
    background: #48484a;
    border-color: #636366;
  }
  
  .translation-content {
    color: #ffffff;
  }
  
  .translation-actions {
    background: #48484a;
    border-color: #636366;
  }
}

/* 减少动画以提高性能 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
  .message-bubble-container {
    border: 2px solid currentColor;
  }
  
  .translation-result {
    border: 2px solid currentColor;
  }
}