/* ============================================= */
/* 🎨 تعريف متغيرات الألوان من الهوية البصرية */
/* ============================================= */


/* ============================================= */
/* 🎭 شخصية الشات بوت التفاعلية */
/* ============================================= */
/* ============================================= */
/* 🎨 تعريف متغيرات الألوان العامة */
/* ============================================= */
.ai-chat-widget,
.ai-chat-button {
  --color-text: #2d3748;
  --color-muted: #718096;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
  --radius: 12px;
}

/* ============================================= */
/* 🎭 زر الشات بوت الأساسي */
/* ============================================= */
.ai-chat-button {
  position: fixed;
  bottom: 25px;
  left: 25px;
  z-index: 10000;
  width: 70px;
  height: 70px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary, #46b376), var(--color-secondary, #fcc316));
  cursor: pointer;
  box-shadow:
    0 10px 30px rgba(252, 195, 22, 0.4),
    0 0 0 0 rgba(252, 195, 22, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  animation:
    pulse-glow 2s infinite,
    float-animation 3s ease-in-out infinite;
}

/* تأثير التحويم */
.ai-chat-button:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow:
    0 15px 40px rgba(70, 179, 118, 0.5),
    0 0 0 10px rgba(70, 179, 118, 0.2);
  animation: none;
}

/* أثناء السحب */
.ai-chat-button.dragging {
  transition: none;
  transform: scale(1.05) rotate(5deg);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.3),
    0 0 0 15px rgba(70, 179, 118, 0.25);
}

/* إصلاح التفاعل باللمس */
#aiChatButton,
.ai-chat-button {
  pointer-events: auto !important;
  touch-action: manipulation !important;
  z-index: 99999 !important;
}

#aiChatButton {
  position: fixed !important;
  bottom: 25px !important;
  left: 25px !important;
  z-index: 999999 !important;
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* ============================================= */
/* 💬 فقاعة التلميح الذكية المتصلة بالزر */
/* ============================================= */
.ai-chat-wrapper {
  position: fixed;
  bottom: 25px;
  left: 25px;
  z-index: 10000;
  overflow: visible;
}

/* ✅ فقاعة يسار أو يمين الأيقونة تلقائياً */
/* ✅ فقاعة التلميح الثابتة في الحجم والموقع */
.ai-chat-hint {
  position: fixed;
  background: var(--color-secondary, #fcc316);
  color: #fff;
  padding: 10px 14px;
  border-radius: 18px 18px 18px 0px ;
  font-size: 14px;
  line-height: 1.6;
  display: inline-block;
  text-align: center;
  min-width: 120px;
  max-width: 260px;
  white-space: normal;
  word-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10001;
}

/* 🔹 ظهور */
.ai-chat-hint.visible {
  opacity: 1;
  transform: translateY(0);
}

/* 🔹 الذيل */
.ai-chat-hint::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 20px;
  border-width: 6px;
  border-style: solid;
  border-color: var(--color-secondary, #fcc316) transparent transparent transparent;
}

/* 📱 للجوال */
@media (max-width: 768px) {
  .ai-chat-hint {
    font-size: 12px;
    padding: 8px 10px;
    max-width: 200px;
    transform: translateY(6px) !important; /* ✅ يجبر الحركة للأسفل */
  }

  .ai-chat-hint.visible {
    transform: translateY(6px) !important; /* ✅ تأكيد وقت الظهور */
  }

  .ai-chat-hint::after {
    bottom: -6px; /* ✅ ذيل الفقاعة أقرب للأيقونة */
  }
}

/* ============================================= */
/* 📱 تحسين العرض للجوال */
/* ============================================= */
@media (max-width: 768px) {
  .ai-chat-widget {
    width: calc(100vw - 40px);
    left: 20px;
    right: 20px;
    bottom: 80px;
    height: 70vh;
  }

    .ai-chat-button {
    width: 72px;
    height: 72px;
    box-shadow:
      0 8px 30px rgba(252, 195, 22, 0.45),
      inset 0 0 12px rgba(70, 179, 118, 0.6);
  }

  .ai-avatar {
    width: 58px;
    height: 58px;
  }


}

/* ============================================= */
/* 🎪 حركات الزر والفقاعة */
/* ============================================= */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow:
      0 10px 30px rgba(252, 195, 22, 0.4),
      0 0 0 0 rgba(252, 195, 22, 0.7);
  }
  50% {
    box-shadow:
      0 10px 30px rgba(252, 195, 22, 0.4),
      0 0 0 10px rgba(252, 195, 22, 0);
  }
}

