/* ==============================================================================
   مساعد أمان بيتك الذكي (Smart Chatbot CSS)
   تصميم عربي أنيق متوافق بنسبة 100% مع شاشات الهواتف وهوية أمان بيتك
   ============================================================================== */

:root {
  --bot-primary: #E65C00;
  --bot-primary-hover: #CC5200;
  --bot-primary-light: #FFF4EC;
  --bot-dark: #1F2428;
  --bot-gray-bg: #F8FAFC;
  --bot-border: #EAE3D9;
  --bot-shadow: 0 10px 30px rgba(230, 92, 0, 0.22);
  --bot-radius-bubble: 18px;
}

/* 1. الحاوية العامة للزر العائم */
.chatbot-launcher-wrapper {
  position: fixed;
  bottom: 74px; /* فوق شريط التنقل السفلي */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px; /* ليتطابق مع إطار الهاتف بالضبط */
  pointer-events: none;
  z-index: 998;
  display: flex;
  justify-content: flex-start; /* الزر يظهر بالزاوية اليسرى */
  padding: 0 16px;
  box-sizing: border-box;
}

/* زر إطلاق الشات بوت العائم */
.chatbot-launcher-btn {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #FF7A00 0%, #E65C00 100%);
  color: #FFFFFF;
  border: none;
  padding: 10px 16px 10px 12px;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(230, 92, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.chatbot-launcher-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(230, 92, 0, 0.45);
}

.chatbot-launcher-btn:active {
  transform: translateY(1px) scale(0.97);
}

.chatbot-launcher-icon-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.chatbot-launcher-icon-wrap img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* شارة النبض الخضراء (أونلاين) */
.chatbot-online-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  background-color: #22C55E;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
}

.chatbot-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  border: 2px solid rgba(230, 92, 0, 0.6);
  animation: botPulse 2.4s infinite ease-out;
  pointer-events: none;
}

@keyframes botPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.2); opacity: 0; }
}

/* 2. طبقة التعتيم الخلفية (Backdrop Overlay) */
.chatbot-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chatbot-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 3. صندوق نافذة الشات بوت المنبثقة */
.chatbot-modal {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 110%);
  width: 100%;
  max-width: 480px;
  height: 82vh;
  max-height: 660px;
  min-height: 480px;
  background: #FFFFFF;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
}

.chatbot-modal.active {
  transform: translate(-50%, 0);
}

/* هيدر نافذة الشات */
.chatbot-header {
  background: linear-gradient(135deg, #1F2428 0%, #2A333D 100%);
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #E65C00;
  flex-shrink: 0;
}

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

.chatbot-avatar-container {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #FFFFFF;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatbot-avatar-container img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chatbot-header-text h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #FFFFFF;
}

.chatbot-header-text p {
  font-size: 0.72rem;
  margin: 2px 0 0;
  color: #CBD5E1;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-live-badge {
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: #22C55E;
  border-radius: 50%;
  box-shadow: 0 0 6px #22C55E;
}

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

.chatbot-action-icon-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.chatbot-action-icon-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* 4. منطقة الرسائل (Chat Messages Body) */
.chatbot-messages-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #FAF6F0;
  background-image: radial-gradient(#E8DFC8 0.75px, transparent 0.75px);
  background-size: 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* شريط الأمان العلوي الصغير */
.chatbot-trust-banner {
  align-self: center;
  background: rgba(230, 92, 0, 0.08);
  border: 1px dashed rgba(230, 92, 0, 0.3);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.72rem;
  color: #B34700;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
}

/* سطر الرسالة الواحدة */
.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
}

.chat-row.bot {
  justify-content: flex-start;
}

.chat-row.user {
  justify-content: flex-end;
}

/* صورة البوت المصغرة بجانب رسائله */
.chat-bot-mini-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #FFFFFF;
  padding: 2px;
  border: 1px solid #FFD8BE;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.chat-bot-mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* فقاعة الرسالة (Bubble) */
.chat-bubble {
  max-width: 82%;
  padding: 11px 15px;
  font-size: 0.88rem;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
}

.chat-row.bot .chat-bubble {
  max-width: 90%;
  width: fit-content;
  background: #FFFFFF;
  color: #1F2428;
  border: 1px solid #EDE6DD;
  border-radius: 18px 18px 18px 4px;
  box-sizing: border-box;
}

/* عندما تحتوي الفقاعة على خيارات تفاعلية أو كروت خدمات تشغل العرض المتاح بالكامل دون أي فيضان */
.chat-row.bot .chat-bubble:has(.chat-inline-options-wrap),
.chat-row.bot .chat-bubble:has(.chat-action-card),
.chat-bubble.has-options {
  width: 100% !important;
  max-width: calc(100% - 36px) !important;
  padding: 12px 14px;
}

.chat-row.user .chat-bubble {
  background: linear-gradient(135deg, #FF7A00 0%, #E65C00 100%);
  color: #FFFFFF;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(230, 92, 0, 0.25);
}

/* تنسيق النصوص داخل الرد */
.chat-bubble p {
  margin: 0 0 8px;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}
.chat-bubble strong {
  color: #E65C00;
  font-weight: 800;
}
.chat-row.user .chat-bubble strong {
  color: #FFF;
}

/* وقت الرسالة */
.chat-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 0.68rem;
  margin-top: 6px;
  opacity: 0.85;
}

.chat-time-badge {
  direction: ltr !important;
  unicode-bidi: isolate;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.chat-list-item {
  margin: 5px 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.45;
}

/* كارد إجراء الحجز المباشر (Booking Action Card) */
.chat-action-card {
  margin-top: 10px;
  background: #FFF9F3;
  border: 1.5px solid #FFD8BE;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(230, 92, 0, 0.08);
}

.chat-action-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-action-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #E65C00;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.chat-action-card-details h4 {
  font-size: 0.88rem;
  font-weight: 800;
  color: #1F2428;
  margin: 0;
}

.chat-action-card-details span {
  font-size: 0.72rem;
  color: #64748B;
  display: block;
}

.chat-action-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.chat-action-badge {
  background: #FFFFFF;
  border: 1px solid #FFE4D0;
  color: #E65C00;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-action-card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #FF7A00 0%, #E65C00 100%);
  color: #FFFFFF !important;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(230, 92, 0, 0.22);
}

.chat-action-card-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(230, 92, 0, 0.3);
}

