@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

.chatbot-toggler {
  position: fixed;
  bottom: 20px;
  right: 10px;
  outline: none;
  border: none;
  height: 60px;
  width: 60px;
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: none;
  z-index: 1000;
}

.chatbot-toggler:hover {
  transform: scale(1.1);
}

body.show-chatbot .chatbot-toggler {
  transform: rotate(90deg);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 10px 30px rgba(255, 107, 53, 0.4);
  }
  50% {
    box-shadow: 0 15px 40px rgba(255, 107, 53, 0.6);
  }
}

.chatbot-toggler span {
  color: #fff;
  position: absolute;
  font-size: 2rem;
  transition: all 0.3s ease;
}

.chatbot-toggler span:last-child,
body.show-chatbot .chatbot-toggler span:first-child {
  opacity: 0;
}

body.show-chatbot .chatbot-toggler span:last-child {
  opacity: 1;
}

.chatbot {
  position: fixed;
  right: 35px;
  bottom: 110px;
  width: 380px;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
  transform-origin: bottom right;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 10000;
}

body.show-chatbot .chatbot {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.chatbot header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
  position: relative;
}

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

.bot-icon {
  width: 42px;
  height: 42px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: wiggle 3s infinite ease-in-out;
  overflow: hidden;
  padding: 3px; 
  border: none; 
}

.bot-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(8deg);
  }
  75% {
    transform: rotate(-8deg);
  }
}

header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.header-right {
  display: none !important;
}

.mobile-close-btn {
  display: flex;
  position: absolute;
  top: 12px;
  right: 15px;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  font-size: 24px;
  color: #fff;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
  padding: 0;
  transition: all 0.3s ease;
  align-items: center;
  justify-content: center;
}

.mobile-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.mobile-close-btn:active {
  transform: scale(0.95);
}

.chatbot .chatbox {
  overflow-y: auto;
  height: 400px;
  padding: 20px 16px 20px 20px;
  background: #f8f9fc;
}

.chatbot .chatbox::-webkit-scrollbar {
  width: 4px;
}

.chatbot .chatbox::-webkit-scrollbar-track {
  background: transparent;
  margin: 10px 4px;
}

.chatbot .chatbox::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.chatbot .chatbox::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

.chat-input textarea::-webkit-scrollbar {
  display: none;
}

