/**
 * AI 智能助手 - 对话面板样式
 */
.ai-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed, #a855f7);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(79,70,229,.4);
  z-index: 9990;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .25s ease;
  animation: aiPulse 2s infinite;
}
.ai-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(79,70,229,.55);
}
.ai-chat-btn:active {
  transform: scale(.95);
}
@keyframes aiPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(79,70,229,.4); }
  50% { box-shadow: 0 4px 32px rgba(139,92,246,.7); }
}
.ai-chat-btn.hidden { display: none; }

/* 对话面板 */
.ai-panel {
  position: fixed;
  bottom: 90px; right: 24px;
  width: 420px;
  max-height: 640px;
  height: calc(100vh - 160px);
  min-height: 440px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 48px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  display: none;
  flex-direction: column;
  z-index: 9995;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  animation: aiSlideUp .3s ease;
}
.ai-panel.open { display: flex; }
@keyframes aiSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 面板头部 */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-radius: 16px 16px 0 0;
  flex-shrink: 0;
}
.ai-panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700;
}
.ai-panel-badge {
  font-size: 10px; background: rgba(255,255,255,.2);
  padding: 2px 8px; border-radius: 10px; font-weight: 500;
}
.ai-panel-actions { display: flex; gap: 4px; }
.ai-panel-actions button {
  width: 30px; height: 30px; border-radius: 8px;
  border: none; background: rgba(255,255,255,.15); color: #fff;
  font-size: 14px; cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.ai-panel-actions button:hover { background: rgba(255,255,255,.3); }

/* 对话消息区 */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}
.ai-messages::-webkit-scrollbar { width: 5px; }
.ai-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.ai-msg {
  display: flex; gap: 10px; max-width: 92%;
  animation: aiMsgIn .25s ease;
}
@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.ai-msg.ai { align-self: flex-start; }

.ai-msg-avatar {
  width: 34px; height: 34px; border-radius: 10px;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.ai-msg.user .ai-msg-avatar { background: #e0e7ff; }
.ai-msg.ai .ai-msg-avatar { background: #ede9fe; }

.ai-msg-content {
  padding: 10px 14px; border-radius: 14px;
  font-size: 13px; line-height: 1.6; word-break: break-word;
}
.ai-msg.user .ai-msg-content {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; border-bottom-right-radius: 4px;
}
.ai-msg.ai .ai-msg-content {
  background: #fff; color: #334155;
  border: 1px solid #e2e8f0; border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.ai-msg-content p { margin: 0 0 6px 0; }
.ai-msg-content p:last-child { margin-bottom: 0; }
.ai-msg-content code {
  background: rgba(0,0,0,.06); padding: 1px 5px;
  border-radius: 3px; font-size: 11px;
}
.ai-msg.user .ai-msg-content code { background: rgba(255,255,255,.2); }
.ai-msg-content ul, .ai-msg-content ol {
  margin: 4px 0; padding-left: 18px;
}
.ai-msg-content li { margin-bottom: 2px; }

.ai-msg-time {
  font-size: 10px; color: #94a3b8; margin-top: 2px; padding: 0 4px;
}

/* 打字指示器 */
.ai-typing { display: flex; gap: 4px; padding: 10px 14px; }
.ai-typing span {
  width: 7px; height: 7px; background: #94a3b8;
  border-radius: 50%; animation: aiDot 1.4s infinite both;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiDot {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}

/* 输入区 */
.ai-input-area {
  padding: 12px 16px; border-top: 1px solid #e2e8f0;
  display: flex; gap: 8px; background: #fff;
  flex-shrink: 0;
}
.ai-input-area textarea {
  flex: 1; padding: 10px 14px; border: 1.5px solid #e2e8f0;
  border-radius: 12px; font-size: 13px; resize: none;
  min-height: 40px; max-height: 100px; line-height: 1.5;
  font-family: inherit; outline: none;
  transition: border-color .2s;
}
.ai-input-area textarea:focus { border-color: #7c3aed; }
.ai-input-area textarea::placeholder { color: #94a3b8; font-size: 12px; }

.ai-send-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: none; background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; font-size: 18px; cursor: pointer;
  flex-shrink: 0; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  align-self: flex-end;
}
.ai-send-btn:hover { box-shadow: 0 2px 12px rgba(124,58,237,.35); }
.ai-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 快捷问题 */
.ai-quick-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0;
}
.ai-quick-btn {
  font-size: 11px; padding: 5px 12px; border-radius: 14px;
  border: 1px solid #e2e8f0; background: #fff; color: #475569;
  cursor: pointer; transition: all .2s; white-space: nowrap;
}
.ai-quick-btn:hover { border-color: #7c3aed; color: #7c3aed; background: #f5f3ff; }

/* 响应式 */
@media (max-width: 520px) {
  .ai-panel { width: calc(100vw - 32px); right: 16px; left: 16px; max-height: 70vh; }
  .ai-chat-btn { right: 12px; bottom: 16px; width: 48px; height: 48px; font-size: 20px; }
}
