/* ══════════════════════════════════════════════════════
   CYBERNEX CHATBOT — chatbot.css
   Matches existing CyberNexSolution design system exactly
   ══════════════════════════════════════════════════════ */

/* ── Launcher bubble ─────────────────────────────────── */
#cnx-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cyan);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0,229,160,0.45), 0 2px 8px rgba(0,0,0,0.3);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  outline: none;
}
#cnx-chat-launcher:hover {
  transform: translateY(-3px) scale(1.07);
  box-shadow: 0 14px 40px rgba(0,229,160,0.6), 0 4px 12px rgba(0,0,0,0.3);
}
#cnx-chat-launcher:active { transform: scale(0.96); }

#cnx-chat-launcher .cnx-icon-chat,
#cnx-chat-launcher .cnx-icon-close {
  position: absolute;
  transition: all 0.28s cubic-bezier(0.4,0,0.2,1);
}
#cnx-chat-launcher .cnx-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}
#cnx-chat-launcher.open .cnx-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}
#cnx-chat-launcher.open .cnx-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Unread badge */
#cnx-unread-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-base);
  animation: cnxBadgePop 0.3s cubic-bezier(0.4,0,0.2,1) both;
  transition: opacity 0.2s;
}
#cnx-unread-badge.hidden { opacity: 0; pointer-events: none; }
@keyframes cnxBadgePop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Chat window ─────────────────────────────────────── */
#cnx-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 370px;
  max-height: 580px;
  background: #0d1820;
  border: 1px solid rgba(0,229,160,0.22);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,229,160,0.08);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.32s cubic-bezier(0.4,0,0.2,1);
  transform-origin: bottom right;
}
#cnx-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────── */
#cnx-chat-header {
  background: linear-gradient(135deg, #0a1c14 0%, #0d2018 100%);
  border-bottom: 1px solid rgba(0,229,160,0.15);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cnx-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00e5a0, #00c484);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(0,229,160,0.4);
}
.cnx-header-info { flex: 1; min-width: 0; }
.cnx-header-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e8f4f0;
  letter-spacing: 0.01em;
}
.cnx-header-status {
  font-size: 0.72rem;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.cnx-status-dot {
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--cyan);
  animation: cnxPulse 2s infinite;
}
@keyframes cnxPulse {
  0%,100% { box-shadow: 0 0 4px var(--cyan); }
  50% { box-shadow: 0 0 10px var(--cyan), 0 0 20px rgba(0,229,160,0.3); }
}
.cnx-header-close {
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: 8px;
  color: #8aafc0;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  transition: all 0.2s;
}
.cnx-header-close:hover { background: rgba(255,255,255,0.12); color: #e8f4f0; }

/* ── Quick action chips ──────────────────────────────── */
#cnx-quick-actions {
  padding: 10px 14px 4px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: #0d1820;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cnx-chip {
  background: rgba(0,229,160,0.08);
  border: 1px solid rgba(0,229,160,0.2);
  color: var(--cyan);
  font-size: 0.71rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: system-ui, 'Segoe UI', sans-serif;
}
.cnx-chip:hover {
  background: rgba(0,229,160,0.16);
  border-color: rgba(0,229,160,0.45);
  transform: translateY(-1px);
}

/* ── Messages area ───────────────────────────────────── */
#cnx-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#cnx-messages::-webkit-scrollbar { width: 4px; }
#cnx-messages::-webkit-scrollbar-track { background: transparent; }
#cnx-messages::-webkit-scrollbar-thumb { background: rgba(0,229,160,0.2); border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────────── */
.cnx-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: cnxMsgIn 0.28s cubic-bezier(0.4,0,0.2,1) both;
}
@keyframes cnxMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cnx-msg.bot { align-self: flex-start; }
.cnx-msg.user { align-self: flex-end; }

.cnx-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.855rem;
  line-height: 1.6;
  font-family: system-ui, 'Segoe UI', sans-serif;
}
.cnx-msg.bot .cnx-bubble {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #d4e8e0;
  border-bottom-left-radius: 5px;
}
.cnx-msg.user .cnx-bubble {
  background: linear-gradient(135deg, #00c484, #00a870);
  color: #021a10;
  font-weight: 600;
  border-bottom-right-radius: 5px;
}

.cnx-bubble a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cnx-bubble a:hover { color: #7dd3f8; }

.cnx-bubble ul { margin: 6px 0 2px 16px; }
.cnx-bubble li { margin-bottom: 3px; }

.cnx-msg-time {
  font-size: 0.64rem;
  color: rgba(138,175,192,0.5);
  margin-top: 4px;
  padding: 0 2px;
}
.cnx-msg.user .cnx-msg-time { text-align: right; }

/* Typing indicator */
.cnx-typing-bubble {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  align-self: flex-start;
  animation: cnxMsgIn 0.28s ease both;
}
.cnx-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--cyan);
  border-radius: 50%;
  opacity: 0.4;
  animation: cnxTypingBounce 1.2s infinite;
}
.cnx-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cnx-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes cnxTypingBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input row ───────────────────────────────────────── */
#cnx-chat-footer {
  padding: 12px 14px;
  background: #0a1318;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  gap: 9px;
  align-items: flex-end;
  flex-shrink: 0;
}
#cnx-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(0,229,160,0.15);
  border-radius: 12px;
  color: #d4e8e0;
  font-size: 0.855rem;
  font-family: system-ui, 'Segoe UI', sans-serif;
  padding: 10px 14px;
  outline: none;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  transition: border-color 0.2s;
  line-height: 1.5;
}
#cnx-input::placeholder { color: rgba(138,175,192,0.45); }
#cnx-input:focus { border-color: rgba(0,229,160,0.45); }

#cnx-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--cyan);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,229,160,0.35);
}
#cnx-send-btn:hover { background: #00c484; transform: scale(1.05); }
#cnx-send-btn:active { transform: scale(0.96); }
#cnx-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#cnx-send-btn svg { color: #021a10; }

/* ── Disclaimer ──────────────────────────────────────── */
#cnx-disclaimer {
  text-align: center;
  font-size: 0.62rem;
  color: rgba(138,175,192,0.35);
  padding: 5px 14px 10px;
  background: #0a1318;
}

/* ── Mobile responsive ───────────────────────────────── */
@media (max-width: 480px) {
  #cnx-chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    max-height: 70vh;
    border-radius: 18px;
  }
  #cnx-chat-launcher { right: 18px; bottom: 18px; }
}
