/* ===== SPEED DIAL FAB ===== */
.speed-dial {
  position: fixed;
  bottom: 25px;
  right: 5px;
  z-index: 5000;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0;
}

/* Main trigger button - WHITE with logo */
.sd-main-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: #FFFFFF;
  box-shadow:
    0 8px 28px rgba(192,57,43,0.45),
    0 2px 8px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  z-index: 2;
  overflow: hidden;
}
.sd-main-btn:hover { transform: scale(1.1); box-shadow: 0 12px 35px rgba(192,57,43,0.6); }
.speed-dial.sd-open .sd-main-btn { transform: scale(1.05); }

.sd-main-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  z-index: 1;
  transition: transform 0.3s;
}
.sd-main-btn:hover .sd-main-logo { transform: scale(1.08); }

.sd-main-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
}

/* Pulse rings on main button */
.sd-pulse-ring {
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(192,57,43,0.5);
  animation: sdPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes sdPulse {
  0%   { transform: scale(0.9); opacity: 0; }
  50%  { opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Sub-items container — opens ABOVE the main button */
.sd-items {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
  pointer-events: none;
}

/* Each sub-item: label on LEFT, icon on RIGHT */
.sd-item {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px) scale(0.7);
  transition: opacity 0.3s, transform 0.3s;
  position: relative;
}
/* Staggered delays */
.speed-dial.sd-open .sd-item:nth-child(1) { opacity: 1; transform: translateY(0) scale(1); transition-delay: 0s; }
.speed-dial.sd-open .sd-item:nth-child(2) { opacity: 1; transform: translateY(0) scale(1); transition-delay: 0.06s; }
.speed-dial.sd-open .sd-item:nth-child(3) { opacity: 1; transform: translateY(0) scale(1); transition-delay: 0.12s; }
.speed-dial.sd-open .sd-item:nth-child(4) { opacity: 1; transform: translateY(0) scale(1); transition-delay: 0.18s; }

/* Label chip — hidden */
.sd-label { display: none; }

/* Sub buttons */
.sd-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s;
  flex-shrink: 0;
}
.sd-btn:hover { transform: scale(1.18); }

/* Chat sub-button - RED gradient with robot */
.sd-chat-btn {
  background: linear-gradient(135deg, #C0392B 0%, #7B241C 100%);
  box-shadow: 0 6px 20px rgba(192,57,43,0.5);
  color: white;
}
.sd-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

/* WhatsApp */
.sd-whatsapp-btn {
  background: #25D366;
  box-shadow: 0 6px 20px rgba(37,211,102,0.45);
}
/* Facebook */
.sd-facebook-btn {
  background: #1877F2;
  box-shadow: 0 6px 20px rgba(24,119,242,0.45);
}
/* Instagram */
.sd-instagram-btn {
  background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%);
  box-shadow: 0 6px 20px rgba(214,36,159,0.45);
}

@media (max-width: 480px) {
  .speed-dial { bottom: 20px; right: 0px; }
  .sd-main-btn { width: 56px; height: 56px; }
  .sd-btn { width: 44px; height: 44px; }
}

/* ===== AI CHAT AGENT ===== */

.chat-fab-icon .chat-ai-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: #27AE60;
  border-radius: 50%;
  border: 2px solid white;
  animation: chatBlink 2s ease infinite;
}
@keyframes chatBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.85); }
}

/* ===== CHAT WINDOW ===== */
.chat-window {
  position: fixed;
  bottom: 110px;
  right: 5px;
  width: 360px;
  height: 520px;
  background: #FFFFFF;
  border-radius: 28px;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.18),
    0 8px 30px rgba(192,57,43,0.12),
    0 0 0 1px rgba(192,57,43,0.1);
  z-index: 4999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85) translateY(20px);
  transform-origin: bottom right;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-window.open {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #C0392B 0%, #7B241C 100%);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.chat-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.chat-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.chat-header-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  overflow: hidden;
}
.chat-header-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.chat-header-info { flex: 1; position: relative; z-index: 1; }
.chat-header-name {
  color: #fff;
  font-family: 'Tajawal', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  display: block;
}
.chat-header-status {
  color: rgba(255,255,255,0.8);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}
.status-dot {
  width: 7px; height: 7px;
  background: #2ECC71;
  border-radius: 50%;
  animation: chatBlink 1.5s ease infinite;
}
.chat-close-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.3s;
  position: relative; z-index: 1;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.25); }

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #F8F6F3;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(192,57,43,0.3); border-radius: 2px; }

/* Message Bubbles */
.msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  animation: msgSlide 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes msgSlide {
  from { opacity: 0; transform: translateY(15px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.msg.bot { align-self: flex-end; align-items: flex-end; }
.msg.user { align-self: flex-start; align-items: flex-start; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  position: relative;
}
.msg.bot .msg-bubble {
  background: linear-gradient(135deg, #C0392B, #922B21);
  color: white;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 15px rgba(192,57,43,0.25);
}
.msg.user .msg-bubble {
  background: #FFFFFF;
  color: #1A1A1A;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
}
.msg-time {
  font-size: 0.7rem;
  color: #aaa;
  margin-top: 5px;
  font-family: 'Tajawal', sans-serif;
  padding: 0 4px;
}

/* Quick Replies */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}
.quick-reply-btn {
  background: #fff;
  border: 1.5px solid rgba(192,57,43,0.35);
  color: #C0392B;
  padding: 7px 14px;
  border-radius: 20px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
}
.quick-reply-btn:hover {
  background: #C0392B;
  color: white;
  border-color: #C0392B;
  transform: scale(1.04);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: #FFFFFF;
  border-radius: 18px;
  border-bottom-right-radius: 5px;
  width: fit-content;
  align-self: flex-end;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.typing-dot {
  width: 7px; height: 7px;
  background: #C0392B;
  border-radius: 50%;
  animation: typingBounce 1.2s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; background: #922B21; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; background: #7B241C; }
@keyframes typingBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Chat Input */
.chat-input-area {
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.06);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: #F8F6F3;
  border: 1.5px solid rgba(0,0,0,0.08);
  border-radius: 20px;
  padding: 11px 16px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  color: #1A1A1A;
  outline: none;
  resize: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.3s, box-shadow 0.3s;
  direction: rtl;
  line-height: 1.5;
}
.chat-input:focus {
  border-color: rgba(192,57,43,0.5);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.1);
}
.chat-input::placeholder { color: #aaa; }
.chat-send-btn {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #C0392B, #922B21);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(192,57,43,0.4);
  flex-shrink: 0;
}
.chat-send-btn:hover { transform: scale(1.1) rotate(-10deg); box-shadow: 0 6px 20px rgba(192,57,43,0.5); }

/* Powered by */
.chat-footer-brand {
  text-align: center;
  padding: 8px;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.7rem;
  color: #bbb;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.04);
}
.chat-footer-brand span { color: #C0392B; font-weight: 700; }

@media (max-width: 480px) {
  .chat-window { width: calc(100vw - 20px); right: 5px; bottom: 100px; }
}
