/* Floating Style */
.chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #4a2c7e;
  color: white;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: transform 0.2s ease-in-out, background-color 0.2s ease-in-out;
}

.chat-toggle:hover {
  background-color: #3a1c5e;
  transform: scale(1.1);
}

.chat-window {
  position: fixed;
  bottom: 90px;
  right: 20px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 5;
  background-color: white;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
  opacity: 0;
  transform: translateY(20px);
}

.chat-window.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Common Styles */
.chat-header {
  color: white;
  display: flex;
  height: 60px;
  padding-inline: 10px;
  align-items: center;
  justify-content: space-between;
  background-color: #4a2c7e;
}

.chat-header-content {
  display: flex;
  align-items: center;
}

.chat-icon {
  width: 40px;
  height: 40px;
  background-color: white;
  border-radius: 50%;
  margin-right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chat-header-title {
  font-size: 16px;
  font-weight: 500;
  color: white;
}

.chat-close {
  cursor: pointer;
  font-size: 20px;
  opacity: 0.8;
  transition: opacity 0.2s ease-in-out;
}

.chat-close:hover {
  opacity: 1;
}

.chat-messages {
  overflow-y: auto;
  padding: 0px 15px;
  background-color: #f9f9f9;
}


/* Message layout */
.message-container {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
}

.message-content {
  padding: 10px 15px;
  border-radius: 15px;
  max-width: 70%;
  word-wrap: break-word;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.user-message {
  align-items: flex-end;
}

.user-message .message-content {
  color: white;
  border-radius: 15px 15px 0 15px;
}

.bot-message {
  align-items: flex-start;
}

.bot-message .message-content {
  background-color: white;
  color: #333;
  border-radius: 15px 15px 15px 0;
}

.chat-input-area {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 55px;
  border-top: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: white;
  box-sizing: border-box;
}

.chat-input {
  flex: 1;
  border: none;
  border-radius: 5px;
  outline: none;
  padding: 10px;
  /* Keep input white even in dark themes */
  background-color: #ffffff;
  color: #111111;
}

/* Ensure placeholder remains readable on white background */
.chat-input::placeholder {
  color: #666666;
}

.chat-send {
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  margin-inline: 5px;
  min-width: 40px;
  min-height: 40px;
  box-sizing: border-box;
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.loading-container {
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

.thinking-container {
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

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

.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thinking-spinner {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 3px solid #ccc;
  border-top-color: #4a2c7e;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.thinking-text {
  color: #666;
  font-style: italic;
}

/* Reference styling */
.message-references {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.message-references .reference-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  color: #555;
}

.message-references .reference-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: currentColor;
}

.message-references .reference-text {
  font-size: 0.75rem;
}

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px;
  background-color: #f1f1f1;
  border-radius: 15px 15px 15px 0;
  max-width: 70%;
}

.loading-text {
  color: #666;
  font-style: italic;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.chat-trigger-area {
  position: absolute;
  bottom: 55px;
  left: 0;
  right: 0;
  padding: 10px 15px;
  border-top: 1px solid #eee;
  background-color: white;
  z-index: 10;
  max-height: 50%;
  overflow-y: auto;
}

.trigger-container {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.trigger-text {
  padding: 6px 12px;
  border-radius: 15px;
  background-color: #f0f0f0;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s, color 0.2s;
}
