/* 大一CMS - AI 智能问答浮动组件样式 */
#ai-chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.ai-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #4f7cff, #3a5bdb);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(58, 91, 219, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
.ai-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(58, 91, 219, .55);
}

.ai-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(10px) scale(.98);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.ai-panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.ai-panel-header {
  background: linear-gradient(135deg, #4f7cff, #3a5bdb);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-title { font-weight: 600; font-size: 15px; }
.ai-title-wrap { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ai-model-badge {
  display: inline-block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  color: rgba(255, 255, 255, .9);
  background: rgba(255, 255, 255, .18);
  border-radius: 6px;
  padding: 2px 8px;
  align-self: flex-start;
}
.ai-model-badge[hidden] { display: none; }
.ai-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f5f7fb;
}
.ai-msg { display: flex; margin-bottom: 12px; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-bot { justify-content: flex-start; }
.ai-bubble {
  max-width: 80%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-msg-user .ai-bubble {
  background: #4f7cff;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.ai-msg-bot .ai-bubble {
  background: #fff;
  color: #222;
  border: 1px solid #e6e9f0;
  border-bottom-left-radius: 3px;
}

.ai-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  border-radius: 50%;
  background: #b9c0d4;
  animation: ai-blink 1.2s infinite both;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.ai-input-area {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #eef0f5;
  background: #fff;
}
.ai-input {
  flex: 1;
  resize: none;
  border: 1px solid #dfe3ec;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
  max-height: 120px;
  font-family: inherit;
}
.ai-input:focus { border-color: #4f7cff; }
.ai-send {
  border: none;
  background: #4f7cff;
  color: #fff;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 14px;
  cursor: pointer;
}
.ai-send:disabled, .ai-input:disabled { opacity: .6; cursor: not-allowed; }

/* ===== 站内知识库参考来源（回答下方的溯源链接） ===== */
.ai-msg-bot.ai-has-src { flex-direction: column; align-items: flex-start; }
.ai-sources {
  max-width: 80%;
  margin-top: 6px;
  padding: 8px 10px;
  background: #eef3ff;
  border: 1px solid #dde6ff;
  border-radius: 10px;
}
.ai-sources-title {
  font-size: 12px;
  color: #7a86a8;
  margin-bottom: 4px;
}
.ai-source-item {
  display: block;
  font-size: 12px;
  line-height: 1.7;
  color: #3a5bdb;
  text-decoration: none;
  word-break: break-word;
}
.ai-source-item:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .ai-panel { width: calc(100vw - 32px); height: 70vh; }
  .ai-sources { max-width: 92%; }
}
