/* 聊天窗口样式 */
.chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 400px;
  height: 600px; /* 固定高度 */
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: all 0.3s ease;
  overflow: hidden;
  font-size: 16px; /* 增大基础字体大小 */
}

.chat-container.collapsed {
  height: 60px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--md-primary-fg-color);
  color: white;
  cursor: pointer;
  user-select: none;
  font-size: 18px; /* 增大标题字体 */
}

.chat-header-title {
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header-title svg {
  width: 24px;
  height: 24px;
}

.chat-controls {
  display: flex;
  gap: 8px;
}

.chat-controls svg {
  width: 22px;
  height: 22px;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px; /* 减小消息之间的间距 */
  height: 400px; /* 留出更多空间给输入框 */
}

.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  word-wrap: break-word;
  line-height: 1.4; /* 减小行高 */
  position: relative;
  font-size: 16px;
}

.user-message {
  align-self: flex-end;
  background: #e1f5fe;
  border-bottom-right-radius: 0;
}

.assistant-message {
  align-self: flex-start;
  background: #f5f5f5;
  border-bottom-left-radius: 0;
}

.chat-footer {
  padding: 12px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  align-items: flex-start; /* 改为顶部对齐，配合更高的输入框 */
}

.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 12px 18px;
  outline: none;
  font-size: 16px;
  resize: none;
  min-height: 70px; /* 设置初始最小高度 */
  max-height: 150px; /* 增加最大高度 */
  overflow-y: auto;
}

.chat-send-btn {
  background: var(--md-primary-fg-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  margin-left: 12px;
  margin-top: 12px; /* 稍微下移按钮，与输入框顶部有一定距离 */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.chat-send-btn svg {
  width: 22px;
  height: 22px;
}

.chat-send-btn:hover {
  background: var(--md-primary-fg-color--dark);
}

.chat-send-btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
}

/* 打开聊天的悬浮按钮 */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--md-primary-fg-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
  transition: all 0.3s ease;
}

.chat-fab svg {
  width: 28px;
  height: 28px;
}

.chat-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}

/* 选中文本后显示的询问按钮 */
.ask-selection-btn {
  position: absolute;
  background: var(--md-primary-fg-color);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 14px;
  cursor: pointer;
  z-index: 1001;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.ask-selection-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

/* 打字动画 */
.typing-indicator {
  display: flex;
  align-items: center;
  align-self: flex-start;
  background: #f5f5f5;
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 5px;
}

.typing-dot {
  width: 10px;
  height: 10px;
  margin: 0 3px;
  background-color: #888;
  border-radius: 50%;
  opacity: 0.6;
  animation: typing-dot-animation 1.4s infinite ease-in-out both;
}

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

@keyframes typing-dot-animation {
  0%, 80%, 100% { transform: scale(0.7); }
  40% { transform: scale(1); }
}

/* Markdown 样式增强 */
.assistant-message code {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 14px;
}

.assistant-message pre {
  background-color: #282c34;
  color: #abb2bf;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0; /* 减小上下外边距 */
  font-family: monospace;
  font-size: 14px;
}

.assistant-message pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

/* 减小段落和元素之间的间距 */
.assistant-message p {
  margin: 4px 0; /* 减小段落间距 */
}

.assistant-message ul, .assistant-message ol {
  margin: 4px 0; /* 减小列表外边距 */
  padding-left: 20px; /* 减小内边距 */
}

.assistant-message li {
  margin: 2px 0; /* 减小列表项间距 */
}

.assistant-message h1, .assistant-message h2, .assistant-message h3 {
  margin: 6px 0 4px 0; /* 减小标题间距 */
}

.assistant-message a {
  color: var(--md-primary-fg-color);
  text-decoration: none;
}

.assistant-message a:hover {
  text-decoration: underline;
}

.assistant-message blockquote {
  border-left: 4px solid #ccc;
  margin: 6px 0;
  padding-left: 12px;
  color: #666;
}

/* Markdown 格式中的换行处理 */
.assistant-message br {
  line-height: 1.2; /* 减小换行行高 */
  margin-bottom: 0;
  display: block;
  content: "";
  margin-top: 5px; /* 减少换行产生的空间 */
}

/* 移动设备适配 */
@media (max-width: 768px) {
  .chat-container {
    width: 350px;
    height: 550px;
  }
  
  .chat-body {
    height: 350px;
  }
}

@media (max-width: 480px) {
  .chat-container {
    width: calc(100% - 40px);
    height: 500px;
  }
  
  .chat-body {
    height: 300px;
  }
}

/* 从JS文件迁移的样式 */
#ai-title {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

#ai-title:hover {
  color: #1e88e5;
}

.chat-close {
  cursor: pointer;
  transition: color 0.2s;
}

.chat-close:hover {
  color: #f44336;
  transform: scale(1.1);
}

.chat-clear-btn {
  margin-right: 10px;
  cursor: pointer;
  transition: color 0.2s;
}

.chat-clear-btn:hover {
  color: #f44336;
}

.persona-message {
  background-color: #f0f7ff;
  border-left: 3px solid #2196F3;
  font-style: italic;
}

.persona-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.persona-modal-content {
  background-color: white;
  border-radius: 8px;
  width: 300px;
  max-width: 90%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.persona-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.persona-modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.persona-modal-close {
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

.persona-modal-close:hover {
  color: #333;
}

.persona-modal-body {
  padding: 16px;
}

.persona-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.persona-option {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.persona-option:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

.persona-option.active {
  background-color: #e3f2fd;
  border-color: #2196F3;
  color: #0d47a1;
}

.persona-custom {
  display: flex;
  margin-top: 12px;
}

.persona-custom input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px 0 0 4px;
  outline: none;
}

.persona-custom input:focus {
  border-color: #2196F3;
}

.persona-custom button {
  padding: 8px 12px;
  background-color: #2196F3;
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
}

.persona-custom button:hover {
  background-color: #1976d2;
} 