/* RAG Chat Widget Styles */
.rag-chat-container {
  position: fixed;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
}

.rag-chat-container[data-language="ar"] {
  direction: rtl;
  font-family: 'Tajawal', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
}

.rag-chat-bottom-right {
  bottom: 20px;
  right: 20px;
}

.rag-chat-bottom-left {
  bottom: 20px;
  left: 20px;
}

.rag-chat-widget {
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 550px;
  max-height: calc(100vh - 100px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.rag-chat-widget.rag-chat-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

.rag-chat-header {
  background: #0EA5E9;
  color: white;
  padding: 16px;
  border-radius: 16px 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.rag-chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.rag-chat-title {
  font-size: 16px;
  font-weight: 600;
}

.rag-chat-close {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rag-chat-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.rag-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}

.rag-chat-message {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 80%;
  word-wrap: break-word;
  animation: slideIn 0.3s ease-out;
}

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

.rag-chat-message.user {
  background: #0EA5E9;
  color: white;
  align-self: flex-end;
  margin-left: auto;
}

[data-language="ar"] .rag-chat-message.user {
  margin-left: 0;
  margin-right: auto;
  align-self: flex-start;
}

.rag-chat-message.bot {
  background: #e5e7eb;
  color: #1f2937;
  align-self: flex-start;
}

[data-language="ar"] .rag-chat-message.bot {
  align-self: flex-end;
}

.rag-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #e5e7eb;
  border-radius: 12px;
  max-width: 60px;
  align-self: flex-start;
}

.rag-chat-typing span {
  width: 8px;
  height: 8px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.rag-chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.rag-chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.rag-chat-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 8px;
  border-radius: 0 0 16px 16px;
}

.rag-chat-input {
  flex: 1;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.rag-chat-input:focus {
  border-color: #0EA5E9;
}

.rag-chat-send {
  padding: 12px;
  background: #0EA5E9;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.rag-chat-send:hover:not(:disabled) {
  background: #0284c7;
}

.rag-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rag-chat-toggle {
  width: 60px;
  height: 60px;
  background: #0EA5E9;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s, opacity 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

.rag-chat-toggle:hover {
  transform: scale(1.1);
}

.rag-chat-toggle.rag-chat-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Mobile responsive */
@media (max-width: 480px) {
  .rag-chat-widget {
    width: calc(100vw - 20px);
    height: calc(100vh - 80px);
    border-radius: 12px;
  }

  .rag-chat-container.rag-chat-bottom-right,
  .rag-chat-container.rag-chat-bottom-left {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }

  .rag-chat-toggle {
    width: 56px;
    height: 56px;
  }
}

/* Scrollbar styling */
.rag-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.rag-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.rag-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.rag-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
