/* ============================================================================
   DQQ Chatbot Widget — premium styles (brand-matched, RTL/LTR, responsive)
   Namespaced under .dqq-cb-* so it never collides with the page's own CSS.
   Brand: primary green #24a259, dark #22303E, light surfaces #F4FAF7/#ebf7f0.
   ========================================================================== */

.dqq-cb-root {
  /* --- design tokens (mirrors the landing page identity) --- */
  --dqq-primary: #24a259;
  --dqq-primary-dark: #1e8e4e;
  --dqq-primary-2: #24A45A;
  --dqq-secondary: #22303E;
  --dqq-surface: #ffffff;
  --dqq-surface-soft: #f4faf7;
  --dqq-surface-soft-2: #ebf7f0;
  --dqq-bot-bubble: #f1f7f3;
  --dqq-bot-text: #22303E;
  --dqq-user-text: #ffffff;
  --dqq-text: #2b3a33;
  --dqq-text-muted: #6a7a72;
  --dqq-border: #e6efe9;
  --dqq-danger: #c0563f;
  --dqq-shadow: 0 18px 50px -12px rgba(34, 48, 62, 0.30), 0 6px 18px -8px rgba(36, 162, 89, 0.18);
  --dqq-radius: 22px;
  --dqq-radius-sm: 14px;
  --dqq-launcher-size: 62px;
  --dqq-font: "Madani Arabic", "IBM Plex Sans Arabic", "SF UI Display", system-ui, -apple-system, "Segoe UI", sans-serif;

  font-family: var(--dqq-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.dqq-cb-root *,
.dqq-cb-root *::before,
.dqq-cb-root *::after { box-sizing: border-box; }

/* ============================== Launcher ================================== */
/* Default (page is RTL/Arabic): existing site FABs sit bottom-LEFT,
   so the chatbot lives bottom-RIGHT to avoid covering them or any CTA. */
.dqq-cb-launcher {
  position: fixed;
  /* raised so it clears the host page's scroll-to-top button (48px @ bottom:30)
     which shares this corner; the existing FABs are in the opposite corner. */
  bottom: 92px;
  inset-inline-end: auto;
  right: 26px;
  left: auto;
  /* above the site's fixed header (z-index:1000000) and all page chrome,
     but below the initial loading splash (z-index:10000000). */
  z-index: 9000001;
  width: var(--dqq-launcher-size);
  height: var(--dqq-launcher-size);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, var(--dqq-primary) 0%, var(--dqq-primary-dark) 100%);
  box-shadow: 0 14px 30px -8px rgba(36, 162, 89, 0.55), 0 4px 10px rgba(34, 48, 62, 0.18);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease, background .3s ease;
  -webkit-tap-highlight-color: transparent;
}
/* On LTR/English pages the site FABs sit bottom-RIGHT → put the bot bottom-LEFT. */
[dir="ltr"] .dqq-cb-launcher,
.dqq-cb-root[data-side="left"] .dqq-cb-launcher {
  right: auto;
  left: 26px;
}

.dqq-cb-launcher:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 20px 38px -8px rgba(36,162,89,.6), 0 6px 14px rgba(34,48,62,.2); }
.dqq-cb-launcher:active { transform: translateY(-1px) scale(.98); }

