/* Nexoria Lab — RAG Chat Widget
   Scoped entirely under .nx-chat-root / .nx- classes so it can't collide
   with App.jsx's own classnames (card, btn, nav-links, etc). */

.nx-chat-root {
  --nx-accent: #f5a623;
  --nx-bg: #0c0c0e;
  --nx-panel: #141416;
  --nx-border: #26262a;
  --nx-text: #f2f2f0;
  --nx-text-dim: #9a9a9f;
  font-family: -apple-system, "Segoe UI", Inter, system-ui, sans-serif;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999; /* stays above modals/toasts regardless of the site's own stacking */
}

.nx-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: var(--nx-accent);
  color: #14140f;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}
.nx-chat-toggle:hover {
  transform: scale(1.06);
}
.nx-chat-toggle:focus-visible,
.nx-chat-close:focus-visible,
.nx-chat-input:focus-visible {
  outline: 2px solid var(--nx-accent);
  outline-offset: 2px;
}

.nx-hex {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 700;
  clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0% 50%);
}
.nx-chat-toggle .nx-hex {
  font-size: 20px;
}
.nx-hex--sm {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  background: var(--nx-accent);
  color: #14140f;
  font-size: 13px;
}

.nx-chat-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: var(--nx-panel);
  border: 1px solid var(--nx-border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.nx-chat-panel[hidden] {
  display: none; /* without this, display:flex above wins over the hidden
                     attribute and the close button/icon silently does nothing */
}

.nx-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--nx-border);
  background: var(--nx-bg);
  flex-shrink: 0;
}
.nx-chat-title {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}
.nx-chat-title strong {
  color: var(--nx-text);
  font-size: 14px;
}
.nx-chat-subtitle {
  color: var(--nx-text-dim);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nx-chat-close {
  background: none;
  border: none;
  color: var(--nx-text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.nx-chat-close:hover {
  color: var(--nx-text);
  background: var(--nx-border);
}

.nx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nx-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.nx-msg--bot {
  align-items: flex-start;
  align-self: flex-start;
}
.nx-msg--user {
  align-items: flex-end;
  align-self: flex-end;
}

.nx-bubble {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.nx-msg--bot .nx-bubble {
  background: #1d1d20;
  color: var(--nx-text);
  border-bottom-left-radius: 4px;
}
.nx-msg--user .nx-bubble {
  background: var(--nx-accent);
  color: #14140f;
  border-bottom-right-radius: 4px;
}

.nx-sources {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--nx-text-dim);
  padding: 0 2px;
}
.nx-badge {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nx-accent);
  margin-bottom: 3px;
  padding: 0 2px;
}

.nx-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 13px 13px;
}
.nx-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--nx-text-dim);
  animation: nx-bounce 1.2s infinite ease-in-out;
}
.nx-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.nx-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes nx-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .nx-typing span {
    animation: none;
    opacity: 0.8;
  }
}

.nx-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--nx-border);
  background: var(--nx-bg);
  flex-shrink: 0;
}
.nx-chat-input {
  flex: 1;
  min-width: 0;
  background: #1a1a1d;
  border: 1px solid var(--nx-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--nx-text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.nx-chat-input::placeholder {
  color: var(--nx-text-dim);
}
.nx-chat-input:focus {
  border-color: var(--nx-accent);
}
.nx-chat-send {
  width: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  border: none;
  background: var(--nx-accent);
  color: #14140f;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.nx-chat-send:hover {
  filter: brightness(1.05);
}

@media (max-width: 480px) {
  .nx-chat-root {
    right: 16px;
    bottom: 16px;
  }
  .nx-chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 110px);
    right: -8px;
  }
}