@keyframes float-animation {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}



/* وجه الشات بوت */
.ai-avatar {
  position: relative;
  width: 50px;
  height: 50px;
}

.ai-face {
  width: 100%;
  height: 100%;
  position: relative;
  background: white;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ai-eyes {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.ai-eye {
  width: 8px;
  height: 8px;
  background: var(--color-text);
  border-radius: 50%;
  animation: blink 4s infinite;
  position: relative;
}

.ai-eye::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  background: white;
  border-radius: 50%;
  top: 1px;
  left: 1px;
}

.ai-smile {
  width: 16px;
  height: 8px;
  border-bottom: 2px solid var(--color-text);
  border-radius: 0 0 8px 8px;
  animation: smile 6s infinite;
}

/* مؤشر الاتصال */
.ai-online-indicator {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #4CAF50;
  border: 2px solid white;
  border-radius: 50%;
  animation: ping 2s infinite;
}

.ai-pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--color-secondary);
  animation: pulse-ring 2s infinite;
}

.ai-bot-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}


/* ============================================= */
/* 💬 نافذة الشات المتطورة */
/* ============================================= */

.ai-chat-widget {
  position: fixed;
  bottom: 100px;
  left: 25px;
  width: 400px;
  height: 600px;
  max-height: 70vh;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 20px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.2);
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  animation: 
    chatSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.ai-chat-widget.dark-mode {
  background: rgba(26, 26, 26, 0.45);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* رأس الشات المطور */
.ai-chat-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.ai-chat-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-avatar {
  position: relative;
  width: 45px;
  height: 45px;
}

.ai-animated-face {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ai-animated-face::before {
}

.ai-status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #4CAF50;
  border: 2px solid white;
  border-radius: 50%;
  animation: statusPulse 2s infinite;
}

.ai-chat-info h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
}

.ai-status-text {
  font-size: 0.8rem;
  opacity: 0.9;
  color: rgba(255, 255, 255, 0.9);
}

/* أزرار الرأس */
.ai-chat-actions {
  display: flex;
  gap: 8px;
}

.ai-action-btn, .ai-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.ai-action-btn:hover, .ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* جسم الشات */
.ai-chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: transparent;
  overflow: hidden;
}

.ai-messages-container {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
    -webkit-overflow-scrolling: touch; /* سلاسة سكرول iOS */

}
/* مساحة أسفل للإطار السفلي عند أجهزة بآيفون الحديثة */
@supports(padding: max(0px)) {
  .ai-chat-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ============================================= */
/* ✍️ تأثير الكتابة المتقدم */
/* ============================================= */

/* ===== Typing indicator visibility & layout ===== */
.ai-typing-indicator.advanced {
  display: flex;              /* ← مهم: يكون Flex افتراضيًا */
  align-items: center;
  gap: 12px;
  padding: 7px 9px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0,0,0,.06);
}
.ai-typing-indicator.advanced[hidden] {
  display: none !important;   /* ← الإخفاء يتم عبر خاصية hidden */
}

/* النقاط المتحركة */
.ai-typing-dots { display: inline-flex; gap: 4px; }
.ai-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-primary, #555);
  opacity: .35;
  animation: aiTypingDot 1.2s infinite ease-in-out;
}
.ai-typing-dots span:nth-child(1){ animation-delay: 0s;   }
.ai-typing-dots span:nth-child(2){ animation-delay: .2s;  }
.ai-typing-dots span:nth-child(3){ animation-delay: .4s;  }

@keyframes aiTypingDot {
  0%, 80%, 100% { transform: scale(.75); opacity: .35; }
  40%           { transform: scale(1);   opacity: 1;    }
}

/* ============================================= */
/* 🔽 تذييل الشات والإدخال */
/* ============================================= */

.ai-chat-footer {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding: 5px;
}