/* ===== proactive teaser bubble (shown beside the closed launcher) ===== */
.dqq-cb-teaser {
  position: fixed;
  z-index: 9000001;
  bottom: calc(92px + var(--dqq-launcher-size) + 14px);
  right: 26px;
  left: auto;
  max-width: 250px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 14px 34px -10px rgba(34,48,62,.32), 0 3px 10px rgba(34,48,62,.10);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(.96);
  transform-origin: bottom right;
  transition: opacity .35s ease, transform .35s cubic-bezier(.34,1.56,.64,1), visibility .35s;
  -webkit-tap-highlight-color: transparent;
}
[dir="ltr"] .dqq-cb-teaser,
.dqq-cb-root[data-side="left"] .dqq-cb-teaser {
  right: auto; left: 26px; transform-origin: bottom left;
}
.dqq-cb-teaser--show { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.dqq-cb-root.is-open .dqq-cb-teaser { opacity: 0 !important; visibility: hidden !important; }
.dqq-cb-teaser__ava {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, var(--dqq-primary) 0%, var(--dqq-primary-dark) 100%);
}
.dqq-cb-teaser__ava svg { width: 18px; height: 18px; }
.dqq-cb-teaser__txt {
  flex: 1 1 auto;
  font-size: 13.5px; line-height: 1.45; font-weight: 600;
  color: #22303E; padding-top: 4px;
}
.dqq-cb-teaser__x {
  flex: 0 0 auto;
  border: none; background: transparent;
  color: #9aa6b2; font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 2px; border-radius: 6px;
}
.dqq-cb-teaser__x:hover { color: #52606d; background: rgba(34,48,62,.06); }
.dqq-cb-teaser::after {
  content: ""; position: absolute; bottom: -5px; right: 28px;
  width: 12px; height: 12px; background: #fff; transform: rotate(45deg);
  box-shadow: 3px 3px 8px -3px rgba(34,48,62,.16);
}
[dir="ltr"] .dqq-cb-teaser::after,
.dqq-cb-root[data-side="left"] .dqq-cb-teaser::after { right: auto; left: 28px; }
.dqq-cb-launcher:focus-visible { outline: 3px solid rgba(36,162,89,.45); outline-offset: 3px; }

/* idle pulse ring */
.dqq-cb-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--dqq-primary);
  opacity: .55;
  animation: dqq-pulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes dqq-pulse {
  0%   { transform: scale(1);   opacity: .55; }
  70%  { transform: scale(1.6); opacity: 0;   }
  100% { transform: scale(1.6); opacity: 0;   }
}

/* icon swap (chat <-> close) */
.dqq-cb-launcher .dqq-cb-ic {
  position: absolute;
  width: 30px; height: 30px;
  transition: opacity .25s ease, transform .35s cubic-bezier(.34,1.56,.64,1);
}
.dqq-cb-launcher .dqq-cb-ic--close { opacity: 0; transform: rotate(-90deg) scale(.5); }
.dqq-cb-root.is-open .dqq-cb-launcher .dqq-cb-ic--chat  { opacity: 0; transform: rotate(90deg) scale(.5); }
.dqq-cb-root.is-open .dqq-cb-launcher .dqq-cb-ic--close { opacity: 1; transform: rotate(0) scale(1); }
.dqq-cb-root.is-open .dqq-cb-launcher::after { display: none; }

