/* ============================================================
   SYNTRIX AI Chatbot — chatbot.css
   Premium floating AI chatbot UI
   ============================================================ */

/* ============ Chatbot Variables ============ */
:root {
  --cb-navy: #0a1020;
  --cb-navy-deep: #060a14;
  --cb-navy-light: #0e1730;
  --cb-blue: #2f7dff;
  --cb-blue-light: #4d90ff;
  --cb-cyan: #17d8ff;
  --cb-cyan-light: #4fe6ff;
  --cb-white: #eaf1ff;
  --cb-dim: #9fb0cc;
  --cb-faint: #6b7c99;
  --cb-line: rgba(120, 160, 230, 0.14);
  --cb-glass: rgba(13, 20, 38, 0.82);
  --cb-glass-strong: rgba(10, 16, 30, 0.92);
  --cb-grad: linear-gradient(120deg, #4d90ff, #17d8ff);
  --cb-radius: 16px;
  --cb-radius-sm: 12px;
  --cb-font-en: "Inter", system-ui, -apple-system, sans-serif;
  --cb-font-ar: "Cairo", "Inter", system-ui, sans-serif;
  --cb-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --cb-ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-lang="ar"] {
  --cb-font-body: var(--cb-font-ar);
}
[data-lang="en"] {
  --cb-font-body: var(--cb-font-en);
}

/* ============ Floating Button ============ */
.syntrix-chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--cb-grad);
  color: #04121f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(47, 125, 255, 0.45),
    0 0 60px rgba(23, 216, 255, 0.15);
  transition: transform 0.35s var(--cb-ease), box-shadow 0.35s var(--cb-ease);
  animation: cbPulse 3s ease-in-out infinite;
}

[data-lang="ar"] .syntrix-chat-fab {
  right: auto;
  left: 28px;
}

@keyframes cbPulse {
  0%,
  100% {
    box-shadow: 0 8px 32px rgba(47, 125, 255, 0.45),
      0 0 60px rgba(23, 216, 255, 0.15);
  }
  50% {
    box-shadow: 0 8px 40px rgba(47, 125, 255, 0.6),
      0 0 80px rgba(23, 216, 255, 0.25);
  }
}

.syntrix-chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 44px rgba(47, 125, 255, 0.55),
    0 0 80px rgba(23, 216, 255, 0.3);
}

.syntrix-chat-fab:active {
  transform: scale(0.96);
}

.syntrix-chat-fab.is-open {
  animation: none;
  background: rgba(13, 20, 38, 0.8);
  border: 1.5px solid var(--cb-cyan);
  color: var(--cb-cyan);
}

.syntrix-chat-fab.is-open:hover {
  background: rgba(23, 216, 255, 0.12);
}

.syntrix-chat-fab svg {
  width: 28px;
  height: 28px;
  transition: transform 0.3s var(--cb-ease);
}

.syntrix-chat-fab.is-open svg {
  transform: rotate(90deg);
}

/* ============ WhatsApp Floating Button ============ */
.syntrix-wa-fab {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #25d366;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 8px 32px rgba(37, 211, 102, 0.4);
  transition: transform 0.35s var(--cb-ease), box-shadow 0.35s var(--cb-ease),
    bottom 0.35s var(--cb-ease), opacity 0.25s var(--cb-ease),
    visibility 0.25s var(--cb-ease);
  animation: waFabPulse 3s ease-in-out infinite;
}

[data-lang="ar"] .syntrix-wa-fab {
  right: auto;
  left: 28px;
}

#syntrixChatbot:has(.syntrix-chat-fab.is-open) .syntrix-wa-fab {
  bottom: calc(100px + min(580px, 100vh - 140px) + 14px);
  right: 28px;
  left: auto;
}

@keyframes waFabPulse {
  0%,
  100% {
    box-shadow: 0 8px 32px rgba(37, 211, 102, 0.4);
  }
  50% {
    box-shadow: 0 8px 44px rgba(37, 211, 102, 0.55);
  }
}

.syntrix-wa-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 44px rgba(37, 211, 102, 0.55);
}

.syntrix-wa-fab:active {
  transform: scale(0.96);
}

.syntrix-wa-fab svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

@media (max-width: 640px) {
  .syntrix-wa-fab {
    bottom: 88px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  [data-lang="ar"] .syntrix-wa-fab {
    right: auto;
    left: 20px;
  }

  #syntrixChatbot:has(.syntrix-chat-fab.is-open) .syntrix-wa-fab {
    bottom: 88px;
    right: 20px;
    left: auto;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5);
    pointer-events: none;
  }

  .syntrix-wa-fab svg {
    width: 28px;
    height: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .syntrix-wa-fab {
    animation: none;
  }
}

