/* Optional: Import a Google Font (if desired) */
/* @import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap"); */

/* ==============================
   Color Variables
============================== */
:root {
  --white: #ffffff;
  --black: #000000;
  --teal-main: #028482;
  --orange-hover: #f6a015;
  --light-bg: #f2f7f6;
  --text-primary: #333333;
  --bubble-user: #ffffff;
  --bubble-bot: #e2f2f1;
}

/* ==============================
     Global Resets
============================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif, Arial, sans-serif;
}

body {
  position: relative;
  height: 100%;
  margin: 0;
  padding: 0;
}

/* ==============================
     Chatbot Container & Toggler
============================== */
#chatbot-toggler {
  position: fixed;
  bottom: 30px;
  right: 35px;
  border: none;
  height: 50px;
  width: 50px;
  display: flex;
  cursor: pointer;
  border-radius: 50%;
  background: var(--teal-main);
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

#chatbot-toggler span {
  position: absolute;
  color: var(--white);
  font-size: 28px;
}

/* Rotate the button 90deg when open */
.container.show-chatbot #chatbot-toggler {
  transform: rotate(90deg);
}

/* Toggle icon visibility */
#chatbot-toggler span:last-child,
.container.show-chatbot #chatbot-toggler span:first-child {
  opacity: 0;
}

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

#chatbot-toggler:hover {
  background-color: var(--orange-hover);
}

/* ==============================
     Chatbot Popup
============================== */

.chatbot-popup {
  width: 350px;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  border-radius: 15px;
  overflow: hidden;
  position: fixed;
  box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1), 0 32px 64px -48px rgba(0, 0, 0, 1);
  background: linear-gradient(to bottom right, var(--light-bg), var(--white));

  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Show the popup when .show-chatbot is applied */
.container.show-chatbot .chatbot-popup {
  opacity: 1;
  pointer-events: auto;
}

/* ==============================
     Chatbot Header
============================== */
.chat-header {
  position: sticky;
  top: -10px;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--teal-main);
  padding: 15px 20px;
}

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

.header-info svg {
  height: 35px;
  width: 35px;
  padding: 6px;
  background: var(--white);
  fill: var(--teal-main);
  border-radius: 50%;
  flex-shrink: 0;
  transform: scaleX(-1);
}

.logo-text {
  color: var(--white);
  font-size: 1.2rem;
  font-weight: 600;
}

#header-toggler {
  height: 35px;
  width: 35px;
  border: none;
  outline: none;
  color: var(--white);
  background: none;
  font-size: 1.8rem;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#header-toggler:hover {
  background-color: var(--orange-hover);
}

/* ==============================
     Chat Body
============================== */
.chat-body {
  flex: 1;
  overflow-y: auto; /* So messages scroll if they exceed container height */
  padding: 10px;
  background-color: transparent;
  min-height: 370px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: center;
}

.message.error .message-text {
  color: red;
}

.bot-message svg {
  align-self: flex-end;
  height: 35px;
  width: 35px;
  padding: 6px;
  background: var(--white);
  fill: var(--teal-main);
  border-radius: 50%;
  transform: scaleX(-1);
}

.message-text {
  padding: 10px;
  max-width: 75%;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 0.95rem;
}

/* Bot bubble */
.bot-message .message-text {
  background: var(--bubble-bot);
  color: var(--text-primary);
  border-radius: 14px 14px 14px 0px;
  border: var(--black) solid 0.5px;
  max-width: 70%;
}

.backgroundchat-intro {
  background: var(--bubble-bot);
  color: var(--text-primary);
  padding: 10px 8px 8px 10px;
  border-radius: 14px 14px 14px 0px;
  border: var(--black) solid 0.5px;
  max-width: 70%;
  margin: 5px;
}

/* User bubble */
.user-message {
  justify-content: flex-end;
}
.user-message .message-text {
  background: var(--bubble-user);
  color: var(--text-primary);
  border-radius: 14px 14px 0px 14px;
  border: var(--black) solid 0.5px;
  max-width: 70%;
  margin: 5px;
}

/* ==============================
     Chat Footer
============================== */
.chat-footer {
  padding: 10px 20px 15px;
  background-color: var(--light-bg);
  left: 0;
  width: 100%;
  height: 60px;
  background: #f2f7f6;
}
.chat-form {
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: 30px;
  outline: 1px solid #ccc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.chat-form:focus-within {
  outline: 2px solid var(--teal-main);
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  height: 45px;
  padding: 0 15px;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.chat-form button {
  height: 35px;
  width: 35px;
  background: var(--teal-main);
  color: var(--white);
  border: none;
  border-radius: 50%;
  margin-right: 6px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.chat-form button:hover {
  background-color: var(--orange-hover);
}

/* ==============================
     Responsive (Mobile)
============================== */
@media (max-width: 520px) {
  #chatbot-toggler {
    bottom: 20px;
    right: 20px;
  }

  .chatbot-popup {
    bottom: 10px;
    right: 10px;
    width: 90%;
    height: 80vh;
    border-radius: 12px;
  }

  .chat-header {
    padding: 12px 15px;
  }

  .chat-footer {
    padding: 10px 15px;
  }

  #mic-button:hover {
    background-color: var(--orange-hover);
  }
}
