/* Chatbot Widget Styles - Glassmorphism & Premium Feel */
:root {
  --chatbot-primary: #4A90E2;
  --chatbot-gradient-start: #4facfe;
  --chatbot-gradient-end: #00f2fe;
  --chatbot-bg: rgba(255, 255, 255, 0.15); /* Glass effect */
  --chatbot-panel-bg: rgba(255, 255, 255, 0.85); /* More opaque for readability */
}

#chatbot-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 99999; /* Always on top */
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* --- Toggle Button --- */
#chatbot-toggle {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background-image: url("/images/chatbot-avatar.jpg");
  background-size: cover;
  background-position: center;
  cursor: pointer;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  border: 3px solid rgba(255, 255, 255, 0.6);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
}

#chatbot-toggle::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.7);
  animation: pulse-blue 2s infinite;
  z-index: -1;
}

#chatbot-toggle:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.5);
}

@keyframes pulse-blue {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(79, 172, 254, 0.7);
  }
  70% {
    transform: scale(1.2);
    box-shadow: 0 0 0 10px rgba(79, 172, 254, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(79, 172, 254, 0);
  }
}

/* --- Chat Panel --- */
#chatbot-panel {
  position: absolute;
  bottom: 90px;
  right: 0;
  width: 380px;
  height: 550px;
  max-height: 80vh; /* Responsive height */
  background: var(--chatbot-panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Animation states */
  opacity: 0;
  transform: translateY(20px) scale(0.9);
  pointer-events: none;
  transform-origin: bottom right;
  transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

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

/* --- Header --- */
.chatbot-header {
  background: linear-gradient(
    135deg,
    var(--chatbot-gradient-start) 0%,
    var(--chatbot-gradient-end) 100%
  );
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-image: url("/images/chatbot-avatar.jpg");
  background-size: cover;
  border: 2px solid white;
}

.chatbot-header-title h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: white;
}

.chatbot-header-title span {
  font-size: 12px;
  opacity: 0.8;
  display: block;
}

.chatbot-close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chatbot-close-btn:hover {
  opacity: 1;
}

/* --- Messages --- */
.chatbot-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background-color: rgba(240, 244, 248, 0.5);
  scroll-behavior: smooth;
}

.chatbot-message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease-out;
}

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

.chatbot-message.bot {
  align-self: flex-start;
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chatbot-message.user {
  align-self: flex-end;
  background: linear-gradient(
    135deg,
    var(--chatbot-gradient-start),
    var(--chatbot-gradient-end)
  );
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* --- Input Area --- */
.chatbot-input-area {
  padding: 15px;
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 10px;
  align-items: center;
}

.chatbot-input-area input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #e0e0e0;
  border-radius: 25px;
  background: #f8f9fa;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.chatbot-input-area input:focus {
  border-color: #4facfe;
  background: white;
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

.chatbot-send-btn {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(
    135deg,
    var(--chatbot-gradient-start),
    var(--chatbot-gradient-end)
  );
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 10px rgba(79, 172, 254, 0.3);
}

.chatbot-send-btn:hover {
  transform: scale(1.05);
}

.chatbot-send-btn svg {
  fill: currentColor;
  width: 20px;
  height: 20px;
  margin-left: 2px; /* Visual optical adjustment */
}

/* --- Loading Dots --- */
.typing-indicator {
  padding: 15px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  margin-bottom: 10px;
}

.dot {
  width: 6px;
  height: 6px;
  background: #90949c;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
  animation-delay: -0.32s;
}
.dot:nth-child(2) {
  animation-delay: -0.16s;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  #chatbot-panel {
    width: calc(100vw - 40px);
    right: -20px;
    bottom: 80px;
    height: 70vh;
  }
}
