#aiChatbotWidget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}

.chat-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-toggle-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: var(--shadow-xl);
}

.chat-toggle-btn .chat-icon,
.chat-toggle-btn .close-icon {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  position: absolute;
}

.chat-toggle-btn .close-icon {
  transform: scale(0.7) rotate(-45deg);
  opacity: 0;
}

.chat-toggle-btn.open .chat-icon {
  transform: scale(0.7) rotate(45deg);
  opacity: 0;
}

.chat-toggle-btn.open .close-icon {
  transform: scale(1) rotate(0);
  opacity: 1;
}

.chat-popup {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 500px;
  max-height: 70vh;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  transform: scale(0.95);
  opacity: 0;
  visibility: hidden;
}

.chat-popup.open {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
}

.chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-header-icon {
  width: 24px;
  height: 24px;
  color: var(--primary-600);
}

.chat-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0;
}

.chat-header p {
  font-size: 12px;
  color: var(--gray-600);
  margin: 0;
}

.chat-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-reset-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--gray-500);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-reset-btn:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

.chat-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--gray-500);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.chat-close-btn:hover {
  color: var(--gray-800);
}

.chat-messages {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--gray-100);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.chat-message {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  max-width: 85%;
  line-height: 1.5;
  font-size: 14px;
}

.chat-message.user {
  background: var(--primary-500);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-message.bot {
  background: var(--gray-100);
  color: var(--gray-800);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}

.chat-message.bot.error {
  background: #fee;
  border-left: 3px solid #f44;
  color: #c33;
}

.chat-message.loading {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.chat-message.loading .loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: loading-bounce 1.4s infinite ease-in-out both;
}

.chat-message.loading .loading-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-message.loading .loading-dot:nth-child(2) { animation-delay: -0.16s; }

.loading-text {
  font-size: 13px;
  color: var(--gray-600);
  font-style: italic;
}

@keyframes loading-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

.chat-input-container {
  display: flex;
  padding: 12px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

#chatInput {
  flex-grow: 1;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#chatInput:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

#sendChatBtn {
  margin-left: 12px;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--primary-500);
  color: white;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

#sendChatBtn:hover {
  background: var(--primary-600);
}

#sendChatBtn .send-icon {
  width: 20px;
  height: 20px;
}

.pre-made-questions {
  padding: 8px 12px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-200);
}

.pre-made-questions-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.pre-made-questions-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toggle-questions-btn {
  background: none;
  border: none;
  font-size: 11px;
  color: var(--primary-600);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.toggle-questions-btn:hover {
  background: var(--primary-50);
}

.pre-made-btn {
  background-color: #fff;
  border: 1px solid var(--primary-500);
  border-radius: 16px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary-600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.pre-made-btn:hover {
  background-color: var(--primary-50);
  border-color: var(--primary-600);
}

.chat-privacy-notice {
  padding: 8px 12px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  font-size: 11px;
  color: var(--gray-600);
  text-align: center;
  line-height: 1.4;
}

.chat-privacy-notice a {
  color: var(--primary-600);
  text-decoration: none;
}

.chat-privacy-notice a:hover {
  text-decoration: underline;
}
