/* AI聊天功能专用样式 - WeChat风格 */

/* AI消息容器 */
.message.ai {
  align-self: flex-start;
  align-items: flex-start;
  max-width: 80%;
}

/* AI消息内容基础样式 */
.message.ai .message-content {
  background: linear-gradient(135deg, #1e90ff, #4169e1);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(30, 144, 255, 0.2);
  position: relative;
}

/* AI思考过程消息 */
.ai-thinking-message {
  background: #f8f9fa !important;
  border: 1px solid #e9ecef !important;
  color: #6c757d !important;
  font-style: italic;
  position: relative;
  min-width: 200px;
}

.ai-thinking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.ai-thinking-indicator {
  font-size: 14px;
  font-weight: 500;
  color: #6c757d;
}

.ai-thinking-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: #6c757d;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-thinking-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #495057;
}

.ai-thinking-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.ai-thinking-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.ai-thinking-content.expanded {
  max-height: 300px;
  opacity: 1;
}

.thinking-text {
  padding: 8px 0;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* AI响应消息 */
.ai-response-message {
  background: linear-gradient(135deg, #1e90ff, #4169e1) !important;
  color: white !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(30, 144, 255, 0.2) !important;
}

/* AI消息操作按钮 */
.ai-response-message .message-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.ai-response-message .message-actions button {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.ai-response-message .message-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.ai-response-message .message-actions .delete-btn:hover {
  background: rgba(255, 0, 0, 0.3);
  border-color: rgba(255, 0, 0, 0.5);
}

.ai-response-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-response-indicator {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}

/* AI响应内容样式 */
.ai-response-message .text-message {
  color: white !important;
}

.ai-response-message .text-message.markdown-rendered {
  padding: 8px 28px 8px 0 !important;
}

/* AI响应中的Markdown样式调整 */
.ai-response-message .text-message.markdown-rendered h1,
.ai-response-message .text-message.markdown-rendered h2,
.ai-response-message .text-message.markdown-rendered h3,
.ai-response-message .text-message.markdown-rendered h4,
.ai-response-message .text-message.markdown-rendered h5,
.ai-response-message .text-message.markdown-rendered h6 {
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.ai-response-message .text-message.markdown-rendered blockquote {
  border-left-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
}

.ai-response-message .text-message.markdown-rendered code {
  background: rgba(255, 255, 255, 0.2);
  color: #f8f9fa;
}

.ai-response-message .text-message.markdown-rendered pre {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-response-message .text-message.markdown-rendered a {
  color: #87ceeb;
  text-decoration: underline;
}

.ai-response-message .text-message.markdown-rendered hr {
  border-top-color: rgba(255, 255, 255, 0.3);
}

/* AI打字指示器 */
.ai-typing-indicator {
  display: inline-block;
  color: rgba(255, 255, 255, 0.8);
  animation: aiTypingBlink 1s infinite;
  font-weight: bold;
  margin-left: 2px;
}

@keyframes aiTypingBlink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0.3;
  }
}

/* AI模式指示器 - 切换开关形式 */
.ai-mode-indicator {
  position: absolute;
  top: -20px;
  right: 8px;
  background: #e0e0e0;
  color: #666;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  z-index: 10;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: aiModeSlideIn 0.3s ease-out;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-mode-indicator:hover {
  background: #d0d0d0;
  transform: scale(1.02);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.ai-mode-indicator:active {
  transform: scale(0.98);
}

@keyframes aiModeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* AI消息的Markdown切换按钮样式调整 */
.ai-response-message .markdown-toggle {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.ai-response-message .markdown-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* AI响应完成状态 */
.ai-response-complete {
  position: relative;
}

.ai-response-complete::after {
  content: "✓";
  position: absolute;
  bottom: 4px;
  right: 4px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 10px;
  font-weight: bold;
}

/* AI错误消息样式 */
.message.ai .message-content.ai-error {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52) !important;
  color: white !important;
  border: 1px solid #ff5252 !important;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .message.ai {
    max-width: 85%;
  }

  .ai-thinking-content.expanded {
    max-height: 200px;
  }

  .ai-mode-indicator {
    font-size: 9px;
    padding: 3px 6px;
    top: -15px;
    right: 8px;
  }

  .ai-thinking-toggle {
    padding: 2px;
  }

  .thinking-text {
    font-size: 12px;
  }

  .ai-response-indicator,
  .ai-thinking-indicator {
    font-size: 11px;
  }
}

/* 大屏幕优化 */
@media (min-width: 768px) {
  .message.ai {
    max-width: 70%;
  }

  .ai-thinking-content.expanded {
    max-height: 400px;
  }

  .thinking-text {
    font-size: 14px;
  }
}

/* AI消息动画效果 */
.message.ai.fade-in {
  animation: aiMessageSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes aiMessageSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* AI思考过程加载动画 */
.ai-thinking-message .ai-thinking-indicator::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  margin-left: 4px;
  animation: aiThinkingPulse 1.5s infinite;
}

@keyframes aiThinkingPulse {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* 滚动条样式优化（AI消息区域） */
.ai-thinking-content::-webkit-scrollbar {
  width: 4px;
}

.ai-thinking-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
}

.ai-thinking-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
}

.ai-thinking-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.5);
}
