/* Widgets do backend (chat, busca, conteudo dinamico).
   Paleta identica ao site: fundo rgba(15,23,42,.95), borda rgba(148,163,255,.2),
   gradiente #4f46e5 -> #8b5cf6, texto #f4f5fb. */

/* ---------- busca na topbar ---------- */
/* Wrapper: terceira linha do flex-column da .topbar-inner, em fluxo estatico.
   Apenas o dropdown e posicionado (absolute, ancorado no wrapper). */
.rc-search {
  position: relative;
  width: min(320px, 100%);
}
.rc-search-input {
  width: 100%;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 255, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #f4f5fb;
  font-size: 0.85rem;
  outline: none;
}
.rc-search-input:focus {
  border-color: rgba(148, 163, 255, 0.5);
}
.rc-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(360px, 90vw);
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 255, 0.2);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  z-index: 200; /* acima da .topbar (100) */
  padding: 0.4rem;
}
.rc-search-item {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  text-decoration: none;
  color: #f4f5fb;
}
.rc-search-item.active,
.rc-search-item:hover {
  background: rgba(79, 70, 229, 0.25);
}
.rc-search-item-title {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}
.rc-search-item-section {
  display: inline-block;
  font-size: 0.7rem;
  color: #a5b4fc;
  margin-right: 0.5rem;
}
.rc-search-item-snippet {
  display: block;
  font-size: 0.78rem;
  opacity: 0.75;
  margin-top: 0.15rem;
}
.rc-search-empty {
  padding: 0.7rem;
  font-size: 0.85rem;
  opacity: 0.7;
}

/* ---------- chat flutuante ---------- */
.rc-chat-toggle {
  position: fixed;
  right: 1.4rem;
  bottom: 1.4rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 255, 0.2);
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  color: #f4f5fb;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 1100;
  box-shadow: 0 10px 30px rgba(79, 70, 229, 0.4);
}
.rc-chat-panel {
  position: fixed;
  right: 1.4rem;
  bottom: calc(1.4rem + 70px);
  width: 360px;
  height: min(520px, calc(100vh - 140px));
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 255, 0.2);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  z-index: 1100;
  overflow: hidden;
}
.rc-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 255, 0.15);
}
.rc-chat-title {
  font-weight: 600;
  font-size: 0.95rem;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.rc-chat-close {
  background: none;
  border: none;
  color: #f4f5fb;
  font-size: 1.3rem;
  cursor: pointer;
  opacity: 0.7;
}
.rc-chat-close:hover { opacity: 1; }
.rc-chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.rc-msg { display: flex; flex-direction: column; }
.rc-msg-user { align-items: flex-end; }
.rc-msg-assistant { align-items: flex-start; }
.rc-msg-bubble {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.rc-msg-user .rc-msg-bubble {
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  border-bottom-right-radius: 4px;
}
.rc-msg-assistant .rc-msg-bubble {
  background: rgba(148, 163, 255, 0.12);
  border-bottom-left-radius: 4px;
}
.rc-typing .rc-msg-bubble { opacity: 0.6; font-style: italic; }
.rc-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}
.rc-source-chip {
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 255, 0.3);
  color: #a5b4fc;
  text-decoration: none;
}
.rc-source-chip:hover { background: rgba(79, 70, 229, 0.25); }
.rc-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid rgba(148, 163, 255, 0.15);
}
.rc-chat-input {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 255, 0.2);
  background: rgba(15, 23, 42, 0.6);
  color: #f4f5fb;
  font-size: 0.88rem;
  outline: none;
}
.rc-chat-send {
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6);
  color: #f4f5fb;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ---------- conteudo dinamico ---------- */
.rc-loading {
  opacity: 0.55;
  position: relative;
}
.rc-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(100deg, transparent 30%, rgba(148, 163, 255, 0.08) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: rc-shimmer 1.2s linear infinite;
}
.rc-updated {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  opacity: 0.55;
  margin-top: 0.4rem;
}
.rc-item-link {
  font-size: 0.78rem;
  color: #a5b4fc;
}
.rc-item-extra {
  font-size: 0.78rem;
  opacity: 0.7;
  margin-top: 0.3rem;
}

@keyframes rc-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- responsivo ---------- */
@media (max-width: 480px) {
  .rc-chat-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    border-radius: 0;
  }
  .rc-chat-toggle {
    right: 1rem;
    bottom: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rc-loading::after { animation: none; }
  .rc-chat-toggle, .rc-chat-panel { transition: none; }
}
