/* ========================================
   AI 智能助手 - 样式
   上海三安档案管理网站
   ======================================== */

/* AI 助手浮动按钮 */
.ai-assistant-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0650A0, #0a6ed1);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(6, 80, 160, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  z-index: 9998;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: ai-pulse 2s infinite;
}

.ai-assistant-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(6, 80, 160, 0.5);
}

@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(6, 80, 160, 0.35); }
  50% { box-shadow: 0 4px 28px rgba(6, 80, 160, 0.55); }
}

/* AI 助手聊天窗口 */
.ai-chat-widget {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 480px;
  max-width: calc(100vw - 48px);
  height: 680px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.ai-chat-widget.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* 头部 */
.ai-chat-header {
  background: linear-gradient(135deg, #0650A0, #0a6ed1);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.ai-header-info h6 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.ai-header-info small {
  font-size: 11px;
  opacity: 0.85;
}

.ai-header-status {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf50;
  margin-right: 4px;
  animation: status-blink 1.5s infinite;
}

@keyframes status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ai-chat-header-actions {
  display: flex;
  gap: 6px;
}

.ai-chat-header-actions button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ai-chat-header-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 消息区域 */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
  width: 5px;
}

.ai-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

/* 消息气泡 */
.ai-message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: msg-slide-in 0.3s ease;
}

@keyframes msg-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.ai-message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ai-message.bot .ai-message-avatar {
  background: #e3f0fc;
  color: #0650A0;
}

.ai-message.user .ai-message-avatar {
  background: #0650A0;
  color: #fff;
}

.ai-message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.ai-message.bot .ai-message-bubble {
  background: #fff;
  color: #333;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ai-message.user .ai-message-bubble {
  background: #0650A0;
  color: #fff;
  border-top-right-radius: 4px;
}

.ai-message-time {
  font-size: 10px;
  color: #999;
  margin-top: 4px;
  text-align: right;
}

.ai-message.user .ai-message-time {
  color: rgba(255, 255, 255, 0.7);
}

/* 打字动画 */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.ai-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #bbb;
  animation: typing-bounce 1.4s infinite;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* 流式输出光标 */
.ai-stream-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.1em;
  background: #0650A0;
  animation: ai-caret-blink 1s step-end infinite;
}

@keyframes ai-caret-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 底部区域 */
.ai-chat-footer {
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.ai-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-input-group input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
  background: #f8f9fa;
}

.ai-input-group input:focus {
  border-color: #0650A0;
  background: #fff;
}

.ai-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #0650A0;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  background: #0a6ed1;
}

.ai-send-btn:active {
  transform: scale(0.92);
}

.ai-send-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* 快捷建议 */
.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ai-suggestions button {
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 16px;
  background: #f0f4ff;
  color: #0650A0;
  border: 1px solid #d6e4ff;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.ai-suggestions button:hover {
  background: #0650A0;
  color: #fff;
  border-color: #0650A0;
}

/* 置信度标签 */
.ai-confidence-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
}

.ai-confidence-high {
  background: #e8f5e9;
  color: #2e7d32;
}

.ai-confidence-medium {
  background: #fff3e0;
  color: #e65100;
}

.ai-confidence-low {
  background: #fce4ec;
  color: #c62828;
}

/* 引文来源标签 */
.ai-source-tag {
  font-size: 11px;
  color: #0650A0;
  background: #e8f0fe;
  padding: 3px 10px;
  border-radius: 10px;
  margin-top: 6px;
  display: inline-block;
}
.ai-source-tag i {
  font-size: 10px;
  margin-right: 3px;
}

/* 消息气泡内 Markdown 支持 */
.ai-message-bubble strong {
  color: #0650A0;
}
.ai-message-bubble ul {
  margin: 4px 0;
  padding-left: 18px;
}
.ai-message-bubble li {
  line-height: 1.7;
  list-style-type: disc;
}

/* 响应式 */
@media (max-width: 520px) {
  .ai-chat-widget {
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    right: 12px;
    bottom: 90px;
    border-radius: 12px;
  }

  .ai-assistant-btn {
    right: 12px;
    bottom: 16px;
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
}
