/* ─────────────────────────────────────────────────────────────────────────────
   chatbot.css — Floating AI Chatbot Widget
   ──────────────────────────────────────────────────────────────────────────── */

#chatbot-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: var(--font-family, 'Inter', system-ui, sans-serif);
}

/* ─── Toggle Button ───────────────────────────────────────────────────────────── */
#chatbot-toggle {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--color-primary, #4F46E5);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgb(79 70 229 / 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 30px rgb(79 70 229 / 0.5);
}

#chatbot-toggle:active {
  transform: scale(0.96);
}

/* ─── Chat Panel ──────────────────────────────────────────────────────────────── */
#chatbot-panel {
  position: absolute;
  bottom: calc(100% + 1rem);
  right: 0;
  width: 24rem;
  max-width: calc(100vw - 2rem);
  height: 32rem;
  max-height: calc(100vh - 8rem);
  background: white;
  border-radius: 1.25rem;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.15), 0 4px 12px rgb(0 0 0 / 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideIn 0.25s ease-out;
}

@keyframes chatSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
#chatbot-header {
  background: var(--color-primary, #4F46E5);
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#chatbot-header button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  transition: background-color 0.15s;
}

#chatbot-header button:hover {
  background-color: rgb(255 255 255 / 0.15);
}

/* ─── Messages ───────────────────────────────────────────────────────────────── */
#chatbot-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar { width: 4px; }
#chatbot-messages::-webkit-scrollbar-track { background: transparent; }
#chatbot-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 99px; }

/* ─── Message Bubbles ──────────────────────────────────────────────────────────── */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  animation: fadeInUp 0.2s ease-out;
}

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

.chat-bubble {
  max-width: 80%;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
}

.bot-bubble {
  background: #f3f4f6;
  color: #111827;
  border-bottom-left-radius: 0.25rem;
}

.user-bubble {
  background: var(--color-primary, #4F46E5);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

/* ─── Typing Indicator ────────────────────────────────────────────────────────── */
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
}

.typing span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typingBounce 1.2s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* ─── Input Area ──────────────────────────────────────────────────────────────── */
#chatbot-input-area {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #f3f4f6;
  background: white;
  flex-shrink: 0;
}

#chatbot-input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  max-height: 6rem;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
}

#chatbot-input:focus {
  border-color: var(--color-primary, #4F46E5);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1);
}

#chatbot-send {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--color-primary, #4F46E5);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s, transform 0.1s;
}

#chatbot-send:hover:not(:disabled) {
  background: var(--color-secondary, #7C3AED);
  transform: scale(1.05);
}

#chatbot-send:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* ─── Mobile adjustments ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #chatbot-widget {
    bottom: 1rem;
    right: 1rem;
  }

  #chatbot-panel {
    width: calc(100vw - 2rem);
    right: -0.25rem;
  }
}
