﻿@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 0;
  /* No need for flex on body unless it's the main layout for the entire page */
}

/* Chat icon button - always fixed relative to the viewport */
.chat-icon-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1002; /* Higher z-index to ensure it's always clickable and on top */
  background-color: #1F72EB;
  color: white;
  border: none;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  font-size: 1.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease-in-out, background-color 0.2s;
}

  .chat-icon-button:hover {
    background-color: #1F72EB;
    transform: scale(1.05);
  }

  .chat-icon-button:active {
    transform: scale(0.95);
  }

/* Chat container - positioned fixed relative to the viewport */
.chat-container {
  position: fixed;
  /* Start completely hidden below the viewport */
  bottom: -600px; /* Assumes max-height is 600px */
  right: 20px; /* Aligns with the icon's right edge */
  width: 420px; /* Default desktop width */
  min-width: 320px; /* Ensure a minimum width */
  height: 600px; /* Default desktop height */
  max-width: calc(100vw - 40px); /* Prevent overflow on very narrow screens, maintain 20px margin */
  max-height: calc(100vh - 40px); /* Prevent overflow on very short screens, maintain 20px margin */
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* Prevents interaction when hidden */
  transition: opacity 0.3s ease-in-out, bottom 0.3s ease-in-out, visibility 0.3s ease-in-out;
  z-index: 1001; /* Below the button, but above general page content */
}

  /* Expanded state for chat container */
  .chat-container.expanded {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Allows interaction when visible */
    /* Move up to position above the chat icon button */
    bottom: 100px; /* 20px (body bottom margin) + 60px (icon height) + 20px (gap) = 100px */
    right: 20px; /* Keep aligned with the icon's right edge */
  }

/* Responsive adjustments for mobile devices */
@media (max-width: 768px) {
  .chat-container {
    /* On mobile, expand to fill most of the screen with fixed margins */
    width: calc(100% - 40px); /* 20px margin on each side */
    height: calc(100vh - 40px); /* 20px margin top/bottom */
    top: 20px; /* Align to top with margin */
    left: 20px; /* Align to left with margin */
    right: 20px; /* Align to right with margin */
    bottom: 20px; /* Align to bottom with margin */
    max-width: unset; /* Remove desktop max-width constraint */
    max-height: unset; /* Remove desktop max-height constraint */
  }

  .chat-icon-button {
    bottom: 20px;
    right: 20px;
  }
}

/* Chat header (clickable for minimize) */
.chat-header {
  background-color: #1F72EB;
  color: white;
  padding: 16px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  position: relative;
  cursor: pointer; /* Indicate it's clickable */
  user-select: none; /* Prevent text selection on double-click */
}

  .chat-header:hover {
    background-color: #1F72EB;
  }

.response-timer {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  font-weight: 400;
}

.chat-body {
  flex-grow: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: #e0e7ff;
  display: flex;
  flex-direction: column;
}

.message-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 20px;
  margin-bottom: 10px;
  word-wrap: break-word;
  line-height: 1.4;
  position: relative;
}

.user-message {
  align-self: flex-end;
  background-color: #1F72EB;
  color: white;
  border-bottom-right-radius: 4px;
  animation: fadeIn 0.3s ease-out;
}

.ai-message {
  align-self: flex-start;
  background-color: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-bottom-left-radius: 4px;
  animation: fadeIn 0.3s ease-out;
}

.loading-bubble {
  align-self: flex-start;
  background-color: #e2e8f0;
  color: #4b5563;
  border-bottom-left-radius: 4px;
  animation: fadeIn 0.3s ease-out;
  display: flex;
  align-items: center;
}

.loading-dot {
  width: 8px;
  height: 8px;
  background-color: #9ca3af;
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.4s infinite ease-in-out both;
}

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

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

.chat-input-area {
  display: flex;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background-color: #f9fafb;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.chat-input {
  flex-grow: 1;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s;
}

  .chat-input:focus {
    border-color: #1F72EB;
  }

.send-button {
  background-color: #1F72EB;
  color: white;
  border: none;
  border-radius: 20px;
  padding: 12px 20px;
  margin-left: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: background-color 0.2s, transform 0.1s;
}

  .send-button:hover {
    background-color: #1F72EB;
  }

  .send-button:active {
    transform: scale(0.98);
  }

  .send-button:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
  }

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  40% {
    transform: scale(1.0);
  }
}

