:root {
  /* New color palette based on your request */
  --green: #4CAF50; /* A vibrant, friendly green */
  --orange: #FF9800; /* A warm, inviting orange */
  --white: #FFFFFF;
  --light-gray: #f1f1f1; /* For bot messages and backgrounds */
  --dark-text: #333333;
  --gradient: linear-gradient(135deg, var(--orange), var(--green));
  --error: #f44336; /* Kept red for error states for universal user understanding */
  
  /* Shadows based on the new palette */
  --shadow-green: rgba(76, 175, 80, 0.6);
  --shadow-orange: rgba(255, 152, 0, 0.3);
}

/* Ensure the host page's body is styled appropriately for font */
body {
  font-family: "Poppins", sans-serif;
}

/* Chat Toggle Button */
#chat-toggle {
  position: fixed;
  bottom: 25px;
  right: 25px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--white);
  font-size: 32px;
  box-shadow: 0 0 30px var(--shadow-green);
  transition: all 0.3s ease;
  z-index: 999;
  background: var(--gradient);
}
#chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 0 40px var(--shadow-green);
}

/* Chat Container (Main Window) */
#chat-container {
  position: fixed;
  bottom: 110px;
  right: 25px;
  width: 400px;
  height: 550px;
  background-color: var(--white);
  border: 1px solid #e0e0e0;
  border-radius: 16px;
  box-shadow: 0 10px 25px var(--shadow-orange);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Initial hidden state */
  transform: translateY(50px) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s ease;
  z-index: 100;
}
#chat-container.open {
  /* Open state */
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Chat Header */
#chat-header {
  height: 80px;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 15px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
.header-image {
  max-width: 100%;
  max-height: 60px;
  object-fit: contain;
}

/* Message Area */
#chat-messages {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  color: var(--dark-text);
  font-size: 14px;
  background-color: var(--white);
}

/* Input Area */
#chat-input {
  display: flex;
  align-items: center;
  border-top: 1px solid #e0e0e0;
  background: var(--white);
  padding: 8px;
}
#user-input {
  flex: 1;
  padding: 10px;
  border: 1px solid transparent;
  outline: none;
  background: transparent;
  color: var(--dark-text);
  font-size: 14px;
}
#user-input:focus {
    border-color: var(--green);
    border-radius: 8px;
}

#send-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: var(--green);
  margin-left: 8px;
  transition: transform 0.2s ease, color 0.2s;
}
#send-btn:hover {
  color: var(--orange);
  transform: scale(1.1);
}
#send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  color: #999;
}

/* Message Styles */
.message {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 85%;
  line-height: 1.4;
  word-wrap: break-word;
}
.user {
  background: var(--gradient);
  color: var(--white);
  margin-left: auto;
}
.bot {
  background: var(--light-gray);
  color: var(--dark-text);
  margin-right: auto;
}
.error {
  background: #ffebee;
  border: 1px solid var(--error);
  color: var(--error);
}
.system {
  background: #e8f5e9; /* Light green background */
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
}

/* Typing Indicator */
.typing {
  display: inline-block;
}
.typing-dots {
  display: inline-flex;
  gap: 2px;
}
.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  animation: typing 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}
@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Scrollbar styling */
#chat-messages::-webkit-scrollbar {
  width: 6px;
}
#chat-messages::-webkit-scrollbar-track {
  background: var(--light-gray);
  border-radius: 3px;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: var(--green);
  border-radius: 3px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  #chat-container {
    width: 95vw;
    height: 70vh;
    right: 2.5vw;
    bottom: 100px;
  }
  #chat-toggle {
    right: 15px;
  }
}
