/* =========================
   AI CHAT FLOATING BUTTON
========================= */

.ai-chat-trigger {
  position: fixed;
  right: 22px;
  bottom: 22px;

  width: 64px;
  height: 64px;

  border: 0;
  outline: 0;
  border-radius: 22px;

  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  z-index: 1000;

  box-shadow:
    0 12px 35px rgba(0, 0, 0, 0.22),
    0 4px 12px rgba(0, 0, 0, 0.12);

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


/* الأيقونة */
.ai-chat-trigger-icon {
  position: relative;
  z-index: 2;

  width: 44px;
  height: 44px;

  border-radius: 16px;

  display: flex;
  align-items: center;
  justify-content: center;

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

  color: #fff;
  font-size: 23px;

  backdrop-filter: blur(5px);
}


/* Hover */
.ai-chat-trigger:hover {
  transform: translateY(-4px) scale(1.04);

  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.28),
    0 5px 15px rgba(0, 0, 0, 0.14);
}


/* Online dot */
.ai-chat-trigger-status {
  position: absolute;

  right: 3px;
  top: 3px;

  width: 14px;
  height: 14px;

  background: #22c55e;

  border: 3px solid #fff;
  border-radius: 50%;

  z-index: 3;
}


/* النبضة الخارجية */
.ai-chat-trigger-glow {
  position: absolute;

  width: 100%;
  height: 100%;

  border-radius: 22px;

  background: rgba(17, 24, 39, 0.20);

  animation: aiChatPulse 2.2s infinite;

  z-index: -1;
}


@keyframes aiChatPulse {

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

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

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


/* Mobile */
@media (max-width: 576px) {

  .ai-chat-trigger {
    width: 58px;
    height: 58px;

    right: 16px;
    bottom: 92px;

    border-radius: 20px;
  }

  .ai-chat-trigger-icon {
    width: 40px;
    height: 40px;

    border-radius: 14px;

    font-size: 21px;
  }
}

/* ==========================================
   AI CHAT OFFCANVAS
========================================== */

.ai-chat-canvas {
  width: 430px !important;
  max-width: 100%;
  border: 0 !important;
  background: #f8f9fb;
}


/* ================= HEADER ================= */

.ai-chat-header {
  height: 82px;
  min-height: 82px;

  padding: 0 20px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  background: #fff;

  border-bottom: 1px solid #edf0f4;
}


.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}


