/* Narang AI chat widget */
.narang-ai-root {
  --nai-orange: #F18A1F;
  --nai-cyan: #2EC4B6;
  --nai-ink: #0f1218;
  --nai-panel: rgba(18, 22, 30, 0.96);
  --nai-border: rgba(241, 138, 31, 0.28);
  position: fixed;
  z-index: 1050;
  inset: auto 1.5rem 1.5rem auto;
  font-family: "IBM Plex Sans Arabic", sans-serif;
  direction: rtl;
}

.narang-ai-fab {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 2px solid rgba(241, 138, 31, 0.55);
  border-radius: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #0b0b0b;
  background: #12161f;
  overflow: hidden;
  box-shadow: 0 14px 32px rgba(241, 138, 31, 0.38);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  animation: naranj-fab-in 0.6s 1s both;
  position: relative;
}

.narang-ai-fab:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 18px 40px rgba(241, 138, 31, 0.48);
  border-color: rgba(46, 196, 182, 0.7);
}

.narang-ai-fab-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.narang-ai-fab .nai-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #25d366;
  box-shadow: 0 0 0 2px rgba(15, 18, 24, 0.85);
  animation: nai-pulse 1.8s ease infinite;
}

.narang-ai-fab.is-open {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.25);
}

.narang-ai-fab.is-open .narang-ai-fab-img {
  filter: brightness(0.85);
}

@keyframes nai-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.narang-ai-panel {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  right: 0;
  left: auto;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  border-radius: 1.15rem;
  overflow: hidden;
  background: var(--nai-panel);
  border: 1px solid var(--nai-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.narang-ai-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.narang-ai-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(241, 138, 31, 0.28), transparent 55%),
    linear-gradient(180deg, #1b2230, #141922);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.narang-ai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 0.85rem;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(241, 138, 31, 0.4);
  background: #12161f;
}

.narang-ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.narang-ai-title {
  margin: 0;
  color: #fff;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
}

.narang-ai-sub {
  margin: 0.15rem 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.75rem;
}

.narang-ai-close {
  margin-inline-start: auto;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
  width: 32px;
  height: 32px;
  border-radius: 0.6rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.narang-ai-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.narang-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background:
    radial-gradient(80% 50% at 0% 0%, rgba(46, 196, 182, 0.08), transparent 50%),
    #0f131b;
}

.narang-ai-msg {
  max-width: 88%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.9rem;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.narang-ai-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-right-radius: 0.35rem;
}

.narang-ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(241, 138, 31, 0.92), rgba(255, 179, 90, 0.92));
  color: #121212;
  border-bottom-left-radius: 0.35rem;
}

.narang-ai-msg.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 2.4rem;
}

.narang-ai-msg.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: nai-bounce 1s ease infinite;
}

.narang-ai-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.narang-ai-msg.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes nai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.narang-ai-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: #141922;
}

.narang-ai-form input {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  border-radius: 0.75rem;
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
  outline: none;
}

.narang-ai-form input:focus {
  border-color: rgba(241, 138, 31, 0.55);
  box-shadow: 0 0 0 3px rgba(241, 138, 31, 0.15);
}

.narang-ai-form input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.narang-ai-form button[type="submit"] {
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 0.75rem;
  background: var(--nai-orange);
  color: #111;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.narang-ai-form button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.narang-ai-form button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.narang-ai-form button svg {
  width: 18px;
  height: 18px;
}

/* Lift back-to-top above the AI fab (both on the right) */
.site-public.has-narang-ai .site-back-top {
  bottom: 5.6rem;
}

@media (max-width: 575.98px) {
  .narang-ai-root {
    inset: auto 1rem 1rem auto;
  }

  .narang-ai-panel {
    width: calc(100vw - 2rem);
    height: min(70vh, 520px);
  }

  .site-public.has-narang-ai .site-back-top {
    bottom: 5.1rem;
    right: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .narang-ai-fab,
  .narang-ai-fab .nai-dot,
  .narang-ai-msg.typing span {
    animation: none !important;
  }

  .narang-ai-panel {
    transition: none;
  }
}