.ai-chat-widget.dark-mode .ai-chat-footer {
  background: rgba(26, 26, 26, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-input-container {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.ai-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.ai-input-wrapper input {
  flex: 1;
  border: 2px solid rgba(226, 232, 240, 0.5);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.3s ease;
  background: rgba(248, 249, 250, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.ai-input-wrapper input:focus {
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(70, 179, 118, 0.1);
}

.ai-send-btn {
  background: var(--color-primary);
  color: white;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
}

.ai-send-btn:hover {
  background: var(--color-secondary);
  transform: translateY(-2px);
}

.ai-send-loader {
  display: none;
  position: absolute;
}

.ai-send-btn.loading .ai-send-loader {
  display: block;
}

.ai-send-btn.loading i {
  display: none;
}

.ai-loader-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* اقتراحات سريعة */
.ai-chat-suggestions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-suggestion-btn {
  background: rgba(70, 179, 118, 0.1);
  color: var(--color-primary);
  border: 1px solid rgba(70, 179, 118, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.ai-suggestion-btn:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-1px);
}

/* ============================================= */
/* 💭 تصميم الرسائل المتطور */
/* ============================================= */

.ai-message {
  display: flex;
  gap: 10px;
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-message-bot {
  align-self: flex-start;
}

.ai-message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-message-avatar {
  width: 35px;
  height: 35px;
  flex-shrink: 0;
}

.ai-message-face {
  width: 100%;
  height: 100%;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
}

/* تصميم ألماس للمستخدم */
.ai-user-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.ai-diamond-shape {
  width: 35px;
  height: 35px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  transform: rotate(45deg);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ai-diamond-shape::before {
  content: '💎';
  transform: rotate(-45deg);
  font-size: 1.1rem;
}

.ai-user-label {
  font-size: 0.65rem;
  color: var(--color-muted);
  font-weight: 500;
  white-space: nowrap;
}

.ai-message-content {
  flex: 1;
  max-width: 80%;
}

.ai-message-bubble {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 9px 10px;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.ai-message-bot .ai-message-bubble {
  border-bottom-left-radius: 6px;
  background: rgba(70, 179, 118, 0.1);
}

.ai-message-user .ai-message-bubble {
  border-bottom-right-radius: 6px;
  background: rgba(252, 195, 22, 0.15);
  color: var(--color-text);
}

.ai-message-text {
  line-height: 1.5;
  font-size: 14px;
}

.ai-message-text strong {
  font-weight: 700;
}

/* ============================================= */
/* ⏰ توقيت الرسائل وأزرار التفاعل */
/* ============================================= */

.ai-message-time {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 8px;
  opacity: 0.8;
}

.ai-message-time i {
  font-size: 0.7rem;
}

.ai-message-user .ai-message-time {
  color: var(--color-muted);
}

/* أزرار التفاعل مع الرسائل */
.ai-message-actions {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ai-message-bot:hover .ai-message-actions {
  opacity: 1;
}

.ai-message-action {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--color-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 0.8rem;
}

.ai-message-action:hover {
  background: var(--color-primary);
  color: white;
  transform: scale(1.1);
  border-color: var(--color-primary);
}

.ai-message-action.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

/* ============================================= */
/* 🎪 تأثيرات الحركة */
/* ============================================= */

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 
      0 10px 30px rgba(252, 195, 22, 0.4),
      0 0 0 0 rgba(252, 195, 22, 0.7);
  }
  50% {
    box-shadow: 
      0 10px 30px rgba(252, 195, 22, 0.4),
      0 0 0 10px rgba(252, 195, 22, 0);
  }
}

@keyframes float-animation {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes blink {
  0%, 90%, 100% {
    transform: scaleY(1);
  }
  95% {
    transform: scaleY(0.1);
  }
}

@keyframes smile {
  0%, 70%, 100% {
    transform: scaleX(1);
  }
  75%, 85% {
    transform: scaleX(1.2);
  }
}

@keyframes ping {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

@keyframes chatSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes chatSlideDown {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes typingFace {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes typingDots {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-3px);
  }
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes statusPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(76, 175, 80, 0);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes messageSlideInUser {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* تأثيرات الحركة */
@keyframes chatSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes chatSlideDown {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
}

/* تصميم الماس للمستخدم */
.ai-user-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.ai-diamond-shape {
  width: 35px;
  height: 35px;
  background: linear-gradient(135deg, #46b376, #fcc316);
  transform: rotate(45deg);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.ai-diamond-shape::before {
  content: '💎';
  transform: rotate(-45deg);
}

.ai-user-label {
  font-size: 0.65rem;
  color: #718096;
  font-weight: 500;
}

/* ============================================= */
/* 🌙 دعم الوضع الليلي */
/* ============================================= */

.ai-chat-widget.dark-mode .ai-chat-body {
  background: transparent;
}

.ai-chat-widget.dark-mode .ai-message-bubble {
  background: rgba(58, 58, 58, 0.8);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-chat-widget.dark-mode .ai-input-wrapper input {
  background: rgba(45, 45, 45, 0.45);
  color: white;
  border-color: rgba(64, 64, 64, 0.7);
}

.ai-chat-widget.dark-mode .ai-suggestion-btn {
  background: rgba(64, 64, 64, 0.45);
  color: white;
  border-color: rgba(85, 85, 85, 0.5);
}

.ai-chat-widget.dark-mode .ai-typing-indicator.advanced {
  background: rgba(45, 45, 45, 0.45);
  color: white;
}

.ai-chat-widget.dark-mode .ai-message-action {
  background: rgba(58, 58, 58, 0.45);
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.1);
}

.ai-chat-widget.dark-mode .ai-message-action:hover {
  background: var(--color-primary);
  color: white;
}


/* منع تداخل الطبقات فوق الزر */
body, html {
  touch-action: manipulation !important;
}

@media (max-width: 768px) {
  .ai-chat-widget {
    width: 90vw !important;
    height: 60vh !important;
    bottom: 90px !important;
    left: 5vw !important;
    border-radius: 15px !important;
  }
}


/* 🎯 تخصيص ستايل نافذة الشات بوت لشاشات الجوال فقط */
@media (max-width: 768px) {
  .ai-chat-header {
      padding: 6px;
  }

  .ai-chat-info h3 {
      font-size: 14px;
      font-weight: bold;
  }

  .ai-action-btn,
  .ai-close-btn {
      width: 25px;
      height: 25px;
  }

  .ai-input-wrapper input {
      padding: 10px 10px;
  }

  html,
  body,
  button,
  input,
  select,
  textarea {
      text-size-adjust: 90%;
      -webkit-text-size-adjust: 90%;
  }

  .ai-chat-footer {
      padding: 4px;
  }

  .ai-send-btn {
      width: 35px;
      height: 35px;
  }

  .ai-message-bubble {
      padding: 8px 8px;
  }

  .ai-typing-indicator.advanced {
      padding: 8px 10px;
  }
}
.ai-message-bubble a {
  color: var(--color-secondary);
  text-decoration: none;
  font-weight: 600;
}
.ai-message-bubble a:hover { text-decoration: underline; }
.ai-paragraph {
  line-height: 1.7;
  font-weight: 400;
  color: inherit;
}
.ai-divider {
  border: none;
  border-top: 1px solid rgba(0,0,0,0.15);
  margin: 8px 0;
}


/* حركة ظهور رسالة البوت */
.ai-message-bot .ai-message-bubble {
  animation: botPop .28s cubic-bezier(.2,.7,.3,1) both;
  transform-origin: bottom right;
}
@keyframes botPop {
  0%   { transform: translateY(8px) scale(.98); opacity: 0; }
  100% { transform: none;                             opacity: 1; }
}

/* تحسين حركة فتح/إغلاق النافذة (لو غير موجودة) */
@keyframes chatSlideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes chatSlideDown {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(12px); opacity: 0; }
}

/* 🧱 إخفاء كامل عند التعطيل */
.ai-hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* 🎨 تخصيص شريط التمرير لرسائل المساعد */
.ai-messages-container {
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary) transparent; /* ← اللون الأساسي */
}

/* لأن المتصفحات المختلفة تختلف */
.ai-messages-container::-webkit-scrollbar {
  width: 8px;
}
.ai-messages-container::-webkit-scrollbar-thumb {
  background-color: var(--color-primary); /* ← اللون الأساسي */
  border-radius: 10px;
}
.ai-messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.ai-message-time {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px; /* مسافة ثابتة بين الوقت والعلامات */
  font-size: 12px;
  opacity: 0.85;
  white-space: nowrap; /* يمنع نزول الوقت والعلامات لسطر جديد */
}

.ai-time-text {
  direction: ltr; /* لضبط عرض الوقت بشكل صحيح */
}

.ai-checks {
  display: inline-flex;
  align-items: center;
  gap: 0; /* ✅ لا مسافة بين الصحين */
  margin-inline-start: 2px; /* مسافة خفيفة فقط عن الوقت */
}

.ai-checks i {
  font-size: 11px;
  color: #999;
  transform: scale(0.9); /* لتقليل الحجم قليلاً كما في واتساب */
  margin-left: -2px; /* ✅ يجعل الصح الثانية تقترب أكثر */
}
.ai-checks i:last-child {
  transform: translateX(-2px) rotate(-8deg) scale(0.9);
}
