/* =====================================================
   NEXILENSE AI CHATBOT — CSS
   Matches Nexilense design system exactly
   ===================================================== */

/* ── VARIABLES ──────────────────────────────────────── */
#nx-chatbot-wrap {
  --nc-ink:      #020409;
  --nc-ink1:     #070A14;
  --nc-ink2:     #0B0F1E;
  --nc-el:       #00CCFF;
  --nc-elg:      rgba(0,204,255,0.25);
  --nc-eld:      rgba(0,204,255,0.1);
  --nc-elb:      rgba(0,204,255,0.2);
  --nc-pl:       #8B5CF6;
  --nc-plg:      rgba(139,92,246,0.3);
  --nc-mint:     #00FFB3;
  --nc-white:    #F2F4FF;
  --nc-w60:      rgba(242,244,255,0.6);
  --nc-w30:      rgba(242,244,255,0.3);
  --nc-border:   rgba(255,255,255,0.07);
  --nc-glass:    rgba(7,10,20,0.92);
  --nc-surf:     rgba(255,255,255,0.04);
  --nc-ex:       cubic-bezier(0.16,1,0.3,1);
  font-family:   'Outfit', 'Space Grotesk', sans-serif;
}

/* ── TOGGLE BUTTON ───────────────────────────────────── */
#nx-chat-toggle {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 9998;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--nc-pl), var(--nc-el));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px var(--nc-plg), 0 0 0 0 var(--nc-elg);
  transition: transform 0.3s var(--nc-ex), box-shadow 0.3s;
  animation: nc-pulse 3s ease-in-out infinite;
}
@keyframes nc-pulse {
  0%, 100% { box-shadow: 0 8px 32px var(--nc-plg), 0 0 0 0 var(--nc-elg); }
  50%       { box-shadow: 0 8px 32px var(--nc-plg), 0 0 0 8px rgba(0,204,255,0); }
}
#nx-chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px var(--nc-plg), 0 0 30px var(--nc-elg);
  animation: none;
}

/* Notification badge */
.nx-chat-notif {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FF5F57;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--nc-ink);
  animation: nc-bounce 1s ease-in-out 2s 3;
}
@keyframes nc-bounce {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.25); }
}

/* ── CHAT WINDOW ─────────────────────────────────────── */
#nx-chat-window {
  position: fixed;
  bottom: calc(5.5rem + 68px + 12px);
  right: 1.5rem;
  z-index: 9997;
  width: 360px;
  max-height: 580px;
  border-radius: 20px;
  background: var(--nc-ink1);
  border: 1px solid var(--nc-elb);
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 40px var(--nc-elg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s var(--nc-ex), opacity 0.4s var(--nc-ex);
}
#nx-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
/* Top gradient border */
#nx-chat-window::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--nc-pl), var(--nc-el), var(--nc-mint));
  animation: nc-border-anim 4s linear infinite;
  background-size: 300%;
}
@keyframes nc-border-anim {
  0%   { background-position: 0%; }
  100% { background-position: 300%; }
}

/* ── HEADER ──────────────────────────────────────────── */
.nx-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--nc-border);
  flex-shrink: 0;
}
.nx-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nx-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--nc-pl), var(--nc-el));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.05em;
  position: relative;
  flex-shrink: 0;
}
.nx-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--nc-mint);
  border: 2px solid var(--nc-ink1);
  box-shadow: 0 0 8px rgba(0,255,179,0.6);
  animation: nc-blink 2s infinite;
}
@keyframes nc-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.nx-chat-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--nc-white);
  line-height: 1.2;
}
.nx-chat-status {
  font-size: 0.68rem;
  color: var(--nc-mint);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.05em;
}
.nx-chat-close-btn {
  background: var(--nc-surf);
  border: 1px solid var(--nc-border);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nc-w60);
  cursor: pointer;
  transition: all 0.25s;
  flex-shrink: 0;
}
.nx-chat-close-btn:hover {
  background: var(--nc-eld);
  border-color: var(--nc-elb);
  color: var(--nc-el);
}

/* ── MESSAGES ────────────────────────────────────────── */
.nx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.nx-chat-messages::-webkit-scrollbar { width: 4px; }
.nx-chat-messages::-webkit-scrollbar-track { background: transparent; }
.nx-chat-messages::-webkit-scrollbar-thumb { background: var(--nc-border); border-radius: 2px; }

.nx-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: nc-msg-in 0.4s var(--nc-ex) both;
}
@keyframes nc-msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.nx-msg-bot { flex-direction: row; }
.nx-msg-user { flex-direction: row-reverse; }

.nx-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--nc-pl), var(--nc-el));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.52rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.nx-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.nx-msg-bot .nx-msg-bubble {
  background: var(--nc-surf);
  border: 1px solid var(--nc-border);
  color: var(--nc-white);
  border-bottom-left-radius: 4px;
}
.nx-msg-bot .nx-msg-bubble strong {
  color: var(--nc-el);
}
.nx-msg-user .nx-msg-bubble {
  background: linear-gradient(135deg, var(--nc-pl), var(--nc-el));
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Quick reply chips */
.nx-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 0 36px;
}
.nx-chip {
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--nc-elb);
  background: var(--nc-eld);
  color: var(--nc-el);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}
.nx-chip:hover {
  background: var(--nc-el);
  color: var(--nc-ink);
  border-color: var(--nc-el);
}

/* ── TYPING INDICATOR ────────────────────────────────── */
.nx-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 16px 8px;
  animation: nc-msg-in 0.3s var(--nc-ex) both;
}
.nx-typing-dots {
  background: var(--nc-surf);
  border: 1px solid var(--nc-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.nx-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--nc-el);
  animation: nc-dot 1.2s ease-in-out infinite;
  opacity: 0.4;
}
.nx-typing-dots span:nth-child(1) { animation-delay: 0s; }
.nx-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.nx-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes nc-dot {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50%       { transform: translateY(-4px); opacity: 1; }
}

/* ── INPUT ───────────────────────────────────────────── */
.nx-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--nc-border);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}
#nx-chat-input {
  flex: 1;
  background: var(--nc-ink2);
  border: 1px solid var(--nc-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--nc-white);
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color 0.25s, box-shadow 0.25s;
}
#nx-chat-input::placeholder { color: var(--nc-w30); }
#nx-chat-input:focus {
  border-color: var(--nc-elb);
  box-shadow: 0 0 0 3px rgba(0,204,255,0.06);
}
#nx-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--nc-pl), var(--nc-el));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s, box-shadow 0.25s;
  box-shadow: 0 4px 16px var(--nc-plg);
}
#nx-chat-send:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px var(--nc-plg);
}
#nx-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── FOOTER ──────────────────────────────────────────── */
.nx-chat-footer {
  text-align: center;
  padding: 8px 16px 12px;
  font-size: 0.68rem;
  color: var(--nc-w30);
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.05em;
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.nx-chat-footer a {
  color: var(--nc-el);
  text-decoration: none;
  font-weight: 600;
}
.nx-chat-footer a:hover { opacity: 0.8; }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 480px) {
  #nx-chat-window {
    right: 1rem;
    left: 1rem;
    width: auto;
    bottom: calc(5.5rem + 68px + 8px);
  }
  #nx-chat-toggle {
    right: 1rem;
  }
}