/* unread/attention dot */
.dqq-cb-launcher__dot {
  position: absolute;
  top: 2px; inset-inline-end: 2px; right: 2px; left: auto;
  width: 15px; height: 15px;
  background: #ff5d52;
  border: 2.5px solid #fff;
  border-radius: 50%;
  transform: scale(0);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
[dir="ltr"] .dqq-cb-launcher__dot,
.dqq-cb-root[data-side="left"] .dqq-cb-launcher__dot { right: auto; left: 2px; }
.dqq-cb-root.has-unread .dqq-cb-launcher__dot { transform: scale(1); }
.dqq-cb-root.is-open .dqq-cb-launcher__dot { transform: scale(0); }

/* ============================== Panel ==================================== */
.dqq-cb-panel {
  position: fixed;
  bottom: calc(92px + var(--dqq-launcher-size) + 14px);
  right: 26px; left: auto;
  z-index: 9000002;   /* panel sits above the launcher and the site header */
  width: 384px;
  max-width: calc(100vw - 36px);
  height: 596px;
  max-height: calc(100vh - 130px);
  background: var(--dqq-surface);
  border-radius: var(--dqq-radius);
  box-shadow: var(--dqq-shadow);
  border: 1px solid var(--dqq-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.96);
  transition: opacity .28s ease, transform .34s cubic-bezier(.16,1,.3,1), visibility .28s;
}
[dir="ltr"] .dqq-cb-panel,
.dqq-cb-root[data-side="left"] .dqq-cb-panel {
  right: auto; left: 26px;
  transform-origin: bottom left;
}
.dqq-cb-root.is-open .dqq-cb-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* backdrop — MOBILE ONLY. On desktop the panel is a corner widget, so the
   backdrop must never cover/block the page. It is only activated inside the
   mobile media query below (and never captures pointer events otherwise). */
.dqq-cb-backdrop {
  position: fixed; inset: 0;
  background: rgba(34,48,62,.42);
  backdrop-filter: blur(2px);
  z-index: 9000000;   /* backdrop above page, just under the launcher/panel */
  opacity: 0; visibility: hidden;
  pointer-events: none;
  transition: opacity .3s ease, visibility .3s;
}

/* ------------------------------ Header ----------------------------------- */
.dqq-cb-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--dqq-primary) 0%, var(--dqq-primary-dark) 100%);
  overflow: hidden;
}
.dqq-cb-header::before { /* soft decorative glow */
  content: "";
  position: absolute;
  inset-block-start: -60%;
  inset-inline-end: -10%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 62%);
  pointer-events: none;
}
.dqq-cb-avatar {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  border: 1.5px solid rgba(255,255,255,.45);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.dqq-cb-avatar svg { width: 24px; height: 24px; }
.dqq-cb-avatar__status {
  position: absolute;
  bottom: -1px; inset-inline-end: -1px; right: -1px; left: auto;
  width: 12px; height: 12px;
  background: #34e07a;
  border: 2px solid var(--dqq-primary-dark);
  border-radius: 50%;
}
[dir="ltr"] .dqq-cb-avatar__status { right: auto; left: -1px; }
.dqq-cb-htext { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.dqq-cb-htext h4 { margin: 0; font-size: 15.5px; font-weight: 700; }
.dqq-cb-htext span { display: block; font-size: 11.5px; opacity: .9; font-weight: 400; }
.dqq-cb-hbtns { display: flex; align-items: center; gap: 4px; }
.dqq-cb-iconbtn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s ease, transform .2s ease;
  font-size: 12px; font-weight: 600;
}
.dqq-cb-iconbtn:hover { background: rgba(255,255,255,.26); }
.dqq-cb-iconbtn:active { transform: scale(.92); }
.dqq-cb-iconbtn svg { width: 18px; height: 18px; }
.dqq-cb-iconbtn:focus-visible { outline: 2px solid rgba(255,255,255,.8); outline-offset: 1px; }

/* ------------------------------ Body ------------------------------------- */
.dqq-cb-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px 8px;
  background:
    radial-gradient(120% 60% at 100% 0%, var(--dqq-surface-soft) 0%, transparent 55%),
    var(--dqq-surface);
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dqq-cb-body::-webkit-scrollbar { width: 7px; }
.dqq-cb-body::-webkit-scrollbar-thumb { background: #d6e6dd; border-radius: 10px; }
.dqq-cb-body::-webkit-scrollbar-thumb:hover { background: #bcd8c8; }
.dqq-cb-body { scrollbar-width: thin; scrollbar-color: #d6e6dd transparent; }

/* message row */
.dqq-cb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  animation: dqq-msg-in .32s cubic-bezier(.16,1,.3,1) both;
}
@keyframes dqq-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dqq-cb-msg--bot  { align-self: flex-start; }
.dqq-cb-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.dqq-cb-msg__ava {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--dqq-primary), var(--dqq-primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.dqq-cb-msg__ava svg { width: 16px; height: 16px; }
.dqq-cb-msg--user .dqq-cb-msg__ava { display: none; }
.dqq-cb-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.dqq-cb-msg--bot .dqq-cb-bubble {
  background: var(--dqq-bot-bubble);
  color: var(--dqq-bot-text);
  border-start-start-radius: 5px;
}
.dqq-cb-msg--user .dqq-cb-bubble {
  background: linear-gradient(145deg, var(--dqq-primary) 0%, var(--dqq-primary-dark) 100%);
  color: var(--dqq-user-text);
  border-start-end-radius: 5px;
  box-shadow: 0 6px 14px -6px rgba(36,162,89,.5);
}
.dqq-cb-bubble a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.dqq-cb-msg--bot .dqq-cb-bubble a { color: var(--dqq-primary-dark); }
.dqq-cb-bubble strong { font-weight: 700; }

/* inline CTA buttons inside a bot message */
.dqq-cb-cta-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.dqq-cb-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid var(--dqq-primary);
  color: var(--dqq-primary-dark);
  background: #fff;
  transition: background .2s, color .2s, transform .15s;
}
.dqq-cb-cta:hover { background: var(--dqq-primary); color: #fff; transform: translateY(-1px); }
.dqq-cb-cta--solid { background: linear-gradient(145deg,var(--dqq-primary),var(--dqq-primary-dark)); color:#fff; }
.dqq-cb-cta--solid:hover { color: #fff; filter: brightness(1.05); }

/* typing indicator */
.dqq-cb-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.dqq-cb-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dqq-primary);
  opacity: .5;
  animation: dqq-bounce 1.3s infinite ease-in-out;
}
.dqq-cb-typing span:nth-child(2) { animation-delay: .18s; }
.dqq-cb-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes dqq-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* --------------------------- Suggestions --------------------------------- */
.dqq-cb-suggests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px 6px;
}
.dqq-cb-suggests--intro { margin-top: 2px; }
.dqq-cb-chip {
  border: 1.5px solid var(--dqq-border);
  background: #fff;
  color: var(--dqq-primary-dark);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12.8px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.3;
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
}
.dqq-cb-chip:hover {
  background: var(--dqq-surface-soft-2);
  border-color: var(--dqq-primary);
  transform: translateY(-1px);
  box-shadow: 0 5px 12px -6px rgba(36,162,89,.4);
}
.dqq-cb-chip:active { transform: translateY(0); }
.dqq-cb-chip:focus-visible { outline: 2px solid rgba(36,162,89,.5); outline-offset: 2px; }

/* ------------------------------ Footer ----------------------------------- */
.dqq-cb-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--dqq-border);
  background: #fff;
  padding: 10px 12px 8px;
}
.dqq-cb-inputrow {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--dqq-surface-soft);
  border: 1.5px solid var(--dqq-border);
  border-radius: 16px;
  padding: 6px 6px 6px 14px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.dqq-cb-inputrow:focus-within {
  border-color: var(--dqq-primary);
  box-shadow: 0 0 0 3px rgba(36,162,89,.12);
}
.dqq-cb-input {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dqq-text);
  max-height: 96px;
  padding: 6px 0;
}
.dqq-cb-input::placeholder { color: var(--dqq-text-muted); }
.dqq-cb-send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--dqq-primary), var(--dqq-primary-dark));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, opacity .2s ease, filter .2s;
}
.dqq-cb-send svg { width: 19px; height: 19px; }
.dqq-cb-send:hover:not(:disabled) { filter: brightness(1.07); transform: scale(1.05); }
.dqq-cb-send:active:not(:disabled) { transform: scale(.94); }
.dqq-cb-send:disabled { opacity: .45; cursor: not-allowed; }
.dqq-cb-send:focus-visible { outline: 2px solid rgba(36,162,89,.5); outline-offset: 2px; }

