/* Floating AI Button */
.backtotop_ai {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #ffffff;
  color: #fff;
  font-size: 22px;
  border-radius: 50%;
  width: 55px;
  height: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 1000;
  position: relative;
  overflow: hidden;
}

/* Aurora animated border */
.backtotop_ai::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 3px;
  /* thickness of the border */
  background: conic-gradient(#ff6ec4, #7873f5, #12c2e9, #06beb6, #ff6ec4);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: aurora 6s linear infinite;
  z-index: -1;
}

@keyframes aurora {
  to {
    transform: rotate(360deg);
  }
}

.backtotop_ai:hover {
  background: #1e40af;
  transform: scale(1.1);
}

/* Chat Popup Wrapper */
.chat-container-wrapper {
  position: fixed;
  bottom: 150px;
  right: 20px;
  width: 350px;
  max-height: 80vh;
  display: none;
  flex-direction: column;
  z-index: 1000;
  font-family: Roboto-Regular;
}

.chat-container-wrapper.active {
  display: flex;
}

/* Chat Box */
.chat-container {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  height: 60vh;
  padding: 16px;
}

/* Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chat-title {
  font-size: 20px;
  font-weight: bold;
  color: #374151;
  font-family: Norton S1, sans-serif;
}

.chat-close {
  background: none;
  border: none;
  font-size: 26px;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s ease;
}

.chat-close:hover {
  color: #111827;
}

/* Chat messages */
.chatbox {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: Norton S1, sans-serif;
}

.message-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
}

.user-message {
  background: #2563eb;
  color: white;
  align-self: flex-end;
}

.bot-message {
  background: #f3f4f6;
  color: #111827;
  align-self: flex-start;
}

.loading-dots span {
  display: inline-block;
  animation: blink 1.4s infinite;
  font-size: 22px;
}

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

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

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0;
  }

  40% {
    opacity: 1;
  }
}

/* Input */
.chat-input-wrapper {
  display: flex;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 9999px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  font-family: Norton S1, sans-serif;
}

.chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}

.chat-send {
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: bold;
  padding: 10px 18px;
  margin-left: 8px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-family: Norton S1, sans-serif;
}

.chat-send:hover {
  background: #1e40af;
  transform: scale(1.05);
}

.backtotop {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  border-radius: 100%;
  padding: 0.5rem;
  width: 50px;
  height: 50px;
  cursor: pointer;
  transition: 0.5s;
  z-index: 1;
  box-shadow: rgba(50, 50, 93, 0.25) 0px 6px 12px -2px,
    rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
}

.backtotop svg {
  width: 70%;
  height: 70%;
}

.backtotop:hover {
  background-color: #e6e6e6;
  transition: 0.5s;
}

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

@media only screen and (max-width: 640px) {
  .backtotop {
    width: 40px;
    height: 40px;
    bottom: 0.5rem;
    right: 0.5rem;
  }
}

/* ai */
.backtotop_ai {
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1001; /* higher than aurora */
  overflow: visible; /* allow popup to show outside */
}

.backtotop_ai svg {
  width: 70%;
  height: 70%;
}

.backtotop_ai:hover {
  background-color: #e6e6e6;
  transition: 0.5s;
}

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  scroll-behavior: smooth;
}

@media only screen and (max-width: 640px) {
  .backtotop {
    width: 40px;
    height: 40px;
    bottom: 0.5rem;
    right: 0.5rem;
  }
  .chat-container-wrapper {
    bottom: 110px;
  }
  .backtotop_ai {
    width: 40px;
    height: 40px;
    bottom: 4rem;
    right: 0.5rem;
  }
}

/* === ADDED HOVER POPUP === */
.backtotop_ai .popup {
  position: absolute;
  right: 60px; /* distance from button */
  top: 50%;
  transform: translateY(-50%) translateX(-10px);
  background: #333;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1002; /* above everything */
}

/* Arrow */
.backtotop_ai .popup::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent #333;
}

/* Show on hover */
.backtotop_ai:hover .popup {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
