/* Base font for the entire chat interface */
#chat-container {
  font-family: Arial, sans-serif;
  font-size: 16px;
}

/* Offset for pages with footer */
#chatbot {
  --spacing: 20px; /* Default spacing */
}

/* Chat icon - Fixed button to open chat */
.chat-icon {
  width: 60px;
  height: 60px;
  color: white;
  background-color: #0078d4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: fixed;
  bottom: var(--spacing);
  right: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease-out, background-color 0.3s ease-out;
  overflow: hidden;
}

.chat-icon .icon-image {
  width: 50%;
  height: 50%;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.3s ease-out;
}

.chat-icon.fade-out {
  opacity: 0;
  background-color: transparent;
}

#chat-container.active {
  display: flex;
  opacity: 1;
}

#chat-container.closing {
  opacity: 0;
}

.chat-icon.fading-out .icon-image {
  opacity: 0;
}

.chat-icon i {
  font-size: 24px;
}

/* Send Button */
#send-button {
  background-color: #0078d4;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.3s ease;
}

.send-icon {
  width: 17px;
  height: 17px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

/* Hover effects */
.chat-icon:hover {
  background-color: #106ebe;
  transform: scale(1.05);
}

#send-button:hover {
  background-color: #106ebe;
  transform: scale(1.05);
}

/* Main chat container */
.chat-container {
  display: flex;
  position: fixed;
  bottom: -500px;
  right: 20px;
  width: 350px;
  height: 500px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  overflow: hidden;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease-out;
}

/* Utility classes */
.chat-container.active {
  opacity: 1;
  visibility: visible;
  bottom: var(--spacing);
}

.chat-container.closing {
  bottom: -500px;
  opacity: 0;
  visibility: hidden;
}

/* Header styling */
.chat-header {
  background-color: #2072c8;
  color: white;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 10px 10px 0 0;
}

.header-buttons {
  display: flex;
  align-items: center;
}

.minimize-btn {
  background: none;
  border: none;
  color: white;
  font-family: Arial, sans-serif;
  font-size: 18px;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
  transition: opacity 0.2s;
}

.minimize-btn:hover {
  opacity: 0.8;
}

.refresh-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  padding: 0px 5px;
  margin-right: 5px;
}

.refresh-btn:hover {
  color: #e0e0e0;
}

.chat-header h3 {
  color: white;
  padding-top: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

/* Messages container */
.chat-messages {
  flex-grow: 1;
  padding: 20px;
  padding-bottom: 0 !important;
  overflow-y: auto;
  background-color: #f5f5f5;
}

/* Message styling */
.message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 8px;
  animation: messageAppear 0.3s ease-out;
}

.message-content {
  flex: 1;
  padding: 12px 16px;
  border-radius: 10px;
  max-width: 80%;
  white-space: pre-line;
}

/* Profile icons */
.profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: contain;
  background-color: #f0f0f0;
}

/* User message specific styling */
.user-message {
  flex-direction: row-reverse;
}

.user-message .profile-icon {
  background-color: #e6e6e6;
}

.user-message .message-content {
  background-color: #2072c8;
  color: white;
}

/* Bot message specific styling */
.bot-message .profile-icon {
  background-color: #ffffff;
}

.bot-message .message-content {
  background-color: #f0f0f0;
  color: #333;
}

/* Input area styling */
.chat-input-area {
  display: flex;
  align-items: center;
  padding: 10px;
}

#chat-form {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
}

#user-input {
  flex-grow: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
}

#chat-form button {
  background-color: #2072c8;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loading animation */
.loading-animation {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background-color: #f0f0f0;
  border-radius: 10px;
  margin-bottom: 10px;
  max-width: 60px;
}

.loading-dot {
  width: 8px;
  height: 8px;
  background-color: #2072c8;
  border-radius: 50%;
  animation: loadingBounce 0.8s infinite;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* Animations */
@keyframes messageAppear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loadingBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Chat Notification */
.notification-bubble {
  font-family: Arial, sans-serif;
  position: fixed;
  background: white;
  color: black;
  border: 2px solid #2072c8;
  border-radius: 999px;
  padding: 12px 24px;
  bottom: calc(var(--spacing) + 70px); /* Positioned above chat icon */
  right: 20px;
  max-width: 300px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 999;
  white-space: pre-line;
  flex: 1;
  animation: messageAppear 0.3s ease-out;
  height: fit-content;
  line-height: 1.4;
  visibility: hidden;
}

/* Black border arrow */
.notification-bubble::before {
  content: "";
  position: absolute;
  bottom: -12px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #2072c8;
}

/* White fill arrow */
.notification-bubble::after {
  content: "";
  position: absolute;
  bottom: -9px;
  right: 20px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid white;
  z-index: 1;
}

/* Animation keyframes for extra pop effect */
@keyframes popIn {
  0% {
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.notification-bubble.show {
  opacity: 1;
  transform: translateY(0);
  animation: popIn 0.4s ease;
  visibility: visible;
}

.notification-bubble.hide {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  visibility: hidden;
}

/* Message Sources */
.message-sources {
  margin-top: 10px;
  font-size: 0.9em;
}

.message-sources ul {
  list-style: none;
  padding-left: 0;
  margin: 5px 0;
}

.message-sources a {
  color: #2072c8;
  text-decoration: none;
}

.message-sources a:hover {
  text-decoration: underline;
}

/* Suggestion Buttons */
.suggestions-container {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
  width: calc(100% - 20px);
  padding: 0 10px;
  position: relative;
}

.suggestion-button {
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 15px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s;
  font-size: 0.9em;
  color: #2c2c2c;
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.suggestion-button:hover {
  background-color: #e6e6e6;
}

.suggestion-button:hover::after {
  content: attr(title);
  position: absolute;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  white-space: normal;
  max-width: 300px;
  word-wrap: break-word;
  z-index: 1000;
}

.suggestion-button:hover::before {
  content: "";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.8);
  z-index: 1000;
}

/* Ensure tooltip stays within viewport */
@media (max-width: 320px) {
  .suggestion-button::after {
    max-width: 200px; /* Smaller tooltip for very small screens */
  }
}
