/* Minimal RAG Chatbot Styles */
:root {
  --primary-color: #667eea;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --text-primary: #2d3748;
  --text-secondary: #718096;
  --bg-primary: #ffffff;
  --bg-secondary: #f7fafc;
  --border-color: #e2e8f0;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --transition: all 0.2s ease;
}

* {
  box-sizing: border-box;
}

/* Chat Launcher */
#rag-chat-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  z-index: 1000;
  box-shadow: var(--shadow);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

#rag-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px -10px rgba(102, 126, 234, 0.3);
}

#rag-chat-launcher.active {
  opacity: 0.7;
  transform: scale(0.9);
}

/* Chat Wrapper */
#rag-chat-wrapper {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 320px;
  height: 400px;
  background: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  z-index: 999;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  opacity: 0;
  transform: translateY(10px);
  transition: var(--transition);
}

#rag-chat-wrapper.closed {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

#rag-chat-wrapper:not(.closed) {
  opacity: 1;
  transform: translateY(0);
}

/* Chat Header */
#rag-chat-header {
  background: var(--primary-gradient);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#rag-chat-header span {
  font-weight: 600;
  font-size: 14px;
}

#rag-close {
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 21px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

#rag-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat Content */
#rag-chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Chat Messages */
#rag-chatbox {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: var(--bg-primary);
  min-height: 0;
}

#rag-chatbox::-webkit-scrollbar {
  width: 4px;
}

#rag-chatbox::-webkit-scrollbar-track {
  background: transparent;
}

#rag-chatbox::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.user-msg, .bot-msg {
  margin-bottom: 8px;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  max-width: 80%;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 13px;
  animation: fadeIn 0.2s ease;
}

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

.user-msg {
  background: var(--primary-gradient);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.bot-msg {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.bot-msg.error {
  background: #fed7d7;
  color: #c53030;
  border-color: #feb2b2;
}

.bot-msg .message-content ul,
.bot-msg .message-content ol {
  margin: 8px 0 8px 18px;
  padding: 0;
  color: var(--text-primary);
}

.bot-msg .message-content ul {
  list-style: disc inside;
}

.bot-msg .message-content ol {
  list-style: decimal inside;
}

.bot-msg .message-content li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.bot-msg .message-content strong {
  color: var(--primary-color);
  font-weight: 700;
}

.bot-msg .message-content em {
  color: var(--text-secondary);
  font-style: italic;
}

.bot-msg .message-content a {
  color: var(--primary-color);
  text-decoration: underline;
  transition: color 0.2s;
}

.bot-msg .message-content a:hover {
  color: #764ba2;
}

.bot-msg .message-content code {
  background: #f3f0fa;
  color: #764ba2;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Fira Mono', 'Consolas', monospace;
}

.bot-msg .message-content blockquote {
  border-left: 3px solid var(--primary-color);
  background: #f7f5fc;
  color: var(--text-secondary);
  margin: 8px 0;
  padding: 8px 16px;
  border-radius: 6px;
  font-style: italic;
}

/* Quick Questions */
.quick-questions {
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.quick-questions::-webkit-scrollbar {
  height: 6px;
}

.quick-questions::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
}

.quick-questions::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.quick-questions::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.quick-btn {
  display: inline-block;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  margin-right: 8px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
  min-width: fit-content;
  user-select: none;
  -webkit-user-select: none;
}

.quick-btn:last-child {
  margin-right: 0;
}

.quick-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.quick-btn.clicked {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: scale(0.98);
}

/* Input Bar */
#rag-input-bar {
  padding: 12px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#rag-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}

#rag-input:focus {
  border-color: var(--primary-color);
  background: var(--bg-primary);
}

#rag-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#rag-input::placeholder {
  color: var(--text-secondary);
}

#rag-send {
  background: var(--primary-gradient);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: var(--transition);
  min-width: 60px;
}

#rag-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

#rag-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading Animation */
.loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
  max-width: 80%;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  #rag-chat-wrapper {
    width: calc(100vw - 40px);
    right: 20px;
    left: 20px;
    height: 80vh;
    bottom: 80px;
  }
  #rag-input
  {
    font-size: 11px;
  }
  
}

/* Focus styles for accessibility */
#rag-chat-launcher:focus,
#rag-close:focus,
.quick-btn:focus,
#rag-send:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
