.chat-popup {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 40px);
  height: 450px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1001;
  transform-origin: bottom right;
  animation: popup-scale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popup-scale {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.chat-header {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-hover) 100%
  );
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-header h4 {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-body {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background-color: var(--bg);
}
.chat-msg {
  padding: 12px 15px;
  border-radius: var(--border-radius);
  max-width: 85%;
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
}
.bot-msg {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.user-msg {
  background-color: var(--primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.chat-footer {
  padding: 15px;
  border-top: 1px solid var(--border);
  background-color: var(--bg-surface);
  display: flex;
  gap: 10px;
}
.chat-footer input {
  flex-grow: 1;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background-color: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.chat-footer input:focus {
  border-color: var(--primary);
}
.chat-footer button {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}
.typing-dots span {
  width: 8px;
  height: 8px;
  background-color: var(--text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0s;
}
@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: scale(0.2);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}
