/* 全局样式 */
:root {
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --background-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  --message-user-bg: var(--primary-color);
  --message-ai-bg: #f8f9fa;
  --message-user-text: white;
  --message-ai-text: #333;
  --border-color: #e1e5e9;
  --shadow-color: rgba(0, 0, 0, 0.15);
}

body {
  font-family: 'SF Pro Display', 'SF Pro Icons', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--background-gradient);
  color: #1c1c1e;
  font-size: 16px;
}

body.theme-dark {
  --message-user-bg: #4a5568;
  --message-ai-bg: #2d3748;
  --message-user-text: white;
  --message-ai-text: #e2e8f0;
  --border-color: #4a5568;
  --shadow-color: rgba(0, 0, 0, 0.3);
  background: #1a202c;
  color: #e2e8f0;
}

body.theme-blue {
  --primary-color: #3b82f6;
  --secondary-color: #1d4ed8;
  --background-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

body.theme-purple {
  --primary-color: #8b5cf6;
  --secondary-color: #7c3aed;
  --background-gradient: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.chat-container {
  background-color: white;
  border-radius: 20px;
  box-shadow: 0 20px 40px var(--shadow-color);
  width: 100%;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
}

body.theme-dark .chat-container {
  background-color: #2d3748;
  border-color: #4a5568;
}

/* 头部样式 */
.chat-header {
  background: var(--background-gradient);
  color: white;
  padding: 20px 25px;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.icon-btn i {
  font-size: 16px;
}

/* 消息区域 */
.chat-messages {
  flex-grow: 1;
  padding: 25px;
  overflow-y: auto;
  background-color: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

body.theme-dark .chat-messages {
  background-color: #1a202c;
}

/* 欢迎消息 */
.welcome-message {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  text-align: center;
  margin: 20px auto;
  max-width: 600px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

body.theme-dark .welcome-message {
  background: #2d3748;
  border-color: #4a5568;
  color: #e2e8f0;
}

.ai-avatar {
  width: 80px;
  height: 80px;
  background: var(--background-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: white;
  font-size: 32px;
}

.ai-avatar.small {
  width: 30px;
  height: 30px;
  font-size: 16px;
  margin: 0 10px 0 0;
}

.welcome-content h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 22px;
}

body.theme-dark .welcome-content h3 {
  color: #e2e8f0;
}

.welcome-content p {
  color: #666;
  line-height: 1.6;
  margin-bottom: 15px;
}

body.theme-dark .welcome-content p {
  color: #a0aec0;
}

.welcome-content ul {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 20px 0;
}

.welcome-content li {
  padding: 8px 0;
  color: #555;
  display: flex;
  align-items: center;
  gap: 10px;
}

body.theme-dark .welcome-content li {
  color: #cbd5e0;
}

.welcome-content li i {
  color: var(--primary-color);
}

/* 消息气泡 */
.message {
  display: flex;
  max-width: 80%;
  position: relative;
  animation: messageAppear 0.3s ease-out;
}

.message-animation {
  animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.ai {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 10px;
  background: var(--primary-color);
  color: white;
  font-size: 14px;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: #e2e8f0;
  color: #4a5568;
}

.message-content-wrapper {
  display: flex;
  flex-direction: column;
}

.message-content {
  padding: 15px 20px;
  border-radius: 25px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  position: relative;
  max-width: 100%;
}

.message.user .message-content {
  background: var(--message-user-bg);
  color: var(--message-user-text);
  border-bottom-right-radius: 5px;
}

.message.ai .message-content {
  background: var(--message-ai-bg);
  color: var(--message-ai-text);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 5px;
}

.timestamp {
  font-size: 11px;
  color: #8e8e93;
  margin-top: 5px;
  opacity: 0.7;
}

body.theme-dark .timestamp {
  color: #a0aec0;
}

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

.message.ai .timestamp {
  text-align: left;
}

/* 输入区域 */
.input-area {
  display: flex;
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background-color: white;
  align-items: center;
  gap: 15px;
}

body.theme-dark .input-area {
  background-color: #2d3748;
  border-color: #4a5568;
}

#user-input {
  flex-grow: 1;
  border: 2px solid var(--border-color);
  border-radius: 30px;
  padding: 15px 20px;
  font-size: 16px;
  outline: none;
  transition: all 0.2s ease;
  background-color: #f8f9fa;
}

body.theme-dark #user-input {
  background-color: #1a202c;
  border-color: #4a5568;
  color: #e2e8f0;
}

#user-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background-color: white;
}

body.theme-dark #user-input:focus {
  background-color: #2d3748;
}

.send-btn {
  background: var(--background-gradient);
  color: white;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 18px;
}

.send-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.send-btn:active {
  transform: translateY(0) scale(0.98);
}

.send-btn i {
  font-size: 20px;
}

/* 打字指示器 */
.typing-indicator {
  display: flex;
  align-items: center;
  padding: 15px 25px;
  background-color: white;
  border-top: 1px solid var(--border-color);
}

body.theme-dark .typing-indicator {
  background-color: #2d3748;
  border-color: #4a5568;
}

.typing-indicator .dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-indicator .dots span {
  width: 8px;
  height: 8px;
  background-color: var(--primary-color);
  border-radius: 50%;
  display: inline-block;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator .dots span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator .dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator .dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-5px);
  }
}

/* 设置模态框 */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

body.theme-dark .modal-content {
  background: #2d3748;
  color: #e2e8f0;
}

.modal-header {
  background: var(--background-gradient);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px;
}

.setting-item {
  margin-bottom: 20px;
}

.setting-item label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

body.theme-dark .setting-item label {
  color: #e2e8f0;
}

.setting-item select,
.setting-item input[type="range"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: white;
}

body.theme-dark .setting-item select,
body.theme-dark .setting-item input[type="range"] {
  background: #1a202c;
  border-color: #4a5568;
  color: #e2e8f0;
}

#font-size-value {
  margin-left: 10px;
  font-weight: 500;
}

.modal-footer {
  padding: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-color);
}

body.theme-dark .modal-footer {
  border-color: #4a5568;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--background-gradient);
  color: white;
}

.btn-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

body.theme-dark .btn-secondary {
  background: #4a5568;
  color: #e2e8f0;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

body.theme-dark .chat-messages::-webkit-scrollbar-track {
  background: #4a5568;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--background-gradient);
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .chat-container {
    height: 100vh;
    border-radius: 0;
    max-width: 100%;
  }
  
  .chat-header {
    padding: 15px 20px;
  }
  
  .chat-header h1 {
    font-size: 20px;
  }
  
  .chat-messages {
    padding: 15px;
  }
  
  .message {
    max-width: 90%;
  }
  
  .welcome-message {
    padding: 20px;
    margin: 10px auto;
  }
  
  .input-area {
    padding: 15px;
  }
  
  #user-input {
    padding: 12px 15px;
    font-size: 14px;
  }
  
  .send-btn {
    width: 45px;
    height: 45px;
  }
}
