/**
 * فيفتي فروت - تنسيقات الشات بوت (متوافق مع الاستضافة المشتركة)
 * Fifty Fruit - Chatbot widget styles
 */
#ff-chatbot-root {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 9998;
  font-family: 'Cairo', 'Poppins', sans-serif;
  direction: rtl;
}

[dir="ltr"] #ff-chatbot-root {
  right: auto;
  left: 0;
  direction: ltr;
}

/* خلفية شفافة عند فتح النافذة */
.ff-chatbot-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ff-chatbot-backdrop.ff-chatbot-backdrop-visible {
  opacity: 1;
  visibility: visible;
}

/* زر فتح الشات */
.ff-chatbot-toggle {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F79833 0%, #34A94A 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(247, 152, 51, 0.5);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, opacity 0.3s ease;
}

[dir="ltr"] .ff-chatbot-toggle {
  right: auto;
  left: 24px;
}

.ff-chatbot-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 24px rgba(247, 152, 51, 0.55);
}

.ff-chatbot-toggle.ff-chatbot-open {
  transform: scale(0.85);
  opacity: 0.85;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.ff-chatbot-toggle .ff-chatbot-icon {
  transition: transform 0.3s ease;
}

.ff-chatbot-toggle.ff-chatbot-open .ff-chatbot-icon {
  transform: rotate(90deg);
}

.ff-chatbot-icon {
  font-size: 28px;
  line-height: 1;
}

/* نافذة المحادثة */
.ff-chatbot-window {
  position: absolute;
  bottom: 90px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

[dir="ltr"] .ff-chatbot-window {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

.ff-chatbot-window.ff-chatbot-window-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.ff-chatbot-window.ff-chatbot-hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  visibility: hidden;
}

@keyframes ff-chatbot-slide {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* الهيدر */
.ff-chatbot-header {
  background: linear-gradient(135deg, #F79833 0%, #34A94A 100%);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.ff-chatbot-header-title {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.ff-chatbot-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease;
}

.ff-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

/* منطقة الرسائل */
.ff-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #fafaf8 0%, #F6F5DC 100%);
  scroll-behavior: smooth;
}

.ff-chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.ff-chatbot-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.04);
  border-radius: 3px;
}

.ff-chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(247, 152, 51, 0.35);
  border-radius: 3px;
}

.ff-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(247, 152, 51, 0.5);
}

.ff-chatbot-msg {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  max-width: 100%;
  opacity: 0;
  transform: translateY(8px);
  animation: ff-chatbot-msg-in 0.35s ease forwards;
}

.ff-chatbot-msg-user {
  justify-content: flex-end;
}

.ff-chatbot-msg-bot .ff-chatbot-msg-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}

.ff-chatbot-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F79833 0%, #34A94A 100%);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.ff-chatbot-msg-user .ff-chatbot-msg-avatar {
  order: 1;
  background: linear-gradient(135deg, #34A94A 0%, #2d8a3e 100%);
}

@keyframes ff-chatbot-msg-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ff-chatbot-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.ff-chatbot-msg-bot .ff-chatbot-bubble {
  background: #fff;
  color: #2c3e50;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-right-radius: 6px;
}

.ff-chatbot-msg-user .ff-chatbot-bubble {
  background: linear-gradient(135deg, #F79833 0%, #34A94A 100%);
  color: #fff;
  border: none;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(247, 152, 51, 0.3);
}

/* مؤشر "يكتب" عند استدعاء الذكاء الاصطناعي */
.ff-chatbot-typing {
  padding: 12px 16px !important;
}

.ff-chatbot-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #F79833;
  margin: 0 2px;
  animation: ff-chatbot-dot 1.2s ease-in-out infinite;
}

.ff-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.ff-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ff-chatbot-dot {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* أزرار الردود السريعة */
.ff-chatbot-quick-replies {
  padding: 10px 18px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.ff-chatbot-quick-btn {
  padding: 10px 14px;
  border-radius: 22px;
  border: 1px solid #F79833;
  background: #fff;
  color: #F79833;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 4px rgba(247, 152, 51, 0.15);
}

.ff-chatbot-quick-btn:hover {
  background: linear-gradient(135deg, #F79833 0%, #34A94A 100%);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(247, 152, 51, 0.3);
}

/* حقل الإدخال */
.ff-chatbot-input-wrap {
  padding: 14px 18px 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.ff-chatbot-input {
  flex: 1;
  padding: 13px 18px;
  border: 1px solid #e5e5e5;
  border-radius: 24px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ff-chatbot-input:focus {
  border-color: #F79833;
  box-shadow: 0 0 0 3px rgba(247, 152, 51, 0.18);
}

.ff-chatbot-send {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #F79833 0%, #34A94A 100%);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 2px 8px rgba(247, 152, 51, 0.35);
}

.ff-chatbot-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(247, 152, 51, 0.45);
}

/* موبايل */
@media (max-width: 480px) {
  .ff-chatbot-window {
    width: 100%;
    max-width: none;
    height: 75vh;
    min-height: 400px;
    bottom: 0;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.2);
  }

  .ff-chatbot-window.ff-chatbot-window-visible {
    box-shadow: 0 -20px 56px rgba(0, 0, 0, 0.22);
  }

  .ff-chatbot-toggle {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  [dir="ltr"] .ff-chatbot-toggle {
    right: auto;
    left: 20px;
  }

  .ff-chatbot-messages {
    padding: 14px;
    gap: 12px;
  }

  .ff-chatbot-bubble {
    padding: 11px 14px;
    font-size: 0.9rem;
  }

  .ff-chatbot-quick-replies {
    padding: 8px 14px 12px;
    gap: 8px;
  }

  .ff-chatbot-quick-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .ff-chatbot-input-wrap {
    padding: 12px 14px 16px;
  }
}