.chat-input textarea {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chatbox .chat {
  display: flex;
  list-style: none;
  animation: superBounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes superBounceIn {
  0% {
    opacity: 0;
    transform: translateY(100px) scale(0) rotate(-15deg);
  }
  20% {
    opacity: 0.5;
    transform: translateY(-30px) scale(1.3) rotate(8deg);
  }
  40% {
    opacity: 1;
    transform: translateY(15px) scale(0.85) rotate(-5deg);
  }
  60% {
    transform: translateY(-12px) scale(1.12) rotate(3deg);
  }
  75% {
    transform: translateY(6px) scale(0.95) rotate(-2deg);
  }
  88% {
    transform: translateY(-4px) scale(1.03) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.chatbox .outgoing {
  justify-content: flex-end;
  margin-bottom: 16px;
}

.chatbox .incoming {
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.message-avatar {
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.2);
  position: relative;
  overflow: hidden;
  padding: 3px;
  border: 2px solid #f0f0f0;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.message-avatar::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shine 3s infinite;
}

@keyframes shine {
  0% {
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) translateY(100%) rotate(45deg);
  }
}

.chatbox .chat p {
  white-space: pre-wrap;
  padding: 12px 16px;
  border-radius: 16px;
  max-width: 75%;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  word-wrap: break-word;
}

.chatbox .outgoing p {
  background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.chatbox .incoming p {
  background: #fff;
  color: #1a202c;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.chatbox .chat p:hover {
  transform: translateY(-2px);
}

.chatbox .outgoing p:hover {
  box-shadow: 0 8px 25px rgba(255, 107, 53, 0.5);
}

.chatbox .incoming p:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.chatbot .chat-input {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  background: #fff;
  border-top: 1px solid #e8ecf1;
}

.chat-input textarea {
  height: 50px;
  width: 100%;
  border: 1px solid #cbd5e0;
  outline: none;
  resize: none;
  max-height: 120px;
  padding: 14px 18px;
  font-size: 0.9rem;
  color: #2d3748;
  background: #fff;
  border-radius: 25px;
  transition: all 0.3s ease;
  overflow-y: auto;
}

.chat-input textarea:focus {
  border-color: #FF6B35;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.chat-input textarea::placeholder {
  color: #a0aec0;
}

.chat-input span {
  align-self: flex-end;
  color: #FF6B35;
  cursor: pointer;
  height: 50px;
  width: 50px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: all 0.2s ease;
  border-radius: 50%;
  background: #FFE5DC;
}

.chat-input span:hover {
  background: #FF6B35;
  color: #fff;
  transform: scale(1.1) rotate(15deg);
}

.chat-input textarea:valid ~ span {
  display: flex;
}

.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-12px) scale(1.2);
    opacity: 1;
  }
}

.error {
  color: #e53e3e !important;
  background: #fff5f5 !important;
  border: 1px solid #fc8181 !important;
}

.error a {
  color: #FF6B35;
  text-decoration: underline;
}

/* Mobile Responsive Styles - UPDATED */
@media (max-width: 490px) {
  .chatbot-toggler {
    right: 10px;
    bottom: 15px;
    height: 50px;
    width: 50px;
  }

  .chatbot-toggler .spark-icon {
    width: 40px;
    height: 40px;
  }

  .chatbot-toggler .close-icon {
    font-size: 2rem;
  }

  .chatbot {
    left: 15px;
    right: 15px;
    bottom: 15px;
    top: 60px;
    height: auto;
    max-height: calc(100vh - 75px);
    border-radius: 20px;
    width: auto;
    transform-origin: bottom center;
  }
  
  body.show-chatbot .chatbot {
    transform: scale(1);
  }

  .chatbot header {
    padding: 16px 20px;
  }

  .bot-icon {
    width: 36px;
    height: 36px;
  }

  header h2 {
    font-size: 1.1rem;
  }

  .mobile-close-btn {
    width: 30px;
    height: 30px;
    font-size: 22px;
    top: 10px;
    right: 12px;
  }

  .chatbot .chatbox {
    height: calc(100vh - 245px);
    padding: 16px 12px 16px 16px;
  }
  
  .chatbox .chat {
    margin-bottom: 12px;
  }

  .chatbox .incoming {
    gap: 8px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
  }

  .chatbox .chat p {
    max-width: 85%;
    font-size: 0.85rem;
    padding: 10px 14px;
    line-height: 1.4;
  }

  .chatbot .chat-input {
    padding: 16px 20px;
  }

  .chat-input textarea {
    height: 45px;
    font-size: 0.85rem;
    padding: 12px 16px;
    max-height: 100px;
  }

  .chat-input span {
    height: 45px;
    width: 45px;
    font-size: 1.3rem;
  }

  .typing-indicator {
    padding: 10px 14px;
  }
}

/* Tablet adjustments */
@media (max-width: 768px) and (min-width: 491px) {
  .chatbot {
    width: 90%;
    max-width: 400px;
    right: 5%;
  }
}

.chatbot-toggler .spark-icon {
  width: 50px;
  height: 50px;
  object-fit: contain;
  transition: all 0.3s ease;
  opacity: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 255, 157, 0.4));
  position: absolute;
}

.chatbot-toggler .close-icon {
  opacity: 0;
  position: absolute;
  color: #e45c1d;
  font-size: 2.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  display: none !important;
}

body.show-chatbot .chatbot-toggler .spark-icon {
  opacity: 0;
  transform: rotate(90deg);
}

body.show-chatbot .chatbot-toggler .close-icon {
  opacity: 1;
}

.chatbot-toggler:hover .spark-icon {
  transform: rotate(15deg) scale(1.15);
  filter: drop-shadow(0 6px 12px rgba(0, 255, 157, 0.6));
}

body.show-chatbot .scroll-top {
  display: none !important;
}