.ai-chat-avatar {
  position: relative;

  width: 48px;
  height: 48px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 16px;

  background: linear-gradient(135deg, #111827, #374151);

  color: #fff;
  font-size: 19px;

  box-shadow: 0 6px 18px rgba(17, 24, 39, .16);
}


.ai-chat-online {
  position: absolute;

  width: 12px;
  height: 12px;

  right: -2px;
  bottom: 1px;

  background: #22c55e;

  border: 2px solid #fff;
  border-radius: 50%;
}


.ai-chat-header-text h5 {
  margin: 0 0 3px;

  font-size: 15px;
  font-weight: 800;

  color: #111827;
}


.ai-chat-header-text span {
  display: flex;
  align-items: center;
  gap: 5px;

  font-size: 11px;
  color: #6b7280;
}


.ai-chat-header-text span i {
  font-size: 6px;
  color: #22c55e;
}


.ai-chat-close {
  width: 38px;
  height: 38px;

  border: 0;
  border-radius: 12px;

  background: #f3f4f6;

  color: #4b5563;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 18px;

  transition: .2s ease;
}


.ai-chat-close:hover {
  background: #e5e7eb;
  color: #111827;
}


/* ================= MESSAGES ================= */

.ai-chat-messages {
  flex: 1;

  overflow-y: auto;

  padding: 24px 18px 30px;

  direction: rtl;
}


/* Bootstrap offcanvas body structure */
.ai-chat-canvas {
  display: flex;
  flex-direction: column;
}


/* ================= WELCOME ================= */

.ai-welcome {
  text-align: center;

  padding: 30px 20px 25px;
}


.ai-welcome-icon {
  width: 60px;
  height: 60px;

  margin: 0 auto 15px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 20px;

  background: #fff;

  color: #111827;
  font-size: 24px;

  box-shadow: 0 8px 30px rgba(17, 24, 39, .08);
}


.ai-welcome h4 {
  margin-bottom: 8px;

  font-size: 18px;
  font-weight: 800;

  color: #111827;
}


.ai-welcome p {
  margin-bottom: 5px;

  font-size: 14px;
  color: #4b5563;
}


.ai-welcome small {
  font-size: 11px;
  color: #9ca3af;
}


/* ================= MESSAGE ================= */

.ai-message {
  display: flex;
  align-items: flex-start;

  gap: 9px;

  margin-bottom: 15px;
}


.ai-message-avatar {
  width: 30px;
  height: 30px;

  flex: 0 0 30px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;

  background: #111827;

  color: #fff;

  font-size: 11px;
}


.ai-message-content {
  max-width: 82%;

  padding: 11px 14px;

  border-radius: 5px 16px 16px 16px;

  background: #fff;

  color: #374151;

  font-size: 13px;
  line-height: 1.8;

  box-shadow: 0 3px 15px rgba(0, 0, 0, .04);
}


/* ================= IMAGE PREVIEW ================= */

.ai-upload-preview {
  position: relative;

  padding: 10px 18px 0;

  background: #fff;
}


.ai-upload-image {
  width: 65px;
  height: 65px;

  overflow: hidden;

  border-radius: 12px;

  border: 1px solid #e5e7eb;
}


.ai-upload-image img {
  width: 100%;
  height: 100%;

  object-fit: cover;
}


.ai-upload-preview>button {
  position: absolute;

  top: 5px;
  right: 73px;

  width: 22px;
  height: 22px;

  padding: 0;

  border: 0;
  border-radius: 50%;

  background: #111827;

  color: #fff;

  font-size: 10px;
}


/* ================= FOOTER ================= */

.ai-chat-footer {
  padding: 12px 14px 10px;

  background: #fff;

  border-top: 1px solid #edf0f4;
}


.ai-chat-input-box {
  min-height: 54px;

  padding: 6px;

  display: flex;
  align-items: flex-end;

  gap: 4px;

  border: 1px solid #e5e7eb;
  border-radius: 18px;

  background: #f9fafb;

  transition: .2s ease;
}


.ai-chat-input-box:focus-within {
  background: #fff;

  border-color: #cbd5e1;

  box-shadow: 0 0 0 3px rgba(17, 24, 39, .04);
}


/* textarea */

.ai-chat-input-box textarea {
  flex: 1;

  height: 40px;
  max-height: 110px;

  padding: 9px 6px;

  border: 0;
  outline: 0;

  resize: none;

  background: transparent;

  color: #111827;

  font-size: 13px;

  line-height: 21px;
}


.ai-chat-input-box textarea::placeholder {
  color: #9ca3af;
}


/* image / voice buttons */

.ai-input-action {
  width: 40px;
  height: 40px;

  flex: 0 0 40px;

  border: 0;
  border-radius: 12px;

  background: transparent;

  color: #6b7280;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 17px;

  transition: .2s;
}


.ai-input-action:hover {
  background: #e5e7eb;

  color: #111827;
}


/* Send */

.ai-send-button {
  width: 40px;
  height: 40px;

  flex: 0 0 40px;

  border: 0;
  border-radius: 13px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #111827;

  color: #fff;

  font-size: 14px;

  transition: .2s ease;
}


.ai-send-button:hover {
  transform: scale(1.05);

  background: #000;
}


.ai-chat-disclaimer {
  margin-top: 7px;

  text-align: center;

  color: #9ca3af;

  font-size: 9px;
}


/* ================= SCROLLBAR ================= */

.ai-chat-messages::-webkit-scrollbar {
  width: 5px;
}


.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}


.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 20px;
}


/* ================= MOBILE ================= */

@media (max-width: 576px) {

  .ai-chat-canvas {
    width: 100% !important;
  }

  .ai-chat-header {
    height: 72px;
    min-height: 72px;

    padding: 0 15px;
  }

  .ai-chat-avatar {
    width: 43px;
    height: 43px;

    border-radius: 14px;
  }

  .ai-chat-messages {
    padding: 18px 14px 25px;
  }

  .ai-chat-footer {
    padding: 10px;
  }
}

/* ==========================================
   VOICE RECORDING
========================================== */

.ai-voice-button {
  position: relative;
}


/* أثناء الاستماع */
.ai-voice-button.is-listening {
  background: #fee2e2;
  color: #dc2626;

  animation: aiVoicePulse 1.2s infinite;
}


.ai-voice-button.is-listening::before {
  content: '';

  position: absolute;

  inset: -4px;

  border: 2px solid rgba(220, 38, 38, .20);

  border-radius: 15px;

  animation: aiVoiceWave 1.2s infinite;
}


@keyframes aiVoicePulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}


@keyframes aiVoiceWave {

  0% {
    transform: scale(.9);
    opacity: .8;
  }

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

/* ==========================================
   AI TYPING
========================================== */

.ai-typing {
  display: flex;

  align-items: center;

  gap: 4px;

  min-height: 38px;
}


.ai-typing span {
  width: 6px;
  height: 6px;

  background: #9ca3af;

  border-radius: 50%;

  animation: aiTyping 1.2s infinite;
}


.ai-typing span:nth-child(2) {
  animation-delay: .15s;
}


.ai-typing span:nth-child(3) {
  animation-delay: .30s;
}


@keyframes aiTyping {

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

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

}

.ai-send-button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.ai-streaming {
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 20px;
}

.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .35;
  animation: aiTypingDot 1.2s infinite ease-in-out;
}

.ai-typing span:nth-child(2) {
  animation-delay: .15s;
}

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

@keyframes aiTypingDot {

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

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

.ai-saved-image-info {
  margin-bottom: 5px;
  opacity: .7;
}