/* ===== Aldebawwe AI Chat Widget ===== */

.aldebawwe-chat-root {

  position: fixed;

  z-index: 9500;

  bottom: 24px;

  right: 24px;

  font-family: var(--font, 'Tajawal', sans-serif);

  touch-action: none;

}



html[dir="ltr"] .aldebawwe-chat-root {

  right: 24px;

  left: auto;

}



.aldebawwe-chat-root.is-positioned {

  bottom: auto;

  right: auto;

}



/* Launcher — زر + نص (قابل للسحب قبل فتح الشات) */
.aldebawwe-chat-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: grab;
  user-select: none;
  flex-direction: row-reverse;
}

html[dir="ltr"] .aldebawwe-chat-launcher {
  flex-direction: row;
}

.aldebawwe-chat-root.is-dragging .aldebawwe-chat-launcher,
.aldebawwe-chat-root.is-dragging .aldebawwe-chat-header {
  cursor: grabbing;
}

.aldebawwe-chat-fab-label {
  display: inline-block;
  max-width: 200px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: #f0f4ff;
  background: linear-gradient(135deg, rgba(15, 20, 32, 0.95) 0%, rgba(30, 40, 70, 0.92) 100%);
  border: 1px solid rgba(102, 126, 234, 0.45);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* FAB */
.aldebawwe-chat-fab {

  width: 58px;

  height: 58px;

  border-radius: 50%;

  border: none;

  cursor: pointer;

  background: linear-gradient(135deg, #667eea 0%, #2d6a9f 55%, #764ba2 100%);

  color: #fff;

  font-size: 22px;

  box-shadow: 0 8px 28px rgba(102, 126, 234, 0.45);

  transition: transform 0.25s ease, box-shadow 0.25s ease;

  display: flex;

  align-items: center;

  justify-content: center;

  position: relative;

}



.aldebawwe-chat-fab:hover:not(:active) {
  transform: scale(1.06);
  box-shadow: 0 12px 36px rgba(102, 126, 234, 0.55);
}

.aldebawwe-chat-root.is-dragging .aldebawwe-chat-fab:hover {
  transform: none;
}



.aldebawwe-chat-fab .fab-pulse {

  position: absolute;

  inset: -4px;

  border-radius: 50%;

  border: 2px solid rgba(102, 126, 234, 0.5);

  animation: chatFabPulse 2s ease-out infinite;

  pointer-events: none;

}



@keyframes chatFabPulse {

  0% { transform: scale(1); opacity: 0.8; }

  100% { transform: scale(1.35); opacity: 0; }

}



.aldebawwe-chat-root.is-open .aldebawwe-chat-launcher {
  display: none;
}

/* Panel — مخفي عند الإغلاق */

.aldebawwe-chat-panel {

  width: 360px;

  max-width: calc(100vw - 32px);

  height: 480px;

  max-height: calc(100vh - 48px);

  background: linear-gradient(165deg, #0f1420 0%, #121a2e 100%);

  border: 1px solid rgba(102, 126, 234, 0.28);

  border-radius: 20px;

  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 40px rgba(102, 126, 234, 0.12);

  display: flex;

  flex-direction: column;

  overflow: hidden;

  opacity: 0;

  visibility: hidden;

  transform: scale(0.92) translateY(12px);

  transform-origin: bottom right;

  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;

}



html[dir="ltr"] .aldebawwe-chat-panel {

  transform-origin: bottom right;

}



.aldebawwe-chat-root.is-open .aldebawwe-chat-panel {

  opacity: 1;

  visibility: visible;

  transform: scale(1) translateY(0);

}



/* Header — drag handle */

.aldebawwe-chat-header {

  display: flex;

  align-items: center;

  gap: 10px;

  padding: 12px 14px;

  background: linear-gradient(135deg, rgba(102, 126, 234, 0.22) 0%, rgba(45, 106, 159, 0.18) 100%);

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);

  cursor: grab;

  user-select: none;

  flex-shrink: 0;

}



.aldebawwe-chat-header:active {

  cursor: grabbing;

}



.aldebawwe-chat-header img {

  width: 36px;

  height: 36px;

  border-radius: 10px;

  object-fit: contain;

  background: rgba(255, 255, 255, 0.08);

  padding: 4px;

}



.aldebawwe-chat-header-info {

  flex: 1;

  min-width: 0;

}



.aldebawwe-chat-header-info strong {

  display: block;

  font-size: 14px;

  font-weight: 700;

  color: #f0f4ff;

  line-height: 1.3;

}



.aldebawwe-chat-header-info span {

  font-size: 11px;

  color: #94a3b8;

  display: flex;

  align-items: center;

  gap: 5px;

}



.aldebawwe-chat-header-info .status-dot {

  width: 7px;

  height: 7px;

  border-radius: 50%;

  background: #10b981;

  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);

  flex-shrink: 0;

}



.aldebawwe-chat-header-actions {

  display: flex;

  gap: 4px;

}



.aldebawwe-chat-header-actions button {

  width: 32px;

  height: 32px;

  border: none;

  border-radius: 8px;

  background: rgba(255, 255, 255, 0.08);

  color: #94a3b8;

  cursor: pointer;

  font-size: 13px;

  transition: background 0.2s, color 0.2s;

}



.aldebawwe-chat-header-actions button:hover {

  background: rgba(255, 255, 255, 0.14);

  color: #fff;

}



/* Messages */

.aldebawwe-chat-messages {

  flex: 1;

  overflow-y: auto;

  padding: 14px;

  display: flex;

  flex-direction: column;

  gap: 10px;

  scroll-behavior: smooth;

}



.aldebawwe-chat-messages::-webkit-scrollbar {

  width: 5px;

}



.aldebawwe-chat-messages::-webkit-scrollbar-thumb {

  background: rgba(102, 126, 234, 0.35);

  border-radius: 4px;

}



.chat-msg {

  max-width: 88%;

  padding: 10px 14px;

  border-radius: 14px;

  font-size: 13.5px;

  line-height: 1.65;

  animation: chatMsgIn 0.3s ease;

}



@keyframes chatMsgIn {

  from { opacity: 0; transform: translateY(6px); }

  to { opacity: 1; transform: translateY(0); }

}



.chat-msg-bot {

  align-self: flex-start;

  background: rgba(255, 255, 255, 0.06);

  border: 1px solid rgba(255, 255, 255, 0.07);

  color: #e2e8f0;

  border-bottom-left-radius: 4px;

}



html[dir="rtl"] .chat-msg-bot {

  border-bottom-left-radius: 14px;

  border-bottom-right-radius: 4px;

}



.chat-msg-user {

  align-self: flex-end;

  background: linear-gradient(135deg, #667eea 0%, #2d6a9f 100%);

  color: #fff;

  border-bottom-right-radius: 4px;

}



html[dir="rtl"] .chat-msg-user {

  border-bottom-right-radius: 14px;

  border-bottom-left-radius: 4px;

}



.chat-msg-typing {

  display: flex;

  gap: 4px;

  padding: 12px 16px;

  align-self: flex-start;

}



.chat-msg-typing span {

  width: 7px;

  height: 7px;

  border-radius: 50%;

  background: #667eea;

  animation: chatTyping 1.2s ease-in-out infinite;

}



.chat-msg-typing span:nth-child(2) { animation-delay: 0.15s; }

.chat-msg-typing span:nth-child(3) { animation-delay: 0.3s; }



@keyframes chatTyping {

  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }

  30% { transform: translateY(-5px); opacity: 1; }

}



/* Quick chips */

.aldebawwe-chat-chips {

  display: flex;

  flex-wrap: wrap;

  gap: 6px;

  padding: 0 14px 10px;

  flex-shrink: 0;

}



.aldebawwe-chat-chip {

  padding: 6px 12px;

  border-radius: 20px;

  border: 1px solid rgba(102, 126, 234, 0.35);

  background: rgba(102, 126, 234, 0.1);

  color: #a5b4fc;

  font-size: 11.5px;

  cursor: pointer;

  transition: background 0.2s, border-color 0.2s;

  font-family: inherit;

}



.aldebawwe-chat-chip:hover {

  background: rgba(102, 126, 234, 0.22);

  border-color: rgba(102, 126, 234, 0.55);

  color: #e0e7ff;

}



/* Input */

.aldebawwe-chat-input-wrap {

  display: flex;

  gap: 8px;

  padding: 12px 14px;

  border-top: 1px solid rgba(255, 255, 255, 0.07);

  background: rgba(0, 0, 0, 0.2);

  flex-shrink: 0;

}



.aldebawwe-chat-input {

  flex: 1;

  border: 1px solid rgba(255, 255, 255, 0.1);

  border-radius: 12px;

  padding: 10px 14px;

  background: rgba(255, 255, 255, 0.05);

  color: #f0f4ff;

  font-size: 13.5px;

  font-family: inherit;

  outline: none;

  transition: border-color 0.2s;

}



.aldebawwe-chat-input:focus {

  border-color: rgba(102, 126, 234, 0.5);

}



.aldebawwe-chat-input::placeholder {

  color: #64748b;

}



.aldebawwe-chat-send {

  width: 42px;

  height: 42px;

  border: none;

  border-radius: 12px;

  background: linear-gradient(135deg, #667eea, #2d6a9f);

  color: #fff;

  cursor: pointer;

  font-size: 16px;

  transition: transform 0.2s, opacity 0.2s;

  flex-shrink: 0;

}



.aldebawwe-chat-send:hover:not(:disabled) {

  transform: scale(1.05);

}



.aldebawwe-chat-send:disabled {

  opacity: 0.45;

  cursor: not-allowed;

}



/* Drag hint */

.aldebawwe-chat-drag-hint {

  text-align: center;

  font-size: 10px;

  color: #475569;

  padding-bottom: 6px;

  flex-shrink: 0;

}



@media (max-width: 768px) {
  .aldebawwe-chat-root {
    right: 12px !important;
    left: auto !important;
    bottom: 12px;
    max-width: calc(100% - 24px);
  }

  .aldebawwe-chat-fab-label {
    max-width: min(160px, calc(100vw - 96px));
    font-size: 12px;
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .aldebawwe-chat-fab-label {
    display: none;
  }

  .aldebawwe-chat-root {

    bottom: 16px;

    right: 16px;

  }



  .aldebawwe-chat-panel {

    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);

    height: min(480px, calc(100vh - 32px));

  }

}


