/* Blog RAG search — floating widget + citation cards.
   Place in your theme's css and reference it from layout.ejs. */

#rag-fab {
  position: fixed;
  right: 50px;
  bottom: 50px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #aa4b6b;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  transition: transform 0.15s ease;
}
#rag-fab:hover {
  transform: scale(1.08);
}

.rag-panel {
  position: fixed;
  right: 50px;
  bottom: 50px;
  width: 360px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  z-index: 9999;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1f2937;
}
.rag-panel.rag-hidden {
  display: none;
}

.rag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #aa4b6b;
  color: #fff;
  font-weight: 600;
}
.rag-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.rag-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rag-clear {
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  padding: 3px 4px;
}
.rag-clear:hover {
  text-decoration: underline;
}

.rag-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rag-msg {
  max-width: 92%;
  padding: 8px 11px;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 14px;
  word-break: break-word;
}
.rag-msg.user {
  align-self: flex-end;
  background: #aa4b6b;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.rag-msg.bot {
  align-self: flex-start;
  background: #f3f4f6;
  border-bottom-left-radius: 4px;
}
.rag-loading {
  opacity: 0.6;
}
.rag-streaming::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  color: #aa4b6b;
  animation: rag-caret 0.8s steps(2, start) infinite;
}
@keyframes rag-caret {
  50% { opacity: 0; }
}
.rag-stream-citations {
  width: 100%;
}

.rag-answer {
  white-space: normal;
}

.rag-cites {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 8px;
}
.rag-cites-head {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.rag-cite {
  display: block;
  text-decoration: none;
  color: #1f2937;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
}
.rag-cite:hover {
  border-color: #aa4b6b;
}
.rag-cite-title {
  font-weight: 500;
}
.rag-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: #aa4b6b;
  border: 1px solid rgba(170, 75, 107, 0.25);
  border-radius: 6px;
  padding: 0 5px;
}
.rag-tag-web {
  color: #059669;
  border-color: #a7f3d0;
}
.rag-snippet {
  display: block;
  color: #6b7280;
  margin-top: 2px;
}
.rag-fallback {
  color: #b45309;
}
.rag-error {
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.6;
}

.rag-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
}
.rag-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}
.rag-input:focus {
  border-color: #aa4b6b;
}
.rag-send {
  border: none;
  background: #aa4b6b;
  color: #fff;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-size: 14px;
}
.rag-send:disabled {
  cursor: wait;
  opacity: 0.65;
}

/* Mobile: bottom sheet */
@media (max-width: 768px) {
  .rag-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 75vh;
    border-radius: 16px 16px 0 0;
  }
  #rag-fab {
    right: 50px;
    bottom: 50px;
  }
}

/* Welcome / 开场白卡片 */
.rag-welcome {
  background: #faf5f7;
  border: 1px solid #f3e3ea;
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #374151;
}
.rag-welcome-badge {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 2px;
}
.rag-welcome-title {
  font-weight: 600;
  font-size: 15px;
  color: #111827;
  margin-bottom: 6px;
}
.rag-welcome-desc {
  margin-bottom: 4px;
}
.rag-welcome-author {
  background: #fff;
  border-left: 3px solid #aa4b6b;
  padding: 7px 9px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.rag-welcome-topics {
  margin-bottom: 10px;
}
.rag-welcome-suggest {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.rag-welcome-suggest-head {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}
.rag-suggest {
  text-align: left;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: #374151;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.rag-suggest:hover {
  border-color: #aa4b6b;
  background: #fdf2f8;
}
.rag-suggest:active {
  transform: scale(0.98);
}
.rag-welcome-about {
  display: inline-block;
  margin-top: 2px;
  color: #aa4b6b;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.rag-welcome-about:hover {
  text-decoration: underline;
}