.dqq-cb-foot-note {
  text-align: center;
  font-size: 10.5px;
  color: var(--dqq-text-muted);
  padding: 6px 4px 2px;
  margin: 0;
}
.dqq-cb-foot-note b { color: var(--dqq-primary-dark); font-weight: 700; }

/* gentle inline error */
.dqq-cb-error {
  align-self: center;
  max-width: 92%;
  text-align: center;
  font-size: 12.5px;
  color: var(--dqq-danger);
  background: #fcefea;
  border: 1px solid #f3d6cc;
  border-radius: 12px;
  padding: 8px 12px;
  line-height: 1.5;
}

/* ============================== Mobile =================================== */
@media (max-width: 480px) {
  .dqq-cb-panel {
    right: 12px; left: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-width: none;
    height: 82vh;
    max-height: calc(100vh - 24px);
    border-radius: 20px;
  }
  [dir="ltr"] .dqq-cb-panel,
  .dqq-cb-root[data-side="left"] .dqq-cb-panel { right: 12px; left: 12px; }
  .dqq-cb-launcher { bottom: 86px; right: 18px; }
  [dir="ltr"] .dqq-cb-launcher,
  .dqq-cb-root[data-side="left"] .dqq-cb-launcher { right: auto; left: 18px; }
  /* the dimming backdrop is enabled ONLY on mobile, where the panel is a sheet */
  .dqq-cb-root.is-open .dqq-cb-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
  .dqq-cb-teaser { bottom: calc(86px + var(--dqq-launcher-size) + 12px); right: 18px; max-width: calc(100vw - 92px); }
  [dir="ltr"] .dqq-cb-teaser,
  .dqq-cb-root[data-side="left"] .dqq-cb-teaser { right: auto; left: 18px; }
}

/* very short screens */
@media (max-height: 560px) {
  .dqq-cb-panel { height: calc(100vh - 90px); }
}

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .dqq-cb-root *,
  .dqq-cb-root *::before,
  .dqq-cb-root *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .12s !important;
  }
}
