/**
 * 清幽云AI样式文件
 * 现代化的界面设计和主题支持
 */

/* 全局重置和基础设置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family, "Microsoft YaHei", "PingFang SC", sans-serif);
  font-size: var(--font-size-base, 14px);
  min-height: 100vh;
  background-color: var(--bg-color, #f5f7fa);
  color: var(--text-color, #2c3e50);
  padding: 20px;
  transition: all 0.3s ease;
}

/* 变量定义 - 浅色主题 */
:root {
  --primary-color: #3498db;
  --secondary-color: #2ecc71;
  --bg-color: #f5f7fa;
  --card-bg: #ffffff;
  --text-color: #2c3e50;
  --border-color: #e0e0e0;
  --ai-message-bg: #ecf0f1;
  --font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-size-base: 14px;
  --font-size-title: 24px;
  --font-size-message: 15px;
  --border-radius: 10px;
  --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  --transition: all 0.3s ease;
}

/* 深色主题 */
body.dark-theme {
  --primary-color: #4a90e2;
  --secondary-color: #27ae60;
  --bg-color: #1a1a1a;
  --card-bg: #2c2c2c;
  --text-color: #e0e0e0;
  --border-color: #404040;
  --ai-message-bg: #3a3a3a;
  --box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* 主容器 */
.ai-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  padding: 20px;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  min-height: 70vh;
}

/* 头部区域 */
.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.ai-title {
  font-size: var(--font-size-title);
  color: var(--text-color);
  font-weight: 600;
}

/* 控制按钮组 */
.control-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.control-btn {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

.control-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* 模型选择器 */
.model-selector {
  position: relative;
}

.model-select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  min-width: 120px;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>');
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

/* 聊天区域 */
.chat-area {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  overflow-y: auto;
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
}

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

.chat-area::-webkit-scrollbar-track {
  background: var(--border-color);
  border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 3px;
}

/* 消息样式 */
.message {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 75%;
  line-height: 1.4;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
  word-wrap: break-word;
}

/* 消息动画 */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 用户消息 */
.user-message {
  background-color: var(--primary-color);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* AI消息 */
.ai-message {
  background-color: var(--ai-message-bg);
  color: var(--text-color);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* 消息时间戳 */
.message-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}

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

/* 加载动画 - 思考过程展示 */
.loading-animation {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 20px;
  background-color: var(--ai-message-bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  max-width: 75%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  animation: messageSlideIn 0.3s ease-out;
}

.loading-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--primary-color);
  font-weight: 500;
}

.loading-dots-container {
  display: flex;
  gap: 6px;
  align-items: center;
}

.loading-dot {
  width: 10px;
  height: 10px;
  background-color: var(--primary-color);
  border-radius: 50%;
  animation: loadingBounce 1.4s infinite ease-in-out both;
  opacity: 0.8;
}

.loading-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
  animation-delay: -0.16s;
}

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

/* 思考过程文本 */
.thinking-text {
  font-size: 13px;
  color: var(--text-color);
  opacity: 0.7;
  font-style: italic;
}

/* 思考过程动画 */
@keyframes thinkingPulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}

.thinking-animation {
  animation: thinkingPulse 2s ease-in-out infinite;
}

/* 输入区域 */
.input-area {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

#userInput {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 25px;
  font-size: var(--font-size-message);
  background: var(--card-bg);
  color: var(--text-color);
  transition: var(--transition);
  resize: none;
  min-height: 45px;
  max-height: 120px;
  overflow-y: auto;
}

#userInput:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

#sendBtn {
  padding: 0 24px;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sendBtn:hover {
  background-color: #27ae60;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

#sendBtn:active {
  transform: translateY(0);
}

/* 清空按钮 */
#clearBtn {
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
}

#clearBtn:hover {
  background: var(--border-color);
}

/* 主题切换按钮 */
#themeToggle {
  padding: 8px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-color);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
}

#themeToggle:hover {
  background: var(--border-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .ai-container {
    padding: 15px;
    min-height: 80vh;
  }
  
  .ai-title {
    font-size: 20px;
  }
  
  .message {
    max-width: 85%;
    padding: 10px 14px;
  }
  
  .input-area {
    flex-direction: column;
  }
  
  #sendBtn {
    padding: 10px 20px;
    align-self: flex-end;
  }
  
  .control-buttons {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .model-select {
    min-width: 100px;
  }
}

@media (max-width: 480px) {
  .ai-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .control-buttons {
    width: 100%;
    justify-content: space-between;
  }
  
  .message {
    max-width: 90%;
  }
}

/* 错误消息样式 */
.error-message {
  background-color: #e74c3c;
  color: white;
  padding: 10px 15px;
  border-radius: 6px;
  margin: 10px 0;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

/* 成功消息样式 */
.success-message {
  background-color: var(--secondary-color);
  color: white;
  padding: 10px 15px;
  border-radius: 6px;
  margin: 10px 0;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

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

/* 提示信息 */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: var(--text-color);
  color: var(--card-bg);
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 12px;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}
