/* RAG Chatbot Widget Styles - IGY Calm & Minimal Design */
.rag-chatbot-widget {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  max-width: 400px;
  border: none;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 8px 20px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  margin: 0;
  position: fixed;
  bottom: 60px;
  right: 60px;
  z-index: 1000;
  --primary-color: #00c037;
  --soft-green: rgba(0, 192, 55, 0.08);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.06);
  --shadow-gentle: 0 4px 16px rgba(0, 0, 0, 0.04);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Минимизирано състояние */
.rag-chatbot-widget.minimized {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(0, 192, 55, 0.2);
  overflow: visible;
}

.rag-chatbot-widget.minimized:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(0, 192, 55, 0.3);
}

/* Скриваме елементи при минимизиране */
.rag-chatbot-widget.minimized .rag-chatbot-header,
.rag-chatbot-widget.minimized .rag-chatbot-loading,
.rag-chatbot-widget.minimized .rag-chatbot-messages,
.rag-chatbot-widget.minimized .rag-chatbot-input-area {
  display: none !important;
}

/* Chat Bubble - с картинка вместо emoji */
.rag-chat-bubble {
  display: none;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #00c037, #00a830);
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1001;
  background-image: url('https://copy.i.gy/wp-content/uploads/2025/03/photo_2025-08-25_15-31-53.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.rag-chatbot-widget.minimized .rag-chat-bubble {
  display: flex;
}

.rag-chat-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 50%);
  border-radius: 50%;
}

/* Bubble Text - центриран над балончето на 2 реда */
.rag-chat-bubble-text {
  position: absolute;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 96, 27, 0.9); /* Тъмно зелен вместо черен */
  color: white;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  white-space: pre-line;
  box-shadow: 0 8px 25px rgba(0, 96, 27, 0.25); /* Зелена сянка */
  backdrop-filter: blur(10px);
  font-family: inherit;
  z-index: 1002;
  pointer-events: none;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  line-height: 1.3;
  min-width: 150px;
}

.rag-chatbot-widget.minimized .rag-chat-bubble-text {
  opacity: 1;
  animation: ragBubbleTextShow 0.5s ease-out 1s both;
}

@keyframes ragBubbleTextShow {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.rag-chat-bubble-text::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(0, 96, 27, 0.9); /* Тъмно зелена стрелка */
}

.rag-chatbot-widget.minimized:hover .rag-chat-bubble-text {
  background: rgba(0, 96, 27, 0.95); /* По-тъмен зелен при hover */
  transform: translateX(-50%) translateY(-3px) scale(1.05);
}

.rag-chatbot-widget.minimized:hover .rag-chat-bubble-text::after {
  border-top-color: rgba(0, 96, 27, 0.95); /* Стрелката също се променя */
}

/* Скриваме bubble елементи когато е разширено */
.rag-chatbot-widget:not(.minimized) .rag-chat-bubble-text,
.rag-chatbot-widget:not(.minimized) .rag-chat-bubble {
  display: none !important;
}

/* Header */
.rag-chatbot-header {
  background: linear-gradient(135deg, #00c037, #00a830);
  color: white;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.rag-chatbot-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.15), transparent 60%);
}

.rag-chatbot-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: white !important;
  position: relative;
  z-index: 1;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.rag-chatbot-controls {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.rag-chatbot-minimize {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 300;
  backdrop-filter: blur(10px);
}

.rag-chatbot-minimize:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* Loading Screen */
.rag-chatbot-loading {
  padding: 48px 24px;
  text-align: center;
  background: linear-gradient(135deg, #fafcfa, #ffffff);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.rag-chatbot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--soft-green);
  border-top: 3px solid #00c037;
  border-radius: 50%;
  animation: ragSpinner 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  margin-bottom: 20px;
}

@keyframes ragSpinner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.rag-chatbot-loading p {
  margin: 0;
  color: #6b7280;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

/* Messages Area */
.rag-chatbot-messages {
  padding: 28px 24px;
  overflow-y: auto;
  background: linear-gradient(135deg, #fafcfa, #ffffff);
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-height: 350px;
  height: 350px;
  scroll-behavior: smooth;
}

.rag-chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.rag-chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.rag-chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 192, 55, 0.2);
  border-radius: 2px;
}

.rag-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 192, 55, 0.3);
}

/* Messages */
.rag-message {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  animation: ragMessageSlideIn 0.3s ease-out;
}

@keyframes ragMessageSlideIn {
  from {
      opacity: 0;
      transform: translateY(10px);
  }
  to {
      opacity: 1;
      transform: translateY(0);
  }
}

.rag-message.user-message {
  flex-direction: row-reverse;
}

.rag-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #00c037, #009e2e);
}

