/* ═══════════════════════════════════════════════════════════════════════
   Krishna Temple AI Chatbot — Widget Stylesheet
   Design: Spiritual luxury — saffron, gold, deep indigo, cream
   Font: Playfair Display (headings) + Lato (body)
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700&family=Lato:wght@300;400;500;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────────────── */
:root {
  --kb-saffron:      #E8650A;
  --kb-saffron-light:#FF8C42;
  --kb-gold:         #C9A84C;
  --kb-gold-light:   #F0D080;
  --kb-indigo:       #1A1040;
  --kb-indigo-mid:   #2D1B69;
  --kb-indigo-soft:  #3D2B7A;
  --kb-cream:        #FFF8EE;
  --kb-cream-dark:   #F5EDD8;
  --kb-white:        #FFFFFF;
  --kb-text-dark:    #1A1040;
  --kb-text-mid:     #4A3F6B;
  --kb-text-light:   #8B7BA8;
  --kb-user-bubble:  linear-gradient(135deg, #E8650A 0%, #C9501A 100%);
  --kb-bot-bubble:   #FFFFFF;
  --kb-shadow-lg:    0 20px 60px rgba(26,16,64,0.25), 0 8px 24px rgba(26,16,64,0.15);
  --kb-shadow-btn:   0 4px 16px rgba(232,101,10,0.4);
  --kb-radius:       20px;
  --kb-radius-sm:    12px;
  --kb-z:            9999;
}

/* ── Reset for widget scope ─────────────────────────────────────────────── */
#kb-chatbot-widget *,
#kb-chatbot-widget *::before,
#kb-chatbot-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Lato', sans-serif;
}

/* ═══════════════════════════════════════════════════════════════════════
   FLOATING TRIGGER BUTTON
   ═══════════════════════════════════════════════════════════════════════ */
#kb-chatbot-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--kb-z);
}

#kb-trigger-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kb-saffron) 0%, #B84D00 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--kb-shadow-btn);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.3s ease;
  position: relative;
  overflow: visible;
}

#kb-trigger-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 24px rgba(232,101,10,0.55);
}

#kb-trigger-btn:active {
  transform: scale(0.96);
}

/* Pulsing ring animation */
#kb-trigger-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(232,101,10,0.4);
  animation: kb-pulse 2.5s ease-out infinite;
}

@keyframes kb-pulse {
  0%   { opacity: 1;   transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.5); }
  100% { opacity: 0;   transform: scale(1.5); }
}

#kb-trigger-btn svg {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#kb-trigger-icon-open  { display: flex; }
#kb-trigger-icon-close { display: none; opacity: 0; }

/* When chat is open, swap icons */
#kb-chatbot-widget.kb-open #kb-trigger-icon-open  { display: none; }
#kb-chatbot-widget.kb-open #kb-trigger-icon-close { display: flex; opacity: 1; }

/* Notification dot (unread indicator) */
#kb-notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #FFD700;
  border: 2px solid white;
  border-radius: 50%;
  animation: kb-dot-bounce 1.5s ease-in-out infinite;
}

@keyframes kb-dot-bounce {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.25); }
}

#kb-notif-dot.kb-hidden { display: none; }

/* ═══════════════════════════════════════════════════════════════════════
   CHAT PANEL
   ═══════════════════════════════════════════════════════════════════════ */
#kb-chat-panel {
  position: fixed;
  bottom: 80px;
  right: 28px;
  width: 380px;
  height: 580px;
  max-height: calc(100vh - 110px);
  background: var(--kb-cream);
  border-radius: var(--kb-radius);
  box-shadow: var(--kb-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4,0,0.2,1),
              transform 0.35s cubic-bezier(0.4,0,0.2,1);
  transform-origin: bottom right;
}

#kb-chatbot-widget.kb-open #kb-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────── */
#kb-header {
  background: linear-gradient(135deg, var(--kb-indigo) 0%, var(--kb-indigo-mid) 60%, var(--kb-indigo-soft) 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  flex-shrink: 0;
}

/* Subtle mandala pattern overlay */
#kb-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3Ccircle cx='30' cy='30' r='14'/%3E%3Ccircle cx='30' cy='30' r='8'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

#kb-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--kb-saffron), var(--kb-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(201,168,76,0.4);
  position: relative;
  z-index: 1;
}

#kb-header-info {
  flex: 1;
  position: relative;
  z-index: 1;
}

#kb-header-title {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--kb-gold-light);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

#kb-header-subtitle {
  font-size: 11.5px;
  color: rgba(255,255,255,0.55);
  font-weight: 300;
  margin-top: 2px;
  letter-spacing: 0.03em;
}

#kb-status-dot {
  width: 8px;
  height: 8px;
  background: #4ADE80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
  animation: kb-status-pulse 2s ease-in-out infinite;
}

@keyframes kb-status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

#kb-header-actions {
  display: flex;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.kb-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: rgba(255,255,255,0.7);
}

.kb-header-btn:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

.kb-header-btn svg { width: 14px; height: 14px; }

/* ── Divider strip ────────────────────────────────────────────────────── */
.kb-gold-strip {
  height: 3px;
  background: linear-gradient(90deg, var(--kb-saffron), var(--kb-gold), var(--kb-saffron));
  flex-shrink: 0;
}