/* ============ Chat Window ============ */
.syntrix-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 8999;
  width: 400px;
  height: 580px;
  max-height: calc(100vh - 140px);
  border-radius: 20px;
  background: var(--cb-glass-strong);
  border: 1px solid var(--cb-line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(47, 125, 255, 0.1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.35s var(--cb-ease), visibility 0.35s,
    transform 0.35s var(--cb-ease);
}

[data-lang="ar"] .syntrix-chat-window {
  right: auto;
  left: 28px;
}

.syntrix-chat-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ============ Chat Header ============ */
.syntrix-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: linear-gradient(
    135deg,
    rgba(47, 125, 255, 0.12),
    rgba(23, 216, 255, 0.06)
  );
  border-bottom: 1px solid var(--cb-line);
  flex-shrink: 0;
}

.syntrix-chat-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cb-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.syntrix-chat-header-icon svg {
  width: 22px;
  height: 22px;
  color: #04121f;
}

.syntrix-chat-header-info {
  flex: 1;
  min-width: 0;
}

.syntrix-chat-header-name {
  font-family: var(--cb-font-en);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--cb-white);
}

.syntrix-chat-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--cb-dim);
  margin-top: 2px;
}

.syntrix-chat-header-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.syntrix-chat-header-subtitle {
  font-size: 0.7rem;
  color: var(--cb-faint);
  margin-top: 1px;
}

/* ============ Messages Area ============ */
.syntrix-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.syntrix-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.syntrix-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.syntrix-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(120, 160, 230, 0.2);
  border-radius: 4px;
}
.syntrix-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 160, 230, 0.35);
}

/* ============ Message Bubbles ============ */
.syntrix-chat-msg {
  display: flex;
  flex-direction: column;
  animation: msgFadeIn 0.35s var(--cb-ease);
}

.syntrix-chat-msg.is-user {
  align-items: flex-end;
}

.syntrix-chat-msg.is-bot {
  align-items: flex-start;
}

[data-lang="ar"] .syntrix-chat-msg.is-user {
  align-items: flex-start;
}
[data-lang="ar"] .syntrix-chat-msg.is-bot {
  align-items: flex-end;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.syntrix-chat-msg-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.syntrix-chat-msg.is-bot .syntrix-chat-msg-bubble {
  background: rgba(47, 125, 255, 0.08);
  border: 1px solid rgba(47, 125, 255, 0.15);
  color: var(--cb-white);
  border-bottom-left-radius: 4px;
}

[data-lang="ar"] .syntrix-chat-msg.is-bot .syntrix-chat-msg-bubble {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

.syntrix-chat-msg.is-user .syntrix-chat-msg-bubble {
  background: var(--cb-grad);
  color: #04121f;
  border-bottom-right-radius: 4px;
}

[data-lang="ar"] .syntrix-chat-msg.is-user .syntrix-chat-msg-bubble {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

.syntrix-chat-msg-label {
  font-size: 0.68rem;
  color: var(--cb-faint);
  margin-bottom: 4px;
  padding: 0 4px;
  font-family: var(--cb-font-en);
  letter-spacing: 0.03em;
}

.syntrix-chat-msg.is-user .syntrix-chat-msg-label {
  text-align: right;
}

[data-lang="ar"] .syntrix-chat-msg.is-user .syntrix-chat-msg-label {
  text-align: left;
}

/* ============ Typing Indicator ============ */
.syntrix-chat-typing {
  display: none;
  align-items: flex-start;
  padding: 0;
}

.syntrix-chat-typing.is-visible {
  display: flex;
}

.syntrix-chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: rgba(47, 125, 255, 0.08);
  border: 1px solid rgba(47, 125, 255, 0.15);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

[data-lang="ar"] .syntrix-chat-typing-dots {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

.syntrix-chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cb-cyan);
  animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ============ Suggested Questions ============ */
.syntrix-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
  animation: msgFadeIn 0.4s var(--cb-ease);
}

.syntrix-chat-suggestions.is-hidden {
  display: none;
}

.syntrix-chat-suggestion {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--cb-line);
  background: rgba(120, 160, 230, 0.04);
  color: var(--cb-dim);
  font-size: 0.82rem;
  font-family: var(--cb-font-body);
  cursor: pointer;
  transition: all 0.25s var(--cb-ease);
  white-space: nowrap;
}

.syntrix-chat-suggestion:hover {
  border-color: var(--cb-cyan);
  color: var(--cb-white);
  background: rgba(23, 216, 255, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(23, 216, 255, 0.12);
}

/* ============ Chat Input ============ */
.syntrix-chat-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--cb-line);
  background: rgba(8, 13, 26, 0.4);
  flex-shrink: 0;
}

