/* AI Chatbot Widget Styles */

:root {
  --chatbot-primary: #1747A6;
  --chatbot-secondary: #F291A3;
  --chatbot-bg: #FFFFFF;
  --chatbot-text: #191919;
  --chatbot-text-light: #7A7A7A;
  --chatbot-border: #E5E5E5;
  --chatbot-shadow: rgba(0, 0, 0, 0.1);
}

/* Chatbot Toggle Button */
.chatbot-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  border-radius: 50%;
  border: none;
  box-shadow: 0 4px 12px var(--chatbot-shadow);
  cursor: pointer;
  z-index: 9998;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.chatbot-toggle.active {
  background: #e74c3c;
}

/* Chatbot Container */
.chatbot-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 60vw;
  max-width: 1200px;
  min-width: 320px;
  height: 80vh;
  max-height: none;
  min-height: 400px;
  background: var(--chatbot-bg);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
}

.chatbot-container.active {
  display: flex;
}

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

/* Chatbot Header */
.chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

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

.chatbot-avatar {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar svg {
  width: 24px;
  height: 24px;
  fill: var(--chatbot-primary);
}

.chatbot-header-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chatbot-header-text p {
  margin: 0;
  font-size: 12px;
  opacity: 0.9;
}

.chatbot-header-actions {
  display: flex;
  gap: 8px;
}

.chatbot-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.chatbot-header-btn svg {
  width: 16px;
  height: 16px;
  fill: white;
}

/* Chatbot Messages Area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #F8F9FA;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: #F1F1F1;
}

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

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

/* Message Bubbles */
.message {
  display: flex;
  gap: 8px;
  max-width: 80%;
  animation: fadeIn 0.3s ease-out;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chatbot-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--chatbot-secondary);
}

.message-avatar svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.message-content {
  background: white;
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  word-wrap: break-word;
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  color: white;
}

.message-content p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.6;
  direction: rtl;
  text-align: right;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Markdown styling */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 12px 0 8px 0;
  font-weight: bold;
  direction: rtl;
  text-align: right;
}

.message-content h1 { font-size: 18px; }
.message-content h2 { font-size: 17px; }
.message-content h3 { font-size: 16px; }
.message-content h4 { font-size: 15px; }

.message-content strong {
  font-weight: bold;
}

.message-content em {
  font-style: italic;
}

.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-right: 20px;
  direction: rtl;
  text-align: right;
}

.message-content li {
  margin: 4px 0;
  line-height: 1.6;
}

.message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.message-content pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content blockquote {
  border-right: 3px solid var(--chatbot-primary);
  margin: 8px 0;
  padding-right: 12px;
  color: var(--chatbot-text-light);
}

.message-content a {
  color: var(--chatbot-primary);
  text-decoration: underline;
}

.message-content hr {
  border: none;
  border-top: 1px solid var(--chatbot-border);
  margin: 12px 0;
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  padding: 20px;
  color: var(--chatbot-text-light);
}

.welcome-message h4 {
  color: var(--chatbot-primary);
  margin-bottom: 12px;
  font-size: 18px;
}

.welcome-message p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* Suggestions */
.chatbot-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px 12px;
  max-height: 150px;
  overflow-y: auto;
}

.suggestion-btn {
  background: white;
  border: 1px solid var(--chatbot-border);
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--chatbot-text);
  cursor: pointer;
  transition: all 0.2s;
  text-align: right;
  direction: rtl;
}

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

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--chatbot-text-light);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

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

/* Chatbot Input Area */
.chatbot-input {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid var(--chatbot-border);
  display: flex;
  gap: 12px;
  align-items: center;
}

.chatbot-input textarea {
  flex: 1;
  border: 1px solid var(--chatbot-border);
  border-radius: 24px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  direction: rtl;
  text-align: right;
  transition: border-color 0.2s;
}

.chatbot-input textarea:focus {
  outline: none;
  border-color: var(--chatbot-primary);
}

.chatbot-input textarea::placeholder {
  color: var(--chatbot-text-light);
}

.chatbot-send-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(23, 71, 166, 0.3);
}

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

.chatbot-send-btn svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Error Message */
.error-message {
  background: #fee;
  color: #c33;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  direction: rtl;
}

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

  .chatbot-toggle {
    right: 10px;
    bottom: 10px;
  }

  .message {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .chatbot-container {
    width: calc(100vw - 20px);
    height: 75vh;
    bottom: 80px;
  }

  .chatbot-header {
    padding: 12px 16px;
  }

  .chatbot-header-text h3 {
    font-size: 14px;
  }

  .chatbot-header-text p {
    font-size: 11px;
  }
}