/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }
  
  /* Chat Button */
  .chat-button {
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background-color: #2962ff;
    color: white;
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s ease;
  }
  
  .chat-button:hover {
    transform: scale(1.1);
  }
  
  .chat-button i {
    font-size: 24px;
  }
  
  /* Chat Window */
  .chat-window {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 360px;
    height: 600px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  /* Chat Header */
  .chat-header {
    padding: 16px;
    background-color: #2962ff;
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .header-content {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .header-avatar i {
    color: #2962ff;
    font-size: 18px;
  }
  
  .close-button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    font-size: 18px;
  }
  
  /* Chat Messages */
  .chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f8f9fa;
  }
  
  .message {
    margin-bottom: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
  }
  
  .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .user-message .message-avatar {
    background-color: #2962ff;
    color: white;
    order: 1;
  }
  
  .assistant-message .message-avatar {
    background-color: white;
    color: #2962ff;
    border: 2px solid #e9ecef;
  }
  
  .message-avatar i {
    font-size: 16px;
  }
  
  .message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
  }
  
  .user-message .message-content {
    background-color: #2962ff;
    color: white;
    margin-left: auto;
  }
  
  .assistant-message .message-content {
    background-color: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  }
  
  /* Reference Links */
  .reference-link {
    color: #2962ff;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
  }
  
  .reference-link:hover {
    color: #1565c0;
    text-decoration: underline;
  }
  
  .user-message .reference-link {
    color: white;
    text-decoration: underline;
  }
  
  /* Source Links */
  .source-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  
  .source-link {
    position: relative;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    text-decoration: none;
    width: 100%;
    transition: all 0.2s ease;
  }
  
  .source-link:hover {
    background-color: #f0f2f5;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  
  .source-link-title {
    font-weight: 600;
    color: #2962ff;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
  }
  
  .source-link-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
  }
  
  .source-link-favicon {
    width: 16px;
    height: 16px;
    object-fit: contain;
  }
  
  /* Source Link Tooltip */
  .source-link-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background-color: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
  }
  
  .source-link:hover .source-link-tooltip {
    opacity: 1;
    visibility: visible;
  }
  
  .source-link-description {
    font-size: 13px;
    color: #495057;
    line-height: 1.5;
    margin-top: 8px;
  }
  
  /* Related Questions */
  .related-questions {
    margin-top: 12px;
    border-top: 1px solid #dee2e6;
    padding-top: 12px;
  }
  
  .related-questions h4 {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
  }
  
  .related-question {
    background: none;
    border: none;
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    color: #2962ff;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s;
  }
  
  .related-question:hover {
    background-color: #f0f2f5;
  }
  
  /* Chat Input */
  .chat-input {
    padding: 16px;
    background-color: white;
    border-top: 1px solid #dee2e6;
  }
  
  .chat-input textarea {
    border-radius: 20px;
    resize: none;
    padding: 8px 16px;
    font-size: 14px;
    border: 1px solid #dee2e6;
    max-height: 100px;
  }
  
  .chat-input .send-button {
    border-radius: 20px;
    padding: 8px 16px;
    margin-left: 8px;
  }
  
  /* Hide chat window by default */
  .chat-window {
    display: none;
  }
  
  /* Show chat window when widget is active */
  .chat-widget.active .chat-window {
    display: flex;
  }
  
  /* Hide chat button when window is open */
  .chat-widget.active .chat-button {
    display: none;
  }
  
  /* Responsive Design */
  @media (max-width: 480px) {
    .chat-window {
      width: 100%;
      height: 100%;
      bottom: 0;
      right: 0;
      border-radius: 0;
    }
  }


/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.typing-indicator .message-avatar {
  margin-top: 8px;
}

.typing-bubble {
  background-color: #e9ecef;
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: #6c757d;
  border-radius: 50%;
  animation: typingAnimation 1.4s infinite;
  opacity: 0.3;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}