/* ===== AI 助手 ===== */

/* 浮动按钮 */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 900;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  color: #7c3aed;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .35s cubic-bezier(.4,0,.2,1);
  font-size: 26px;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.2);
  background: #fff;
}
.ai-fab.active {
  background: #fff;
  transform: rotate(0deg) scale(1);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}
/* 滚动时自动隐藏 */
.ai-fab.fab-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.8);
}

/* 对话面板 */
.ai-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 901;
  width: 400px;
  max-height: 600px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,.15), 0 0 0 1px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.96);
  transition: all .35s cubic-bezier(.4,0,.2,1);
}
.ai-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* header */
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
}
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.ai-panel-logo {
  font-size: 20px;
}
.ai-panel-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s;
}
.ai-panel-close:hover {
  background: rgba(255,255,255,.3);
}

/* chat body */
.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 420px;
  scroll-behavior: smooth;
}
.ai-chat-body::-webkit-scrollbar { width: 5px; }
.ai-chat-body::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }

/* messages */
.ai-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 100%;
}
.ai-msg-user {
  justify-content: flex-end;
}
.ai-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  max-width: 85%;
  word-break: break-word;
}
.ai-msg-user-bubble {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg-bot-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.ai-msg-bot-bubble strong {
  color: #7c3aed;
  font-weight: 600;
}
.ai-inline-link {
  color: #7c3aed;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* typing animation */
.ai-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 18px;
}
.ai-typing span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: ai-dot-bounce .6s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot-bounce {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50% { transform: translateY(-5px); opacity: 1; }
}

/* quick questions */
.ai-quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 8px;
}
.ai-quick-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-size: 12.5px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.ai-quick-btn:hover {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
  transform: translateY(-1px);
}

/* recommendation cards */
.ai-cards-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 4px 38px;
}
.ai-rec-card {
  display: block;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  text-decoration: none;
  color: #1e293b;
  transition: all .2s;
}
.ai-rec-card:hover {
  border-color: #c4b5fd;
  box-shadow: 0 2px 12px rgba(124,58,237,.1);
  transform: translateY(-1px);
}
.ai-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-card-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: contain;
  flex-shrink: 0;
}
.ai-card-emoji {
  font-size: 18px;
  flex-shrink: 0;
}
.ai-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.ai-card-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-card-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-type-tool { background: #ede9fe; color: #7c3aed; }
.ai-type-paper { background: #dbeafe; color: #2563eb; }
.ai-type-article { background: #d1fae5; color: #059669; }

.ai-card-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.ai-card-stars {
  font-size: 11px;
  color: #94a3b8;
}
.ai-card-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fef3c7;
  color: #b45309;
}

/* input area */
.ai-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}
.ai-input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  outline: none;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  color: #1e293b;
}
.ai-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, .1);
}
.ai-input::placeholder { color: #94a3b8; }
.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
}
.ai-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(124,58,237,.3);
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .ai-fab {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 22px;
    opacity: 0.85;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }
  .ai-fab:hover {
    opacity: 1;
  }
  .ai-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
  .ai-chat-body {
    max-height: 60vh;
  }
  .ai-cards-wrap {
    padding-left: 0;
  }
}