/* مؤشر جاري الكتابة (Typing Indicator) */
.chat-typing-bubble {
  background: #FFFFFF;
  border: 1px solid #EDE6DD;
  border-radius: 16px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  background-color: #E65C00;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

/* 5. خيارات وأقسام الخدمات التفاعلية داخل المحادثة (Inline Chat Options & Services) */
.chat-inline-options-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.chat-inline-options-header {
  font-size: 0.74rem;
  font-weight: 800;
  color: #64748B;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.chat-inline-options-header i {
  color: #FF5F00;
  font-size: 0.78rem;
}

/* قائمة كروت الخدمات التفاعلية داخل المحادثة - تصميم عمودي أنيق يمنع أي فيضان */
.chat-inline-services-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.chat-inline-service-btn {
  background: #FFFFFF;
  border: 1.5px solid #EDE6DD;
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: right;
  font-family: inherit;
  color: #1F2428;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.chat-inline-service-btn:hover,
.chat-inline-service-btn:active {
  background: #FFF9F3;
  border-color: #FF5F00;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 95, 0, 0.12);
}

.chat-inline-service-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.chat-inline-service-btn:hover .chat-inline-service-icon {
  transform: scale(1.08);
}

.chat-inline-service-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  text-align: right;
  gap: 2px;
}

.chat-inline-service-name {
  font-size: 0.84rem;
  font-weight: 800;
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.chat-inline-service-sub {
  font-size: 0.68rem;
  color: #64748B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chat-inline-service-btn:hover .chat-inline-service-name {
  color: #FF5F00;
}

.chat-inline-service-arrow {
  font-size: 0.72rem;
  color: #CBD5E1;
  margin-right: auto;
  margin-inline-start: auto;
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.chat-inline-service-btn:hover .chat-inline-service-arrow {
  transform: translateX(-3px);
  color: #FF5F00;
}

/* صف الخيارات الفرعية والاستفسارات السريعة (Chips) */
.chat-inline-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.chat-inline-chip-btn {
  background: #FAF6F0;
  border: 1px solid #EAE3D9;
  color: #334155;
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.chat-inline-chip-btn:hover,
.chat-inline-chip-btn:active {
  background: #FFF4EC;
  border-color: #FF5F00;
  color: #FF5F00;
  transform: translateY(-1px);
}

.chat-inline-chip-btn.cta {
  background: linear-gradient(135deg, #FF7A00 0%, #E65C00 100%);
  color: #FFFFFF !important;
  border: none;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(230, 92, 0, 0.25);
}

.chat-inline-chip-btn.cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(230, 92, 0, 0.35);
  color: #FFFFFF;
}

/* إخفاء شريط الأزرار الخارجي السفلي لظهور الخيارات داخل المحادثة مباشرة */
.chatbot-chips-bar {
  display: none !important;
}

/* 6. شريط الإدخال السفلي (Input Area) */
.chatbot-input-bar {
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #FFFFFF;
  border-top: 1px solid #EDE6DD;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chatbot-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chatbot-input-field {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid #EAE3D9;
  border-radius: 9999px;
  font-size: 0.86rem;
  font-family: inherit;
  color: #1F2428;
  background: #FAF8F5;
  outline: none;
  transition: all 0.2s ease;
}

.chatbot-input-field:focus {
  border-color: #E65C00;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(230, 92, 0, 0.12);
}

.chatbot-input-field::placeholder {
  color: #94A3B8;
  font-size: 0.8rem;
}

/* زر الميكروفون الصوتي داخل حقل الإدخال */
.chatbot-voice-btn {
  position: absolute;
  left: 6px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #8C959F;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.chatbot-voice-btn:hover {
  color: #E65C00;
  background: #FFF4EC;
}

.chatbot-voice-btn.recording {
  color: #DC2626;
  background: #FEE2E2;
  animation: pulseMic 1s infinite alternate;
}

@keyframes pulseMic {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

/* زر الإرسال */
.chatbot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #FF7A00 0%, #E65C00 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 12px rgba(230, 92, 0, 0.3);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(230, 92, 0, 0.4);
}

.chatbot-send-btn:active {
  transform: scale(0.94);
}

/* الشاشات الصغيرة جداً */
@media (max-width: 360px) {
  .chatbot-launcher-btn span {
    display: none;
  }
  .chatbot-launcher-btn {
    padding: 8px;
    border-radius: 50%;
  }
}