/* ── Messages Area ────────────────────────────────────────────────────── */
#kb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background:
    linear-gradient(to bottom, rgba(255,248,238,0.95), rgba(245,237,216,0.98));
}

/* Custom scrollbar */
#kb-messages::-webkit-scrollbar { width: 4px; }
#kb-messages::-webkit-scrollbar-track { background: transparent; }
#kb-messages::-webkit-scrollbar-thumb { background: var(--kb-gold); border-radius: 4px; }

/* Welcome banner */
#kb-welcome {
  text-align: center;
  padding: 12px 10px 6px;
}

#kb-welcome-lotus {
  font-size: 32px;
  display: block;
  margin-bottom: 6px;
  animation: kb-float 3s ease-in-out infinite;
}

@keyframes kb-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}

#kb-welcome-text {
  font-family: 'Playfair Display', serif;
  font-size: 13.5px;
  color: var(--kb-indigo);
  font-weight: 600;
  margin-bottom: 4px;
}

#kb-welcome-sub {
  font-size: 11.5px;
  color: var(--kb-text-mid);
  line-height: 1.5;
}

/* ── Message Bubbles ──────────────────────────────────────────────────── */
.kb-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: kb-msg-in 0.3s cubic-bezier(0.4,0,0.2,1);
}

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

.kb-msg-row.kb-user { flex-direction: row-reverse; }

.kb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.kb-bot-avatar-sm {
  background: linear-gradient(135deg, var(--kb-saffron), var(--kb-gold));
}

.kb-user-avatar-sm {
  background: linear-gradient(135deg, var(--kb-indigo-soft), var(--kb-indigo));
}

.kb-bubble {
  max-width: 80%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Bot bubble */
.kb-msg-row.kb-bot .kb-bubble {
  background: var(--kb-bot-bubble);
  color: var(--kb-text-dark);
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(26,16,64,0.10);
  border: 1px solid rgba(201,168,76,0.15);
}

/* User bubble */
.kb-msg-row.kb-user .kb-bubble {
  background: var(--kb-user-bubble);
  color: white;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 8px rgba(232,101,10,0.25);
}

.kb-msg-time {
  font-size: 10px;
  color: var(--kb-text-light);
  margin-top: 3px;
  text-align: right;
  padding: 0 4px;
}

.kb-msg-row.kb-bot .kb-msg-time { text-align: left; }

/* ── Typing Indicator ─────────────────────────────────────────────────── */
#kb-typing-indicator {
  display: none;
  align-items: flex-end;
  gap: 8px;
}

#kb-typing-indicator.kb-active { display: flex; }

.kb-typing-bubble {
  background: white;
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(26,16,64,0.10);
  border: 1px solid rgba(201,168,76,0.15);
  display: flex;
  gap: 5px;
  align-items: center;
}

.kb-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--kb-gold);
  border-radius: 50%;
  animation: kb-typing-bounce 1.4s ease-in-out infinite;
}

.kb-typing-dot:nth-child(1) { animation-delay: 0s; }
.kb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.kb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes kb-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick Suggestions ────────────────────────────────────────────────── */
#kb-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 16px 10px;
  flex-shrink: 0;
  background: transparent;
}

.kb-suggestion-chip {
  padding: 5px 11px;
  background: white;
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--kb-indigo-mid);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  white-space: nowrap;
}

.kb-suggestion-chip:hover {
  background: var(--kb-indigo);
  color: var(--kb-gold-light);
  border-color: var(--kb-indigo);
  transform: translateY(-1px);
}

/* ── Input Area ───────────────────────────────────────────────────────── */
#kb-input-area {
  padding: 12px 14px 14px;
  background: white;
  border-top: 1px solid rgba(201,168,76,0.2);
  flex-shrink: 0;
}

#kb-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--kb-cream);
  border: 1.5px solid rgba(201,168,76,0.3);
  border-radius: 14px;
  padding: 8px 10px;
  transition: border-color 0.2s;
}

#kb-input-row:focus-within {
  border-color: var(--kb-gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.12);
}

#kb-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--kb-text-dark);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 90px;
  min-height: 20px;
  font-family: 'Lato', sans-serif;
  font-weight: 400;
}

#kb-input::placeholder { color: var(--kb-text-light); }

#kb-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--kb-saffron), #B84D00);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 3px 10px rgba(232,101,10,0.35);
}

#kb-send-btn:hover  { transform: scale(1.08); box-shadow: 0 5px 14px rgba(232,101,10,0.5); }
#kb-send-btn:active { transform: scale(0.95); }
#kb-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
#kb-send-btn svg { width: 18px; height: 18px; }

#kb-input-footer {
  font-size: 10px;
  color: var(--kb-text-light);
  text-align: center;
  margin-top: 7px;
  letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  #kb-chatbot-widget {
    bottom: 16px;
    right: 16px;
  }

  #kb-chat-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    right: 0;
    bottom: 72px;
    border-radius: 16px;
  }

  #kb-trigger-btn {
    width: 56px;
    height: 56px;
  }
}
