/* ============================================
   EZ BOT - CHAT ASSISTANT STYLES
   RTL Support - Purple Theme
   ============================================ */

:root {
  /* Colors */
  --primary-purple: #7B3FBF;
  --primary-dark: #27212D;
  --primary-light: #F8F7F8;
  --accent-light: #CBBCD5;
  --accent-violet: #8F29C9;
  --success-green: #48bb78;
  --text-dark: #27212D;
  --text-light: #FFFFFF;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
  
  /* Sizes */
  --bubble-size: 60px;
  --window-width: 380px;
  --window-height: 600px;
  --header-height: 70px;
  --footer-height: 60px;
  
  /* Transitions */
  --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* RTL ONLY FOR BOT ELEMENTS */
.chat-window,
.chat-window *,
.chat-bubble,
.chat-bubble *,
.powered-by {
  box-sizing: border-box !important;
  direction: rtl !important;
  font-family: 'Segoe UI', 'Cairo', 'Tahoma', sans-serif !important;
}

/* ============================================
   CHAT BUBBLE BUTTON
   ============================================ */
.chat-bubble {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: var(--bubble-size);
  height: var(--bubble-size);
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-violet));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-bounce);
  z-index: 999;
  animation: pulse 2s infinite;
}

.chat-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 40px rgba(123, 63, 191, 0.4);
}

.chat-bubble.active {
  transform: scale(0.9);
  opacity: 0;
  pointer-events: none;
}

.bot-avatar {
  width: 32px;
  height: 32px;
}

.bot-avatar svg {
  width: 100%;
  height: 100%;
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #FF4444;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid white;
  animation: bounce 0.5s ease-in-out;
}

.notification-badge.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 8px 32px rgba(123, 63, 191, 0.3);
  }
  50% {
    box-shadow: 0 8px 40px rgba(123, 63, 191, 0.5);
  }
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ============================================
   CHAT WINDOW
   ============================================ */
.chat-window {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: var(--window-width);
  height: var(--window-height);
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-bounce);
  z-index: 1000;
}

.chat-window.active {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ============================================
   CHAT HEADER
   ============================================ */
.chat-header {
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-violet));
  color: white;
  padding: 16px 20px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

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

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

.bot-avatar-small svg {
  width: 24px;
  height: 24px;
}

.bot-details h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success-green);
  border-radius: 50%;
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* ============================================
   CHAT MESSAGES
   ============================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--primary-light);
  scroll-behavior: smooth;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent-light);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--primary-purple);
}

/* Message Styles */
.message {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  animation: slideIn 0.3s ease-out;
}

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

.message.bot {
  flex-direction: row;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-violet));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.message-content {
  max-width: 75%;
}

.message-bubble {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  line-height: 1.5;
  font-size: 14px;
  color: var(--text-dark);
}

.message.bot .message-bubble {
  border-top-right-radius: 4px;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--primary-purple), var(--accent-violet));
  color: white;
  border-top-left-radius: 4px;
}

.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  padding: 0 4px;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 12px;
  width: fit-content;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--primary-purple);
  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);
  }
  30% {
    transform: translateY(-10px);
  }
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions {
  padding: 20px;
  background: var(--primary-light);
  border-top: 1px solid #E0E0E0;
}

.quick-actions-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 12px;
  text-align: center;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  background: white;
  border: 2px solid var(--accent-light);
  padding: 12px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-base);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.action-btn:hover {
  background: var(--primary-purple);
  color: white;
  border-color: var(--primary-purple);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.action-icon {
  font-size: 24px;
}

/* Option Buttons in Messages */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.option-btn {
  background: white;
  border: 2px solid var(--primary-purple);
  color: var(--primary-purple);
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-base);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.option-btn:hover {
  background: var(--primary-purple);
  color: white;
  transform: translateX(-4px);
}

.option-btn::after {
  content: '←';
  font-size: 18px;
}

.option-btn:hover::after {
  transform: translateX(-4px);
  display: inline-block;
}

/* ============================================
   CHAT FOOTER
   ============================================ */
.chat-footer {
  height: var(--footer-height);
  background: white;
  border-top: 1px solid #E0E0E0;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
}

.footer-btn {
  flex: 1;
  background: var(--primary-light);
  border: 1px solid var(--accent-light);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-base);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

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

.footer-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   POWERED BY BADGE
   ============================================ */
.powered-by {
  position: fixed;
  bottom: 8px;
  left: calc(24px + var(--bubble-size) + 12px);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-base);
  z-index: 998;
  white-space: nowrap;
}

.powered-by.show {
  opacity: 1;
}

.powered-by strong {
  font-weight: 700;
  color: var(--accent-violet);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 480px) {
  :root {
    --window-width: calc(100vw - 32px);
    --window-height: calc(100vh - 100px);
  }
  
  .chat-window {
    left: 16px;
    right: 16px;
    bottom: 80px;
    width: auto;
  }
  
  .chat-bubble {
    bottom: 16px;
    left: 16px;
  }
  
  .powered-by {
    left: calc(16px + var(--bubble-size) + 12px);
  }
}

@media (max-width: 360px) {
  .action-buttons {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.chat-bubble:focus,
.close-btn:focus,
.action-btn:focus,
.option-btn:focus,
.footer-btn:focus {
  outline: 2px solid var(--primary-purple);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}