/* ============================================
   Kiran's AI Chatbot Widget — Caricature Style
   ============================================ */

/* ── Root container (anchors everything bottom-right) ── */
#kb-caricature-root {
  position: fixed;
  bottom: 0;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: 'Georgia', 'Times New Roman', serif;
}

/* ── The chalkboard panel ── */
#kb-board-panel {
  display: none;
  flex-direction: column;
  margin-bottom: 8px;
  width: 320px;
  max-height: 440px;
  border-radius: 12px 12px 4px 4px;
  overflow: hidden;
  box-shadow:
    0 0 0 4px #5C3A1E,
    0 0 0 7px #8B5E2A,
    0 8px 32px rgba(0,0,0,0.35);
  background: #1A3828;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1),
              opacity 0.22s ease;
}

#kb-board-panel.open {
  display: flex;
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Chalkboard inner — chalk-textured feel */
#kb-board-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(255,255,255,0.03) 28px,
      rgba(255,255,255,0.03) 29px
    ),
    #1F3D2B;
}

/* ── Board header ── */
#kb-board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #5C3A1E;
  border-bottom: 3px solid #8B5E2A;
  color: #F5E6C8;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 0.04em;
  font-family: 'Georgia', serif;
}

#kb-close-btn {
  background: none;
  border: none;
  color: #F5E6C8;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}
#kb-close-btn:hover { opacity: 1; }

/* ── Messages area ── */
#kb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
  max-height: 280px;
}

/* Chalk-style scrollbar for WebKit */
#kb-chat-messages::-webkit-scrollbar { width: 4px; }
#kb-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
}

/* ── Message bubbles ── */
.kb-msg {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  max-width: 90%;
  font-size: 13.5px;
  line-height: 1.55;
  animation: kb-pop-in 0.2s ease;
}

@keyframes kb-pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.kb-msg.bot {
  align-self: flex-start;
  color: #E8F5E0;
  /* Chalk handwriting feel */
  font-family: 'Georgia', serif;
  text-shadow: 0 0 8px rgba(232,245,224,0.2);
}

.kb-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.kb-msg.user .kb-msg-text {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px 10px 2px 10px;
  padding: 6px 11px;
  color: #F5E6C8;
  font-family: 'Georgia', serif;
  font-style: italic;
}

.kb-avatar {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Input row ── */
#kb-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 2px dashed rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.15);
}

#kb-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(255,255,255,0.35);
  color: #E8F5E0;
  font-family: 'Georgia', serif;
  font-size: 13.5px;
  font-style: italic;
  padding: 6px 2px;
  outline: none;
  transition: border-color 0.2s;
}

#kb-chat-input::placeholder {
  color: rgba(232,245,224,0.4);
  font-style: italic;
}

#kb-chat-input:focus {
  border-bottom-color: rgba(255,255,255,0.7);
}

#kb-chat-send {
  background: #5C3A1E;
  border: 2px solid #8B5E2A;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  color: #F5E6C8;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
  line-height: 1;
}

#kb-chat-send:hover {
  background: #7A4F2A;
  transform: scale(1.1);
}

/* ── The SVG figure wrapper ── */
#kb-figure-wrap {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#kb-figure-wrap:hover #kb-figure {
  transform: translateY(-4px);
}

#kb-figure {
  width: 108px;
  height: 189px;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.28));
}

/* ── Pulsing dot on figure ── */
#kb-pulse-dot {
  animation: kb-pulse 1.8s ease-in-out infinite;
  transform-origin: 95px 40px;
}

@keyframes kb-pulse {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ── "Ask me!" label ── */
#kb-figure-label {
  font-family: 'Georgia', serif;
  font-size: 11px;
  font-style: italic;
  color: #5C3A1E;
  background: #F5E6C8;
  border: 1px solid #8B5E2A;
  border-radius: 10px;
  padding: 2px 9px;
  margin-top: -4px;
  margin-bottom: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: color 0.2s;
  white-space: nowrap;
}