/* ============================================================
   NEXUS v2 — bolinha orbital + chat
   ------------------------------------------------------------
   • O botão agora é uma esfera brilhante que flutua em círculos
     (360° no plano + sobe/desce) chamando atenção sem abrir nada.
   • O painel SÓ abre no clique e fecha de verdade:
     .nexus-panel[hidden] { display:none } — era isso que fazia
     o chat "não fechar" na versão antiga.
   ============================================================ */

.nexus-root {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

/* ---------- A ESFERA ---------- */
.nexus-fab {
  position: relative;
  width: 62px;
  height: 62px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #04120a;
  font-size: 1.35rem;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85), transparent 34%),
    radial-gradient(circle at 60% 65%, var(--green, #62ff4d) 0%, #1fae14 55%, #0a3d10 100%);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(98, 255, 77, 0.45),
    inset 0 -6px 14px rgba(0, 0, 0, 0.35);
  animation:
    nexusOrbit 7s ease-in-out infinite,
    nexusGlow 2.8s ease-in-out infinite;
  transition: transform 0.25s ease;
}

.nexus-fab:hover {
  animation-play-state: paused, running;
  transform: scale(1.12);
}

.nexus-fab:active {
  transform: scale(0.96);
}

/* anel de pulso ao redor da esfera */
.nexus-fab::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(98, 255, 77, 0.5);
  animation: nexusPing 2.8s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}

/* segundo anel, defasado */
.nexus-fab::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(98, 255, 77, 0.35);
  animation: nexusPing 2.8s cubic-bezier(0, 0, 0.2, 1) infinite;
  animation-delay: 1.4s;
  pointer-events: none;
}

.nexus-fab-icon {
  display: grid;
  place-items: center;
  animation: nexusSpin 9s linear infinite;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

.nexus-fab-label {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: rgba(8, 14, 10, 0.92);
  border: 1px solid rgba(98, 255, 77, 0.35);
  color: var(--text, #f5f7f8);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.nexus-fab:hover .nexus-fab-label {
  opacity: 1;
}

/* movimento orbital: círculo horizontal 360° + flutuação vertical */
@keyframes nexusOrbit {
  0%   { transform: translate(0px, 0px); }
  12%  { transform: translate(-7px, -6px); }
  25%  { transform: translate(-10px, 0px); }
  37%  { transform: translate(-7px, 6px); }
  50%  { transform: translate(0px, 9px); }
  62%  { transform: translate(7px, 6px); }
  75%  { transform: translate(10px, 0px); }
  87%  { transform: translate(7px, -6px); }
  100% { transform: translate(0px, 0px); }
}

@keyframes nexusGlow {
  0%, 100% {
    box-shadow:
      0 12px 30px rgba(0, 0, 0, 0.55),
      0 0 20px rgba(98, 255, 77, 0.35),
      inset 0 -6px 14px rgba(0, 0, 0, 0.35);
  }
  50% {
    box-shadow:
      0 12px 30px rgba(0, 0, 0, 0.55),
      0 0 40px rgba(98, 255, 77, 0.65),
      inset 0 -6px 14px rgba(0, 0, 0, 0.35);
  }
}

@keyframes nexusPing {
  0%   { transform: scale(1); opacity: 0.8; }
  80%, 100% { transform: scale(1.55); opacity: 0; }
}

@keyframes nexusSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* quando o chat está aberto, a esfera fica quieta */
.nexus-root.is-open .nexus-fab {
  animation: nexusGlow 2.8s ease-in-out infinite;
}

.nexus-root.is-open .nexus-fab::before,
.nexus-root.is-open .nexus-fab::after {
  animation: none;
  opacity: 0;
}

/* ---------- PAINEL DO CHAT ---------- */
.nexus-panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 40px));
  height: min(540px, calc(100vh - 130px));
  border: 1px solid rgba(98, 255, 77, 0.25);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, #0c1210 0%, #080b0d 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 30px rgba(98, 255, 77, 0.08);
  transform-origin: bottom right;
  animation: nexusPop 0.28s cubic-bezier(0.22, 1.1, 0.36, 1) both;
}

/* A CORREÇÃO: painel escondido fica escondido de verdade */
.nexus-panel[hidden] {
  display: none !important;
}

@keyframes nexusPop {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.nexus-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(98, 255, 77, 0.05);
}

.nexus-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green, #62ff4d);
  box-shadow: 0 0 10px rgba(98, 255, 77, 0.8);
  animation: nexusGlowDot 2s ease-in-out infinite;
}

@keyframes nexusGlowDot {
  0%, 100% { box-shadow: 0 0 6px rgba(98, 255, 77, 0.5); }
  50% { box-shadow: 0 0 14px rgba(98, 255, 77, 0.95); }
}

.nexus-header-text {
  display: grid;
  line-height: 1.25;
}

.nexus-header-text strong {
  font-size: 0.95rem;
  color: var(--text, #f5f7f8);
}

.nexus-header-text small {
  color: var(--muted, #aeb5bb);
  font-size: 0.74rem;
}

.nexus-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: transparent;
  color: var(--muted, #aeb5bb);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.nexus-close:hover {
  color: var(--text, #f5f7f8);
  border-color: rgba(255, 255, 255, 0.35);
  transform: rotate(90deg);
}

.nexus-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.nexus-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: nexusMsgIn 0.25s ease both;
}

@keyframes nexusMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nexus-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text, #f5f7f8);
  border-bottom-left-radius: 5px;
}

.nexus-msg.user {
  align-self: flex-end;
  background: rgba(98, 255, 77, 0.14);
  border: 1px solid rgba(98, 255, 77, 0.3);
  color: var(--text, #f5f7f8);
  border-bottom-right-radius: 5px;
}

.nexus-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 20px;
}

.nexus-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green, #62ff4d);
  opacity: 0.4;
  animation: nexusTyping 1.1s ease-in-out infinite;
}

.nexus-typing span:nth-child(2) { animation-delay: 0.16s; }
.nexus-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes nexusTyping {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-4px); }
}

.nexus-chips {
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nexus-chips::-webkit-scrollbar {
  display: none;
}

.nexus-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted, #aeb5bb);
  font-size: 0.76rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.nexus-chip:hover {
  border-color: rgba(98, 255, 77, 0.5);
  color: var(--text, #f5f7f8);
  background: rgba(98, 255, 77, 0.08);
}

.nexus-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nexus-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 0.88rem;
  color: var(--text, #f5f7f8);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.nexus-form input:focus {
  border-color: rgba(98, 255, 77, 0.55);
  box-shadow: 0 0 0 3px rgba(98, 255, 77, 0.12);
}

.nexus-send {
  width: 42px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--green, #62ff4d), #24c216);
  color: #04120a;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.nexus-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(98, 255, 77, 0.3);
}

@media (max-width: 560px) {
  .nexus-root {
    right: 16px;
    bottom: 16px;
  }

  .nexus-panel {
    width: calc(100vw - 32px);
    height: min(520px, calc(100vh - 110px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .nexus-fab,
  .nexus-fab::before,
  .nexus-fab::after,
  .nexus-fab-icon {
    animation: none;
  }
}
