/* ============================================================
   KDN STONES — AI Export Lead Qualifier Chatbot
   ============================================================ */

/* ─── TRIGGER BUTTON ────────────────────────────────── */
#kdn-chat-trigger {
  position: fixed;
  bottom: 88px;
  right: 28px;
  z-index: 800;
  width: 60px;
  height: 60px;
  background: var(--charcoal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
  cursor: pointer;
  border: none;
  transition: all 0.3s var(--ease-out);
  animation: chatPulse 3s ease-in-out 5s 3;
}
#kdn-chat-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
#kdn-chat-trigger svg { width: 26px; height: 26px; fill: var(--white); }
.chat-trigger-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #e53e3e;
  color: white;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  border: 2px solid white;
  animation: badgePop 0.3s ease 2s both;
}
@keyframes badgePop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}
@keyframes chatPulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(0,0,0,0.25); }
  50% { box-shadow: 0 4px 32px rgba(46,46,46,0.55), 0 0 0 12px rgba(46,46,46,0.08); }
}

/* ─── CHAT WINDOW ───────────────────────────────────── */
#kdn-chatbot {
  position: fixed;
  bottom: 164px;
  right: 28px;
  z-index: 900;
  width: 360px;
  max-height: 580px;
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s var(--ease-out);
  transform-origin: bottom right;
}
#kdn-chatbot.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── HEADER ─────────────────────────────────────────── */
.chat-header {
  background: var(--charcoal);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  font-family: var(--font-label);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.05em;
}
.chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: statusPulse 2s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.chat-close {
  color: rgba(255,255,255,0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  background: none;
  border: none;
  line-height: 1;
}
.chat-close:hover { color: white; }

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

.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgIn 0.3s var(--ease-out) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg.bot { flex-direction: row; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--charcoal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: white;
  flex-shrink: 0;
}
.msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.875rem;
  line-height: 1.6;
}
.msg.bot .msg-bubble {
  background: var(--white);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.msg.user .msg-bubble {
  background: var(--charcoal);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-time {
  font-size: 0.65rem;
  color: var(--silver);
  margin-top: 3px;
  padding: 0 4px;
}
.msg.bot .msg-time { text-align: left; }
.msg.user .msg-time { text-align: right; }

/* Quick replies */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  background: #FAFAFA;
}
.quick-reply-btn {
  padding: 7px 14px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--charcoal);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-body);
  font-weight: 500;
  white-space: nowrap;
}
.quick-reply-btn:hover {
  background: var(--charcoal);
  color: white;
  border-color: var(--charcoal);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: var(--white);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--silver-l);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ─── INPUT AREA ─────────────────────────────────────── */
.chat-input-area {
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--lightgrey);
  border: 1px solid transparent;
  border-radius: 24px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
  color: var(--text);
}
#chat-input:focus { border-color: var(--silver-l); background: var(--white); }
#chat-input::placeholder { color: var(--silver); }
#chat-send {
  width: 38px; height: 38px;
  background: var(--charcoal);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
#chat-send:hover { background: var(--charcoal-2); transform: scale(1.05); }
#chat-send svg { width: 16px; height: 16px; fill: white; }

/* ─── FOOTER NOTE ────────────────────────────────────── */
.chat-footer-note {
  text-align: center;
  font-size: 0.65rem;
  color: var(--silver);
  padding: 6px;
  background: var(--white);
  border-top: 1px solid var(--border);
}

/* ─── MOBILE ─────────────────────────────────────────── */
@media (max-width: 480px) {
  #kdn-chatbot {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    max-height: 70vh;
  }
  #kdn-chat-trigger { right: 16px; bottom: 80px; }
}
