/* ============ Chat 容器 ============ */
#chat-container {
  position: fixed;
  right: 30px;
  top: 120px;
  bottom: 30px;
  z-index: 1000;
  display: none;
  width: 460px;
}

/* ============ Chat 窗口 ============ */
.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* ============ 头部 ============ */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #672c83;
  color: #fff;
  flex-shrink: 0;
}

.chat-title {
  font-size: 16px;
  font-weight: 600;
}

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

.chat-new-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-new-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chat-close:hover {
  opacity: 1;
}

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

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}

/* ============ 消息气泡 ============ */
.message {
  max-width: 80%;
  word-wrap: break-word;
  line-height: 1.6;
}

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

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

.message-content {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
}

.user-message .message-content {
  background: #672c83;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bot-message .message-content {
  background: #fff;
  color: #333;
  border: 1px solid #e8e8e8;
  border-bottom-left-radius: 4px;
  white-space: normal;
}

/* ============ Bot 消息内 Markdown 样式 ============ */
.bot-message .message-content p {
  margin: 0 0 8px 0;
}

.bot-message .message-content p:last-child {
  margin-bottom: 0;
}

.bot-message .message-content ul,
.bot-message .message-content ol {
  margin: 6px 0;
  padding-left: 20px;
}

.bot-message .message-content li {
  margin: 2px 0;
}

.bot-message .message-content strong {
  font-weight: 600;
}

.bot-message .message-content em {
  font-style: italic;
}

.bot-message .message-content a {
  color: #672c83;
  text-decoration: underline;
}

.bot-message .message-content blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid #672c83;
  background: #f9f5fb;
  color: #555;
}

.bot-message .message-content h1,
.bot-message .message-content h2,
.bot-message .message-content h3,
.bot-message .message-content h4 {
  margin: 10px 0 6px 0;
  font-weight: 600;
}

.bot-message .message-content h1 { font-size: 18px; }
.bot-message .message-content h2 { font-size: 16px; }
.bot-message .message-content h3 { font-size: 15px; }

.bot-message .message-content code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: Consolas, Monaco, "Courier New", monospace;
}

.bot-message .message-content pre {
  margin: 8px 0;
  padding: 12px;
  background: #1e1e1e;
  border-radius: 8px;
  overflow-x: auto;
}

.bot-message .message-content pre code {
  background: none;
  padding: 0;
  color: #d4d4d4;
  font-size: 13px;
  line-height: 1.5;
}

.bot-message .message-content table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13px;
}

.bot-message .message-content th,
.bot-message .message-content td {
  border: 1px solid #ddd;
  padding: 6px 10px;
  text-align: left;
}

.bot-message .message-content th {
  background: #f5f5f5;
  font-weight: 600;
}

.bot-message .message-content hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 10px 0;
}

.bot-message .message-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 6px 0;
  display: block;
}

.chat-img-wrap {
  display: inline-block;
  max-width: 100%;
}

.chat-img-fallback {
  display: inline-block;
  padding: 8px 14px;
  background: #f5f0f8;
  border: 1px dashed #b899cc;
  border-radius: 8px;
  color: #672c83;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  margin: 6px 0;
  transition: background 0.2s;
}

.chat-img-fallback:hover {
  background: #ede4f2;
  text-decoration: underline;
}

/* ============ 推荐问题 ============ */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 8px;
}

.chat-suggestion-btn {
  background: #f5f0f8;
  border: 1px solid #d4c0e3;
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  color: #672c83;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  line-height: 1.4;
}

.chat-suggestion-btn:hover {
  background: #ede4f2;
  border-color: #b899cc;
}

/* 思考状态 */
.message-content.thinking {
  color: #999;
  font-style: italic;
  animation: thinking-pulse 1.5s ease-in-out infinite;
}

@keyframes thinking-pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* 加载中 */
.chat-loading {
  text-align: center;
  color: #999;
  padding: 40px 0;
  font-size: 14px;
}

/* ============ 输入区域 ============ */
.chat-input-area {
  display: flex;
  padding: 14px 16px;
  border-top: 1px solid #eee;
  gap: 10px;
  background: #fff;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #672c83;
}

.chat-send {
  background: #672c83;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.chat-send:hover {
  background: #7a3799;
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ 移动端适配 ============ */
@media (max-width: 768px) {
  #chat-container {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
  }

  .chat-window {
    border-radius: 0;
  }

  .message {
    max-width: 90%;
  }
}
