/**
 * Q9 Custom Chatbot Styles
 * Customizable chatbot UI styles
 */

/* Container */
#q9-chatbot {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  box-sizing: border-box;
}

/* Floating Chatbot (Bottom Right/Left) */
.q9-chatbot-wrapper.q9-floating {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 380px;
  height: 600px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.q9-chatbot-wrapper.q9-floating.q9-bottom-left {
  right: auto;
  left: 20px;
}

/* Inline Chatbot */
.q9-chatbot-wrapper.q9-inline {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.q9-chatbot-header {
  background: linear-gradient(135deg, var(--q9-primary, #3b82f6) 0%, #2563eb 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.q9-chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.q9-chatbot-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.q9-chatbot-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.q9-chatbot-subtitle {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
}

.q9-chatbot-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.q9-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.q9-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.q9-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.q9-chatbot-messages::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.q9-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Welcome Message */
.q9-chatbot-welcome {
  text-align: center;
  color: #666;
  padding: 40px 20px;
  font-size: 14px;
}

/* Message Bubbles */
.q9-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.q9-message-user {
  flex-direction: row-reverse;
}

.q9-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--q9-primary, #3b82f6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 4px;
}

.q9-message-user .q9-message-avatar {
  background: #6b7280;
}

.q9-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  background: white;
  color: #333;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  line-height: 1.5;
}

.q9-message-user .q9-message-content {
  background: var(--q9-primary, #3b82f6);
  color: white;
}

.q9-message.q9-error .q9-message-content {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Sources */
.q9-message-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #6b7280;
}

.q9-message-sources ul {
  margin: 4px 0 0 0;
  padding-left: 20px;
}

.q9-message-sources li {
  margin: 2px 0;
}

/* Input Container */
.q9-chatbot-input-container {
  border-top: 1px solid #e5e7eb;
  background: white;
  padding: 16px;
  flex-shrink: 0;
}

.q9-chatbot-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.q9-chatbot-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}

.q9-chatbot-input:focus {
  border-color: var(--q9-primary, #3b82f6);
}

.q9-chatbot-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--q9-primary, #3b82f6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.q9-chatbot-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

.q9-chatbot-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.q9-chatbot-footer {
  margin-top: 8px;
  text-align: center;
}

.q9-chatbot-footer small {
  color: #9ca3af;
  font-size: 11px;
}

.q9-chatbot-footer a {
  color: var(--q9-primary, #3b82f6);
  text-decoration: none;
}

.q9-chatbot-footer a:hover {
  text-decoration: underline;
}

/* Toggle Button (Floating) */
.q9-chatbot-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--q9-primary, #3b82f6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
}

.q9-chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.q9-chatbot-toggle.q9-bottom-left {
  right: auto;
  left: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .q9-chatbot-wrapper.q9-floating {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 10px;
    left: 10px;
    max-width: none;
    max-height: none;
  }

  .q9-chatbot-toggle {
    bottom: 15px;
    right: 15px;
    width: 56px;
    height: 56px;
  }

  .q9-message-content {
    max-width: 85%;
  }
}

/* Dark Mode Support (optional) */
@media (prefers-color-scheme: dark) {
  .q9-chatbot-wrapper {
    background: #1f2937;
    color: #f9fafb;
  }

  .q9-chatbot-messages {
    background: #111827;
  }

  .q9-message-content {
    background: #374151;
    color: #f9fafb;
  }

  .q9-chatbot-input-container {
    background: #1f2937;
    border-top-color: #374151;
  }

  .q9-chatbot-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
}



