/* =============================================
   assistant.css — تصميم المساعد الذكي
   منصة زُحَلْ
   ============================================= */

/* ===== الحاوية الرئيسية ===== */
.ai-assistant-wrapper {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 8500;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  direction: rtl;
  pointer-events: none; /* تجنب تعارض النقرات مع باقي العناصر */
}
.ai-assistant-wrapper > * {
  pointer-events: auto; /* العناصر الداخلية تقبل النقرات */
}

/* ===== زر التشغيل ===== */
.ai-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.5);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  animation: aiPulse 3s ease-in-out infinite;
  order: 2;
}

.ai-toggle-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.65);
}

.ai-toggle-btn:active {
  transform: scale(0.95);
}

.ai-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

@keyframes aiPulse {
  0%, 100% { box-shadow: 0 8px 30px rgba(124, 58, 237, 0.5); }
  50% { box-shadow: 0 8px 40px rgba(124, 58, 237, 0.8), 0 0 0 10px rgba(124, 58, 237, 0.1); }
}

/* نقطة الإشعار */
.ai-notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #0d1117;
  display: none;
  animation: dotBlink 1.5s ease-in-out infinite;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== فقاعة الترحيب ===== */
.ai-welcome-bubble {
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid rgba(124, 58, 237, 0.4);
  backdrop-filter: blur(20px);
  color: #e2e8f0;
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px;
  font-size: 0.9rem;
  font-family: 'Cairo', sans-serif;
  white-space: nowrap;
  cursor: pointer;
  order: 1;
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.ai-welcome-bubble.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.ai-welcome-bubble:hover {
  border-color: rgba(124, 58, 237, 0.7);
  background: rgba(20, 28, 50, 0.98);
}

/* ===== نافذة الدردشة ===== */
.ai-chat-window {
  width: 360px;
  height: 520px;
  background: rgba(10, 14, 26, 0.97);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 20px;
  backdrop-filter: blur(30px);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 40px rgba(124, 58, 237, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom left;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  order: 0;
}

.ai-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ===== هيدر الدردشة ===== */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(79, 70, 229, 0.15));
  border-bottom: 1px solid rgba(124, 58, 237, 0.2);
  flex-shrink: 0;
}

.ai-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.ai-name {
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #e2e8f0;
}

.ai-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.78rem;
  color: #94a3b8;
}

.ai-status-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ai-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ai-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* ===== منطقة الرسائل ===== */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.3) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
  width: 4px;
}
.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.3);
  border-radius: 2px;
}

/* ===== الرسائل ===== */
.ai-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: msgSlideIn 0.3s ease forwards;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-message-user {
  flex-direction: row-reverse;
}

.ai-message-bot {
  flex-direction: row;
}

.ai-bot-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.ai-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.88rem;
  line-height: 1.6;
  word-break: break-word;
}

.ai-bubble-user {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-bubble-bot {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.ai-bubble-bot strong {
  color: #a78bfa;
}

/* ===== مؤشر الكتابة ===== */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  background: #7c3aed;
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.ai-typing span:nth-child(1) { animation-delay: 0s; }
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== الردود السريعة ===== */
.ai-quick-replies {
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex-shrink: 0;
  min-height: 10px;
}

.ai-quick-reply-btn {
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.35);
  color: #a78bfa;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ai-quick-reply-btn:hover {
  background: rgba(124, 58, 237, 0.25);
  border-color: #7c3aed;
  color: #c4b5fd;
  transform: translateY(-1px);
}

/* ===== منطقة الإدخال ===== */
.ai-chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  background: rgba(0,0,0,0.2);
}

.ai-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: 25px;
  padding: 6px 8px 6px 14px;
  transition: border-color 0.2s ease;
  gap: 8px;
}

.ai-input-wrapper:focus-within {
  border-color: rgba(124, 58, 237, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

#aiChatInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #e2e8f0;
  font-family: 'Cairo', sans-serif;
  font-size: 0.88rem;
  text-align: right;
  direction: rtl;
}

#aiChatInput::placeholder {
  color: #4b5563;
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  transform: rotate(180deg); /* اتجاه للعربي */
}

.ai-send-btn:hover {
  transform: rotate(180deg) scale(1.1);
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.5);
}

/* ===== تجاوبي ===== */
@media (max-width: 480px) {
  .ai-assistant-wrapper {
    left: 14px;
    bottom: 18px;
  }

  .ai-chat-window {
    width: calc(100vw - 28px);
    height: 480px;
  }
}
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; }
.badge-pending { background: #f39c12; color: #fff; }
.badge-approved { background: #2ecc71; color: #fff; }
.badge-rejected { background: #e74c3c; color: #fff; }

/* ===== زر المايكروفون ===== */
.ai-mic-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.ai-mic-btn:hover {
  background: rgba(124, 58, 237, 0.3);
  color: #fff;
  transform: scale(1.1);
}
.ai-mic-btn.listening {
  background: rgba(220, 38, 38, 0.3);
  color: #f87171;
  animation: micPulse 1s ease-in-out infinite;
  border: 1px solid rgba(220, 38, 38, 0.5);
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* ===== محتوى رسالة البوت (نص + بطاقات) ===== */
.ai-message-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

/* ===== البطاقات المصغرة داخل الدردشة ===== */
.ai-mini-cards-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ai-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  overflow: hidden;
}

.ai-mini-card:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(124, 58, 237, 0.5);
  transform: translateX(-2px);
}

.ai-card-img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.ai-card-img-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.ai-card-info {
  flex: 1;
  min-width: 0;
}

.ai-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.ai-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.ai-card-price {
  font-size: 0.8rem;
  font-weight: 700;
  color: #d4a853;
}

.ai-card-type {
  font-size: 0.7rem;
  background: rgba(124, 58, 237, 0.3);
  color: #c4b5fd;
  padding: 1px 6px;
  border-radius: 4px;
}

.ai-card-location {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* أهداف اللمس (موبايل): أزرار المساعد 40px وأزرار الرد السريع 40px ارتفاعاً */
@media (max-width: 768px) {
  .ai-close-btn, .ai-mic-btn, .ai-send-btn { min-width: 40px; min-height: 40px; }
  .ai-quick-reply-btn { min-height: 40px; }
  #aiChatInput { min-height: 40px; }
}
