/* ============================================
   CHATBOT CSS - Visitor Floating Chat Widget
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --primary: #0084ff;
  --primary-dark: #006fd6;
  --primary-light: #006fd6;
  --bg: #f5f7fb;
  --white: #ffffff;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --border: #e5e8ef;
  --bot-bubble: #f0f2f5;
  --user-bubble: #0084ff;
  --shadow: 0 8px 32px rgba(0, 132, 255, 0.18);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Plus Jakarta Sans', sans-serif;
}

/* ---- Floating Button ---- */
#chat-toggle-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 22px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  z-index: 9999;
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
#chat-toggle-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0, 132, 255, 0.28);
}
#chat-toggle-btn .btn-icon {
  font-size: 18px;
  line-height: 1;
}
#chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}
#chat-badge.show { display: flex; }

/* ---- Chat Window ---- */
#chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s;
  font-family: var(--font);
}
#chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#chat-header {
  background: linear-gradient(135deg, var(--primary) 0%, #0066cc 100%);
  color: #fff;
  padding: 16px 20px;
  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: 38px; height: 38px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.chat-header-text h3 { font-size: 15px; font-weight: 700; margin: 0; }
.chat-header-text span { font-size: 12px; opacity: 0.85; }
.status-dot {
  display: inline-block; width: 7px; height: 7px;
  background: #4ade80; border-radius: 50%; margin-right: 5px;
}
#chat-close-btn {
  background: rgba(255,255,255,0.15);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer;
  font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
#chat-close-btn:hover { background: rgba(255,255,255,0.3); }

/* Messages */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.bot  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot .bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 14px;
  background: var(--bot-bubble);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-indicator span {
  width: 7px; height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Footer */
#chat-footer {
  padding: 10px 16px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  outline: none;
  background: var(--bg);
  transition: border 0.2s;
  resize: none;
  overflow-y: auto;
  min-height: 42px;
  max-height: 130px;
  line-height: 1.5;
  display: block;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#chat-input::-webkit-scrollbar { width: 4px; }
#chat-input::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
#chat-input:focus { border-color: var(--primary); }
#chat-send-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
  margin-bottom: 1px;
}
#chat-send-btn:hover { background: var(--primary-dark); transform: scale(1.08); }
#chat-send-btn svg { width: 18px; height: 18px; display: block; }

/* ---- Mobile ---- */
@media (max-width: 480px) {
  #chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 80px;
    max-height: 70vh;
  }
  #chat-toggle-btn { right: 12px; bottom: 16px; }
}