.user-message .rag-message-avatar {
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.rag-message-content {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rag-message-text {
  padding: 16px 20px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-wrap: break-word;
  box-shadow: var(--shadow-gentle);
  background: white;
  color: #2d3748;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 6px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.user-message .rag-message-text {
  background: linear-gradient(135deg, #00c037, #009e2e);
  color: white;
  border-bottom-right-radius: 6px;
  border-bottom-left-radius: 18px;
  border: none;
}

.rag-message-text strong {
  font-weight: 600;
}

.rag-message-text code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 13px;
}

.user-message .rag-message-text code {
  background: rgba(255, 255, 255, 0.2);
}

/* Input Area */
.rag-chatbot-input-area {
  padding: 24px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid rgba(0, 192, 55, 0.08);
  backdrop-filter: blur(20px);
}

.rag-chatbot-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rag-chatbot-input {
  flex: 1;
  padding: 16px 20px;
  border: 2px solid rgba(0, 192, 55, 0.1);
  border-radius: 24px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  resize: none;
  min-height: 80px;
  max-height: 80px;
  line-height: 1.6;
  font-weight: 400;
  background: rgba(255, 255, 255, 0.8);
  color: #374151;
  backdrop-filter: blur(10px);
}

.rag-chatbot-input:focus {
  border-color: rgba(0, 192, 55, 0.3);
  box-shadow: 0 0 0 4px rgba(0, 192, 55, 0.08);
  background: rgba(255, 255, 255, 0.95);
}

.rag-chatbot-input::placeholder {
  color: #9ca3af;
}

.rag-chatbot-send-btn {
  background: linear-gradient(135deg, #00c037, #00a830);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: var(--shadow-gentle);
  letter-spacing: 0.3px;
  align-self: flex-end;
}

.rag-chatbot-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(0, 192, 55, 0.25);
}

.rag-chatbot-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Status indicator */
.rag-chatbot-status {
  margin-top: 12px;
  text-align: center;
  color: #6c757d;
  font-size: 14px;
  font-style: italic;
  padding: 8px;
}

.rag-chatbot-status::before,
.rag-chatbot-status::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #6c757d;
  animation: ragTypingDots 1.4s infinite both;
}

.rag-chatbot-status::before {
  margin-right: 4px;
  animation-delay: -0.32s;
}

.rag-chatbot-status::after {
  margin-left: 6px;
}

@keyframes ragTypingDots {
  0%, 80%, 100% {
      opacity: 0.3;
      transform: scale(0.8);
  }
  40% {
      opacity: 1;
      transform: scale(1);
  }
}

/* Error Messages */
.rag-error-message {
  background: linear-gradient(135deg, #fed7d7, #feb2b2);
  color: #c53030;
  padding: 16px;
  border-radius: 8px;
  margin: 20px;
  text-align: center;
  border: 1px solid #fca5a5;
}

.rag-retry-btn {
  background: #c53030;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 12px;
  transition: background 0.2s ease;
}

.rag-retry-btn:hover {
  background: #9b2c2c;
}

/* Responsive Design */
@media (max-width: 768px) {
  .rag-chatbot-widget {
    right: 30px;
    bottom: 40px;
  }
  
  .rag-chatbot-widget.minimized {
    right: 30px;
    bottom: 40px;
  }
  
  .rag-chat-bubble-text {
    font-size: 11px;
    padding: 6px 10px;
    min-width: 150px;
    bottom: 80px;
  }
  
  .rag-chatbot-widget:not(.minimized) {
    max-width: calc(100vw - 60px);
    width: calc(100vw - 60px);
    right: 30px;
    bottom: 40px;
  }
  
  .rag-chatbot-messages {
    padding: 16px;
  }
  
  .rag-message-content {
    max-width: 85%;
  }
  
  .rag-chatbot-input-wrapper {
    gap: 8px;
  }
  
  .rag-chatbot-input {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .rag-chatbot-widget:not(.minimized) {
    max-width: calc(100vw - 40px);
    width: calc(100vw - 40px);
    right: 20px;
    bottom: 30px;
    border-radius: 24px;
  }
  
  .rag-chat-bubble-text {
    font-size: 12px;
    padding: 8px 12px;
    min-width: 150px;
    bottom: 75px;
  }
  
  .rag-chatbot-header {
    padding: 12px 16px;
  }
  
  .rag-chatbot-header h3 {
    font-size: 14px;
  }
  
  .rag-chatbot-input-area {
    padding: 12px 16px;
  }
  
  .rag-chatbot-send-btn {
    padding: 12px 16px;
    font-size: 13px;
  }
}

/* Accessibility */
@media (prefers-contrast: high) {
  .rag-chatbot-widget {
    border: 2px solid #000;
  }
  
  .rag-chatbot-input {
    border: 2px solid #000;
  }
  
  .rag-message-text {
    border: 2px solid #000;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rag-message,
  .rag-chatbot-minimize,
  .rag-chatbot-send-btn {
    animation: none;
    transition: none;
  }
  
  .rag-chatbot-spinner {
    animation: none;
  }
  
  .rag-chatbot-spinner::after {
    content: '⳹';
    font-size: 24px;
  }
}