.syntrix-chat-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--cb-line);
  background: rgba(8, 13, 26, 0.6);
  color: var(--cb-white);
  font-size: 0.92rem;
  font-family: var(--cb-font-body);
  line-height: 1.4;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.3s, box-shadow 0.3s;
}

[data-lang="ar"] .syntrix-chat-input {
  text-align: right;
  direction: rtl;
}

[data-lang="en"] .syntrix-chat-input {
  text-align: left;
  direction: ltr;
}

.syntrix-chat-input::placeholder {
  color: var(--cb-faint);
}

.syntrix-chat-input:focus {
  outline: none;
  border-color: var(--cb-blue);
  box-shadow: 0 0 0 3px rgba(47, 125, 255, 0.12);
}

.syntrix-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: var(--cb-grad);
  color: #04121f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.25s var(--cb-ease), opacity 0.25s,
    box-shadow 0.25s;
}

.syntrix-chat-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 20px rgba(47, 125, 255, 0.4);
}

.syntrix-chat-send:active {
  transform: scale(0.95);
}

.syntrix-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.syntrix-chat-send svg {
  width: 20px;
  height: 20px;
}

[data-lang="ar"] .syntrix-chat-send svg {
  transform: scaleX(-1);
}

/* ============ Powered By ============ */
.syntrix-chat-powered {
  text-align: center;
  padding: 8px;
  font-size: 0.65rem;
  color: var(--cb-faint);
  font-family: var(--cb-font-en);
  letter-spacing: 0.04em;
  border-top: 1px solid rgba(120, 160, 230, 0.06);
  flex-shrink: 0;
}

/* ============ Mobile Responsive ============ */
@media (max-width: 640px) {
  .syntrix-chat-fab {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  [data-lang="ar"] .syntrix-chat-fab {
    right: auto;
    left: 20px;
  }

  .syntrix-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  [data-lang="ar"] .syntrix-chat-window {
    right: 0;
    left: 0;
  }

  .syntrix-chat-msg-bubble {
    max-width: 90%;
  }

  .syntrix-chat-suggestion {
    font-size: 0.78rem;
    padding: 6px 12px;
  }
}

@media (max-width: 380px) {
  .syntrix-chat-msg-bubble {
    max-width: 95%;
  }
}

/* ============ Reduced Motion ============ */
@media (prefers-reduced-motion: reduce) {
  .syntrix-chat-fab {
    animation: none;
  }

  .syntrix-chat-msg {
    animation: none;
  }

  .syntrix-chat-suggestions {
    animation: none;
  }

  .syntrix-chat-typing-dot {
    animation: none;
    opacity: 0.6;
  }

  .syntrix-chat-window {
    transition: none;
  }
}

/* ============ Light Theme ============ */
html[data-theme="light"] {
  --cb-white: #0f172a;
  --cb-dim: #64748b;
  --cb-faint: #94a3b8;
  --cb-line: rgba(15, 23, 42, 0.12);
  --cb-cyan: #0891b2;
  --cb-glass: rgba(255, 255, 255, 0.86);
  --cb-glass-strong: rgba(255, 255, 255, 0.96);
}

html[data-theme="light"] .syntrix-chat-fab.is-open {
  background: rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .syntrix-chat-fab.is-open:hover {
  background: rgba(8, 145, 178, 0.12);
}

html[data-theme="light"] .syntrix-chat-window {
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18),
    0 0 60px rgba(47, 125, 255, 0.08);
}

html[data-theme="light"] .syntrix-chat-header {
  background: linear-gradient(
    135deg,
    rgba(47, 125, 255, 0.08),
    rgba(23, 216, 255, 0.04)
  );
}

html[data-theme="light"] .syntrix-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
}

html[data-theme="light"] .syntrix-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.3);
}

html[data-theme="light"] .syntrix-chat-msg.is-bot .syntrix-chat-msg-bubble {
  background: rgba(47, 125, 255, 0.08);
  border: 1px solid rgba(47, 125, 255, 0.18);
}

html[data-theme="light"] .syntrix-chat-typing-dots {
  background: rgba(47, 125, 255, 0.08);
  border: 1px solid rgba(47, 125, 255, 0.18);
}

html[data-theme="light"] .syntrix-chat-suggestion {
  background: rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .syntrix-chat-suggestion:hover {
  background: rgba(8, 145, 178, 0.08);
}

html[data-theme="light"] .syntrix-chat-input-area {
  background: rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .syntrix-chat-input {
  background: #ffffff;
}

html[data-theme="light"] .syntrix-chat-powered {
  border-top-color: rgba(15, 23, 42, 0.08);
}
