/* ===== Chatbot Widget ===== */
#chatbot-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
}

/* Floating Action Button */
.chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #5b4a8a 0%, #7b6baa 100%);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(91, 74, 138, .35);
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
  position: relative;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 30px rgba(91, 74, 138, .45);
}
.chat-fab:active { transform: scale(.95); }

.chat-fab-icon { transition: opacity .3s, transform .3s; }
.chat-fab-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(.5);
  transition: opacity .3s, transform .3s;
}
.chat-fab.active .chat-fab-icon { opacity: 0; transform: rotate(90deg) scale(.5); }
.chat-fab.active .chat-fab-close { opacity: 1; transform: rotate(0) scale(1); }

.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e8a0bf;
  color: white;
  font-size: .7rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  animation: badge-bounce .6s cubic-bezier(.4, 0, .2, 1);
  border: 2px solid white;
}

@keyframes badge-bounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Chat Window */
.chat-window {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: #fefcf9;
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(91, 74, 138, .2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(.95);
  pointer-events: none;
  transition: all .3s cubic-bezier(.4, 0, .2, 1);
  border: 1px solid rgba(91, 74, 138, .08);
}
.chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, #5b4a8a 0%, #7b6baa 100%);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-header-title {
  font-weight: 700;
  font-size: .95rem;
}
.chat-header-status {
  font-size: .72rem;
  opacity: .8;
  margin-top: 1px;
}
.chat-close-btn {
  background: rgba(255, 255, 255, .15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s;
}
.chat-close-btn:hover { background: rgba(255, 255, 255, .25); }

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  min-height: 200px;
  max-height: 300px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #d4d0e0; border-radius: 4px; }

/* Message Bubbles */
.chat-msg {
  display: flex;
  max-width: 85%;
}
.chat-msg-user { align-self: flex-end; justify-content: flex-end; }
.chat-msg-bot { align-self: flex-start; }

.chat-bubble {
  padding: .7rem 1rem;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.55;
  white-space: pre-line;
  word-wrap: break-word;
}
.chat-bubble-user {
  background: linear-gradient(135deg, #5b4a8a, #7b6baa);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-bubble-bot {
  background: white;
  color: #2d2d2d;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
  border: 1px solid rgba(91, 74, 138, .06);
}

.chat-msg-animate {
  animation: msg-slide-in .3s cubic-bezier(.4, 0, .2, 1);
}
@keyframes msg-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: .8rem 1.2rem;
  align-items: center;
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b0a8c8;
  animation: typing-bounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

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

/* Action buttons inside bot messages */
.chat-action-wrap {
  margin-top: .5rem;
  max-width: 85%;
}
.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  background: linear-gradient(135deg, #5b4a8a, #7b6baa);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(91, 74, 138, .25);
}
.chat-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(91, 74, 138, .35);
}
.chat-action-btn::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3Cpolyline points='12 5 19 12 12 19'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Inline options inside bot messages */
.chat-options-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
  max-width: 85%;
}
.chat-option-btn {
  padding: .4rem .75rem;
  background: white;
  border: 1.5px solid #e0dce8;
  color: #5b4a8a;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.chat-option-btn:hover {
  background: #5b4a8a;
  color: white;
  border-color: #5b4a8a;
}

/* Quick Actions */
.chat-quick-actions {
  padding: 0 1rem .5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.chat-quick-btn {
  background: white;
  border: 1.5px solid #e0dce8;
  color: #5b4a8a;
  padding: .4rem .8rem;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}
.chat-quick-btn:hover {
  background: #5b4a8a;
  color: white;
  border-color: #5b4a8a;
}

/* Input Area */
.chat-input-area {
  padding: .75rem 1rem;
  display: flex;
  gap: .5rem;
  border-top: 1px solid rgba(91, 74, 138, .06);
  background: white;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e8e4f0;
  border-radius: 12px;
  padding: .65rem 1rem;
  font-size: .88rem;
  font-family: inherit;
  outline: none;
  transition: border-color .3s;
  background: #fefcf9;
}
.chat-input:focus { border-color: #5b4a8a; }
.chat-input::placeholder { color: #aaa; }

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #5b4a8a, #7b6baa);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}
.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(91, 74, 138, .3);
}
.chat-send-btn:active { transform: scale(.95); }

/* ===== Mobile Responsive ===== */
@media (max-width: 480px) {
  #chatbot-widget {
    bottom: 1rem;
    right: 1rem;
  }
  .chat-window {
    width: calc(100vw - 2rem);
    right: 0;
    bottom: 70px;
    max-height: 65vh;
    border-radius: 16px;
  }
  .chat-fab {
    width: 54px;
    height: 54px;
  }
}
