/* NexaDigital — website chat widget (external file: the CSP hash allowlist
   forbids new inline scripts; this file needs 'self' in script-src and
   style-src — see the updated .htaccess shipped with this build).
   The bubble sits bottom-inline-end — OPPOSITE the floating WhatsApp
   button (.wa-float, bottom-inline-start) so the two never overlap. */

.nx-chat-bubble {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 22px;
  z-index: 60;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D63FF, #2543D8);
  background: linear-gradient(135deg, var(--blue, #3D63FF), var(--blue-d, #2543D8));
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 16px 34px -12px rgba(61, 99, 255, .75);
  transition: transform .24s cubic-bezier(.22, .68, .24, 1);
  padding: 0;
}
.nx-chat-bubble:hover { transform: scale(1.06); }
.nx-chat-bubble:focus-visible { outline: 3px solid rgba(61, 99, 255, .5); outline-offset: 2px; }
.nx-chat-bubble svg { width: 26px; height: 26px; fill: #fff; }
.nx-chat-bubble .nx-ico-close { display: none; }
.nx-chat-bubble.nx-open .nx-ico-chat { display: none; }
.nx-chat-bubble.nx-open .nx-ico-close { display: block; }
.nx-chat-bubble::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(61, 99, 255, .55);
  animation: nx-pulse 2.8s ease-out infinite;
}
.nx-chat-bubble.nx-open::before { display: none; }
@keyframes nx-pulse { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }

.nx-chat-panel {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 90px;
  z-index: 60;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 40px 100px -40px rgba(7, 10, 22, .55);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ar, 'Cairo', system-ui, sans-serif);
  direction: rtl;
  text-align: right;
}
.nx-chat-panel.nx-open { display: flex; }

.nx-chat-head {
  background: #0C1224;
  background: var(--ink2, #0C1224);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.nx-chat-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3D63FF, #12C2AE);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 19px;
  flex-shrink: 0;
}
.nx-chat-title { flex: 1; min-width: 0; }
.nx-chat-title b { display: block; font-size: 15px; line-height: 1.4; }
.nx-chat-title span { display: block; font-size: 12px; color: #5FE3D2; color: var(--teal-l, #5FE3D2); }
.nx-chat-title span::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #12C2AE;
  margin-inline-end: 5px;
  vertical-align: 1px;
}
.nx-chat-x {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  opacity: .8;
}
.nx-chat-x:hover { opacity: 1; }

.nx-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #F6F7FB;
  background: var(--paper, #F6F7FB);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nx-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.nx-msg-agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #E2E7F1;
  border: 1px solid var(--line, #E2E7F1);
  color: #070A16;
  border-start-start-radius: 4px;
}
.nx-msg-user {
  align-self: flex-end;
  background: #3D63FF;
  background: var(--blue, #3D63FF);
  color: #fff;
  border-end-end-radius: 4px;
}
.nx-msg-error {
  align-self: center;
  background: #FFF3F0;
  border: 1px solid #FFD9D0;
  color: #9A3B26;
  font-size: 13px;
  max-width: 95%;
  text-align: center;
}

.nx-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #E2E7F1;
  border: 1px solid var(--line, #E2E7F1);
  border-radius: 14px;
  border-start-start-radius: 4px;
  padding: 12px 14px;
  display: flex;
  gap: 5px;
}
.nx-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7C88A0;
  background: var(--muted, #7C88A0);
  animation: nx-bounce 1.2s infinite;
}
.nx-typing i:nth-child(2) { animation-delay: .15s; }
.nx-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes nx-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.nx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  background: #F6F7FB;
  background: var(--paper, #F6F7FB);
}
.nx-chip {
  border: 1px solid #3D63FF;
  border: 1px solid var(--blue, #3D63FF);
  background: #fff;
  color: #2543D8;
  color: var(--blue-d, #2543D8);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.nx-chip:hover { background: #EBEFFF; background: var(--blue-t, #EBEFFF); }

.nx-chat-wa {
  display: none;
  margin: 0 14px 10px;
  background: #25D366;
  color: #0B3D22;
  border-radius: 12px;
  padding: 11px 14px;
  text-align: center;
  font-weight: 700;
  font-size: 14.5px;
  text-decoration: none;
}
.nx-chat-wa.nx-show { display: block; }
.nx-chat-wa:hover { filter: brightness(1.05); }

.nx-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #E2E7F1;
  border-top: 1px solid var(--line, #E2E7F1);
  background: #fff;
  flex-shrink: 0;
}
.nx-chat-input {
  flex: 1;
  border: 1px solid #E2E7F1;
  border: 1px solid var(--line, #E2E7F1);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  min-width: 0;
  background: #F6F7FB;
  background: var(--paper, #F6F7FB);
}
.nx-chat-input:focus { border-color: #3D63FF; border-color: var(--blue, #3D63FF); background: #fff; }
.nx-chat-input:disabled { opacity: .6; }
.nx-chat-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #3D63FF;
  background: var(--blue, #3D63FF);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  padding: 0;
}
.nx-chat-send svg { width: 19px; height: 19px; fill: #fff; transform: scaleX(-1); }
.nx-chat-send:disabled { opacity: .5; cursor: default; }

.nx-chat-foot {
  padding: 7px 12px 9px;
  text-align: center;
  font-size: 11.5px;
  color: #7C88A0;
  color: var(--muted, #7C88A0);
  background: #fff;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .nx-chat-panel {
    inset-inline-end: 12px;
    bottom: 84px;
    width: calc(100vw - 24px);
    height: min(560px, calc(100vh - 110px));
  }
  .nx-chat-bubble { inset-inline-end: 12px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .nx-chat-bubble::before, .nx-typing i { animation: none; }
}
