/* ─── CHATBOT BUBBLE ──────────────────────────── */
#chatbot-bubble {
  position: fixed; bottom: 175px; right: 24px; z-index: 999;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, #0D47A1, #1976D2);
  color: white; display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 6px 28px rgba(13,71,161,0.5);
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  animation: popIn 0.5s 0.8s both;
}
#chatbot-bubble:hover { transform: scale(1.1); }

.cb-pulse {
  position: absolute; width: 100%; height: 100%; border-radius: 50%;
  background: rgba(13,71,161,0.4); animation: cbPulse 2s ease-out infinite;
}
@keyframes cbPulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.7); opacity: 0; }
}

#chat-unread {
  position: absolute; top: -4px; right: -4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #FF5722; color: white;
  font-size: 0.7rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white; animation: bounce 1s ease-in-out infinite alternate;
}
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-4px); } }

/* ─── CHATBOT WINDOW ──────────────────────────── */
#chatbot-window {
  position: fixed; bottom: 248px; right: 24px; z-index: 998;
  width: 360px; max-height: 520px;
  background: white; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(13,71,161,0.2), 0 8px 24px rgba(0,0,0,0.12);
  display: flex; flex-direction: column; overflow: hidden;
  transition: all 0.35s cubic-bezier(0.34,1.2,0.64,1);
  transform-origin: bottom right;
}
.chatbot-hidden {
  opacity: 0 !important;
  transform: scale(0.6) translateY(40px) !important;
  pointer-events: none !important;
}
.chatbot-visible {
  opacity: 1 !important;
  transform: scale(1) translateY(0) !important;
  pointer-events: all !important;
}

/* ─── CHAT HEADER ─────────────────────────────── */
.chat-header {
  background: linear-gradient(135deg, #0D47A1, #1565C0);
  padding: 16px 18px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; color: white;
  flex-shrink: 0;
}
.chat-name { font-size: 0.95rem; font-weight: 700; color: white; }
.chat-status { font-size: 0.75rem; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.online-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #4CAF50;
  box-shadow: 0 0 6px #4CAF50; animation: onlinePulse 2s ease-in-out infinite;
}
@keyframes onlinePulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

.chat-close {
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chat-close:hover { background: rgba(255,255,255,0.3); }

/* ─── CHAT MESSAGES ───────────────────────────── */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 12px; background: #F0F4FF;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(13,71,161,0.2); border-radius: 4px; }

.chat-date-divider {
  text-align: center; font-size: 0.72rem; color: #9CA3AF;
  font-weight: 600; position: relative;
}
.chat-date-divider::before, .chat-date-divider::after {
  content: ''; position: absolute; top: 50%; width: 30%;
  height: 1px; background: #E5E7EB;
}
.chat-date-divider::before { left: 0; }
.chat-date-divider::after { right: 0; }

.chat-msg { display: flex; gap: 8px; align-items: flex-end; }
.chat-msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #0D47A1, #1976D2);
  color: white; font-size: 0.6rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.chat-msg.user .msg-avatar { background: linear-gradient(135deg, #FF9800, #F57C00); }

.msg-bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px;
  font-size: 0.875rem; line-height: 1.6; word-break: break-word;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.chat-msg.bot .msg-bubble {
  background: white; color: #1F2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, #0D47A1, #1565C0);
  color: white; border-bottom-right-radius: 4px;
}

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; align-items: center; }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #9CA3AF;
  animation: typingDot 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 typingDot { 0%,60%,100% { transform:translateY(0); } 30% { transform:translateY(-6px); } }

/* Quick replies */
.chat-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0; }
.chat-quick-replies button {
  font-size: 0.78rem; font-weight: 600; color: #0D47A1;
  background: white; border: 1.5px solid rgba(13,71,161,0.25);
  padding: 6px 12px; border-radius: 100px; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.chat-quick-replies button:hover { background: #E3F2FD; border-color: #0D47A1; }

/* ─── CHAT INPUT ──────────────────────────────── */
.chat-input-area {
  display: flex; gap: 8px; padding: 12px 14px;
  background: white; border-top: 1px solid #E5E7EB; flex-shrink: 0;
}
.chat-input-area input {
  flex: 1; border: 1.5px solid #E5E7EB; border-radius: 100px;
  padding: 10px 16px; font-size: 0.875rem; font-family: inherit;
  outline: none; transition: border-color 0.2s; color: #1F2937;
}
.chat-input-area input:focus { border-color: #0D47A1; }
.chat-send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #0D47A1, #1565C0);
  color: white; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: all 0.2s; flex-shrink: 0;
}
.chat-send-btn:hover { transform: scale(1.08); }

/* ─── RESPONSIVE ──────────────────────────────── */
@media (max-width: 400px) {
  #chatbot-window { width: calc(100vw - 32px); right: 16px; bottom: 240px; }
  #chatbot-bubble { right: 16px; bottom: 168px; }
}
