/* ===================================================
   GARUD CLASSES – CHATBOT WIDGET STYLES
   =================================================== */

:root {
  --chat-primary: #e63946;
  --chat-primary-dark: #b52a34;
  --chat-bg: #ffffff;
  --chat-header-bg: linear-gradient(135deg, #e63946 0%, #c1121f 100%);
  --chat-user-bg: #e63946;
  --chat-bot-bg: #f1f3f5;
  --chat-text: #212529;
  --chat-muted: #6c757d;
  --chat-border: #dee2e6;
  --chat-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  --chat-radius: 18px;
}

/* ── Toggle Button ─────────────────────────────────── */
#chatbot-toggle {
  position: fixed;
  bottom: 148px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--chat-header-bg);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(230, 57, 70, 0.45);
  z-index: 9998;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(230, 57, 70, 0.6);
}

#chatbot-toggle .chat-open-icon,
#chatbot-toggle .chat-close-icon {
  position: absolute;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#chatbot-toggle .chat-close-icon {
  opacity: 0;
  transform: rotate(-90deg);
}

#chatbot-toggle.active .chat-open-icon {
  opacity: 0;
  transform: rotate(90deg);
}

#chatbot-toggle.active .chat-close-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* Notification badge */
#chatbot-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: #ffd60a;
  border-radius: 50%;
  border: 2px solid #fff;
  display: block;
  animation: badge-pulse 1.8s infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ── Blur Overlay ────────────────────────────────── */
#chatbot-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 9997;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#chatbot-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ── Chat Window ───────────────────────────────────── */
#chatbot-window {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 400px;
  max-height: 640px;
  border-radius: var(--chat-radius);
  background: var(--chat-bg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: translate(-50%, -44%) scale(0.88);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

#chatbot-window.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ────────────────────────────────────────── */
#chatbot-header {
  background: var(--chat-header-bg);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.chatbot-header-info {
  flex: 1;
}

.chatbot-header-info h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.chatbot-header-info span {
  font-size: 0.76rem;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 5px;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52fa7c;
  display: inline-block;
  animation: blink 1.6s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#chatbot-minimize {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s;
}

#chatbot-minimize:hover { color: #fff; }

/* ── Quick Suggestions ─────────────────────────────── */
#chatbot-suggestions {
  padding: 8px 12px 4px;
  background: #fef9f9;
  border-bottom: 1px solid var(--chat-border);
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.suggestion-btn {
  background: #fff;
  border: 1px solid #f0c0c3;
  color: var(--chat-primary);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.suggestion-btn:hover {
  background: var(--chat-primary);
  color: #fff;
  border-color: var(--chat-primary);
}

/* ── Messages Container ────────────────────────────── */
#chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar { width: 5px; }
#chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#chatbot-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

/* ── Message Bubbles ───────────────────────────────── */
.chat-msg {
  display: flex;
  gap: 8px;
  animation: msg-in 0.3s ease;
  max-width: 88%;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg.bot {
  align-self: flex-start;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg.bot .msg-avatar {
  background: linear-gradient(135deg, #e63946, #c1121f);
  color: #fff;
}

.chat-msg.user .msg-avatar {
  background: #495057;
  color: #fff;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.chat-msg.bot .msg-bubble {
  background: var(--chat-bot-bg);
  color: var(--chat-text);
  border-top-left-radius: 4px;
}

.chat-msg.user .msg-bubble {
  background: var(--chat-user-bg);
  color: #fff;
  border-top-right-radius: 4px;
}

/* Markdown-like styling inside bubbles */
.msg-bubble strong { font-weight: 700; }

.msg-bubble a {
  color: #e63946;
  text-decoration: underline;
}

.chat-msg.user .msg-bubble a { color: #ffe8ea; }

/* ── Typing Indicator ──────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 10px 14px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #adb5bd;
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scaleY(1); }
  40% { transform: scaleY(1.6); }
}

/* ── Timestamp ─────────────────────────────────────── */
.msg-time {
  font-size: 0.65rem;
  color: var(--chat-muted);
  text-align: right;
  margin-top: 2px;
  padding: 0 4px;
}

/* ── Input Area ────────────────────────────────────── */
#chatbot-input-area {
  padding: 12px;
  border-top: 1px solid var(--chat-border);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--chat-border);
  border-radius: 24px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  resize: none;
}

#chatbot-input:focus {
  border-color: var(--chat-primary);
}

#chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chat-header-bg);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

#chatbot-send:hover {
  opacity: 0.88;
  transform: scale(1.08);
}

#chatbot-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ── Footer branding ───────────────────────────────── */
#chatbot-footer {
  text-align: center;
  padding: 5px 0 9px;
  font-size: 0.65rem;
  color: var(--chat-muted);
  background: #fff;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}

/* ── Responsive – mobile ───────────────────────────── */
@media (max-width: 768px) {
  /* Toggle: bottom-right, above WhatsApp */
  #chatbot-toggle {
    right: 18px;
    left: auto;
    bottom: 148px;
  }

  /* Overlay not needed on mobile (full-screen covers everything) */
  #chatbot-overlay {
    display: none;
  }

  /* Chat window: full-screen slide-up on mobile */
  #chatbot-window {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
    /* override desktop centering */
    transform: translateY(100%);
    opacity: 1;
  }

  #chatbot-window.open {
    transform: translateY(0);
    opacity: 1;
  }

  /* Hide the floating mobile portal bar while chatbot is open */
  body.chatbot-open .mobile-portal-bar {
    display: none !important;
  }
}
