/**
 * Chat Core Styles - 聊天界面核心样式
 * 提取自原项目中所有聊天相关的样式
 */

/* ============================================================================
   聊天容器 - Chat Container
   ============================================================================ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: white;
  border-radius: 100px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  overflow: hidden;
  transition: all 0.3s ease;
}

.chat-container.chat-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  border-radius: 0;
  box-shadow: none;
  background: white;
}

.chat-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 60px;
}

.chat-header h3,
.chat-header h4 {
  margin: 0;
  font-size: 1.1rem;
  color: #333;
  font-weight: 600;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-fullscreen-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.chat-fullscreen-toggle:hover {
  background-color: #e0e0e0;
  color: #333;
}

.chain-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #666;
  background: #f0f8ff;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #e0e7ff;
}

/* ============================================================================
   聊天历史 - Chat History
   ============================================================================ */

.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 100vh;
  scroll-behavior: smooth;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 100vh;
}

.empty-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: #666;
  text-align: center;
}

.empty-chat p {
  margin: 0.5rem 0;
  line-height: 1.5;
}

/* ============================================================================
   消息样式 - Message Styles
   ============================================================================ */

.message {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.message.user {
  align-items: flex-end;
}

.message.assistant {
  align-items: flex-start;
}

.message.streaming {
  opacity: 1;
}

.message-content {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: 18px;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 0.95rem;
  position: relative;
}

.message.user .message-content {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border-bottom-right-radius: 8px;
}

.message.assistant .message-content {
  background: #f8f9fa;
  color: #333;
  border: 1px solid #e9ecef;
  border-bottom-left-radius: 8px;
}

.message-time {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.5rem;
  padding: 0 0.5rem;
}

.message.user .message-time {
  text-align: right;
}

.message.assistant .message-time {
  text-align: left;
}

/* ============================================================================
   思维链样式 - Thinking Chain Styles
   ============================================================================ */

.thinking-container {
  margin-bottom: 1rem;
  border: 1px solid #e0e7ff;
  border-radius: 8px;
  background: #f8faff;
  overflow: hidden;
}

.thinking-header {
  padding: 0.75rem 1rem;
  background: #f0f8ff;
  border-bottom: 1px solid #e0e7ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
  user-select: none;
}

.thinking-header:hover {
  background: #e6f3ff;
}

.thinking-icon {
  font-size: 1.1rem;
}

.thinking-title {
  font-weight: 500;
  color: #4338ca;
  font-size: 0.9rem;
}

.thinking-toggle {
  margin-left: auto;
  color: #6b7280;
  font-size: 0.8rem;
  transition: transform 0.2s;
}

.thinking-content-box {
  padding: 1rem;
  background: white;
  border-top: 1px solid #e0e7ff;
}

.thinking-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

/* ============================================================================
   流式处理样式 - Streaming Styles
   ============================================================================ */

.streaming-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #007bff;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.streaming-text {
  position: relative;
}

.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: #007bff;
  animation: blink 1s infinite;
  margin-left: 2px;
  vertical-align: text-bottom;
}

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

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  margin-right: 8px;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #666;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.partial-math-indicator {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.7;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ============================================================================
   聊天输入 - Chat Input
   ============================================================================ */

.chat-input {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.chat-input input[type="text"] {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

.chat-input input[type="text"]:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chat-input input[type="text"]:disabled {
  background-color: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
}

.send-button {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  background: #0056b3;
  transform: scale(1.05);
}

.send-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
  transform: none;
}

.image-upload-btn {
  background: #f8f9fa;
  color: #666;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.image-upload-btn:hover:not(:disabled) {
  background: #e9ecef;
  color: #495057;
  transform: scale(1.05);
}

.image-upload-btn:disabled {
  background: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================================
   图片预览 - Image Preview
   ============================================================================ */

.image-preview-container {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 0.75rem;
  background: #f8f9fa;
}

.image-preview-header {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.image-preview-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.image-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #ddd;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-info {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px;
  border-radius: 0 0 0 4px;
}

.remove-image-btn {
  background: rgba(220, 53, 69, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.remove-image-btn:hover {
  background: rgba(220, 53, 69, 1);
}

/* ============================================================================
   多模态内容 - Multimodal Content
   ============================================================================ */

.content-text-part {
  margin-bottom: 0.5rem;
}

.content-text-part:last-child {
  margin-bottom: 0;
}

.content-image-part {
  margin: 0.5rem 0;
}

.content-image-part img {
  max-width: 100%;
  max-height: 300px;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.content-unknown {
  padding: 1rem;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
  border-radius: 6px;
  font-style: italic;
}

/* ============================================================================
   保存按钮 - Save Buttons
   ============================================================================ */

.save-buttons-row {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.save-button-inline,
.save-button-primary,
.save-button-secondary {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.save-button-inline {
  background: #28a745;
  color: white;
}

.save-button-inline:hover:not(:disabled) {
  background: #218838;
}

.save-button-primary {
  background: #007bff;
  color: white;
}

.save-button-primary:hover:not(:disabled) {
  background: #0056b3;
}

.save-button-secondary {
  background: #6c757d;
  color: white;
}

.save-button-secondary:hover:not(:disabled) {
  background: #545b62;
}

.save-buttons-group {
  display: flex;
  gap: 0.5rem;
}

/* ============================================================================
   响应式设计 - Responsive Design
   ============================================================================ */

@media (max-width: 768px) {
  .chat-container {
    border-radius: 0;
    height: 100vh;
  }
  
  .chat-header {
    padding: 0.75rem 1rem;
  }
  
  .chat-history {
    padding: 0.75rem;
  }
  
  .message-content {
    max-width: 90%;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
  
  .chat-input {
    padding: 0.75rem 1rem;
  }
  
  .input-row {
    gap: 0.5rem;
  }
  
  .send-button,
  .image-upload-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .chat-input input[type="text"] {
    font-size: 16px; /* 防止iOS缩放 */
  }
}

@media (max-width: 480px) {
  .message-content {
    max-width: 95%;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
  
  .thinking-header {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
  
  .thinking-content-box {
    padding: 0.8rem;
  }
}