/* NΞW LΞVΞL AI assistant — bottom-left so it clears WhatsApp / avatar / scroll-top on the right */

.nl-ai-chat {
  --nl-red: #cf2127;
  --nl-red-dark: #ac1211;
  --nl-grad: linear-gradient(135deg, #cf2127 0%, #d9383e 55%, #ac1211 100%);
  --nl-ink: #1a1a1c;
  --nl-muted: #6b7280;
  --nl-border: rgba(0, 0, 0, 0.08);
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  right: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 99999997;
  font-family: inherit;
}

.nl-ai-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.2rem 0.8rem 0.95rem;
  border: 0;
  border-radius: 999px;
  background: var(--nl-grad);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 34px rgba(172, 18, 17, 0.4), 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.nl-ai-chat__launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(172, 18, 17, 0.5), 0 6px 16px rgba(0, 0, 0, 0.18);
}

.nl-ai-chat__launcher:focus-visible {
  outline: 3px solid rgba(207, 33, 39, 0.45);
  outline-offset: 3px;
}

.nl-ai-chat__launcher[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.nl-ai-chat__launcher-icon {
  display: inline-flex;
  width: 1.5rem;
  height: 1.5rem;
  align-items: center;
  justify-content: center;
}

.nl-ai-chat__panel {
  position: absolute;
  left: 0;
  right: auto;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - 2rem));
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(172, 18, 17, 0.1);
  overflow: hidden;
  transform-origin: bottom left;
  animation: nl-ai-chat-in 0.24s ease;
}

.nl-ai-chat__panel[hidden] {
  display: none !important;
}

@keyframes nl-ai-chat-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nl-ai-chat__header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, #1a1a1c 0%, #2a0d0e 60%, #5a0b0c 100%);
  color: #fff;
  border-bottom: 3px solid var(--nl-red);
}

.nl-ai-chat__avatar {
  display: inline-flex;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(207, 33, 39, 0.6);
}

.nl-ai-chat__avatar img {
  width: 72%;
  height: auto;
  margin: 0;
}

.nl-ai-chat__header-text {
  flex: 1;
  min-width: 0;
}

.nl-ai-chat__title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.nl-ai-chat__subtitle {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.72);
}

.nl-ai-chat__close {
  display: inline-flex;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

.nl-ai-chat__close:hover {
  background: var(--nl-red);
}

.nl-ai-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: linear-gradient(180deg, #f7f7f9 0%, #fff 100%);
}

.nl-ai-chat__welcome {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--nl-border);
  border-inline-start: 3px solid var(--nl-red);
  color: #444;
  font-size: 0.85rem;
  line-height: 1.6;
}

.nl-ai-chat__bubble {
  max-width: 88%;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.6;
  word-break: break-word;
}

.nl-ai-chat__bubble--user {
  align-self: flex-end;
  background: var(--nl-grad);
  color: #fff;
  border-end-end-radius: 4px;
}

.nl-ai-chat__bubble--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--nl-border);
  color: var(--nl-ink);
  border-end-start-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.nl-ai-chat__bubble--assistant a {
  color: var(--nl-red);
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.nl-ai-chat__bubble--error {
  align-self: stretch;
  max-width: 100%;
  background: rgba(220, 53, 69, 0.08);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #a3172a;
}

.nl-ai-chat__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--nl-border);
}

.nl-ai-chat__typing span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--nl-red);
  animation: nl-ai-chat-dot 1.2s infinite ease-in-out;
}

.nl-ai-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.nl-ai-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes nl-ai-chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.nl-ai-chat__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 1rem 0.2rem;
  background: #fff;
}

.nl-ai-chat__chip {
  border: 1px solid rgba(207, 33, 39, 0.3);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  background: #fff;
  color: var(--nl-red);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nl-ai-chat__chip:hover {
  background: var(--nl-red);
  color: #fff;
}

.nl-ai-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  background: #fff;
  border-top: 1px solid var(--nl-border);
}

.nl-ai-chat__input {
  flex: 1;
  min-height: 2.5rem;
  max-height: 7rem;
  resize: none;
  border: 1px solid #e4e4e7;
  border-radius: 12px;
  padding: 0.6rem 0.85rem;
  background: #fafafa;
  color: var(--nl-ink);
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.45;
}

.nl-ai-chat__input:focus {
  outline: none;
  border-color: var(--nl-red);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(207, 33, 39, 0.15);
}

.nl-ai-chat__send {
  display: inline-flex;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: var(--nl-grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(172, 18, 17, 0.3);
}

html[dir="rtl"] .nl-ai-chat__send i {
  transform: scaleX(-1);
}

.nl-ai-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

body.site-cart-drawer-open .nl-ai-chat {
  visibility: hidden;
  pointer-events: none;
}

body.nl-ai-chat-open .nl-ai-chat {
  z-index: 100000000;
}

@media (max-width: 767px) {
  body.nl-ai-chat-open .site-whatsapp-float,
  body.nl-ai-chat-open .chat-icon,
  body.nl-ai-chat-open .fixed_alert,
  body.nl-ai-chat-open .up_btn {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

@media (max-width: 575px) {
  .nl-ai-chat {
    left: 14px;
    bottom: 14px;
  }

  .nl-ai-chat__launcher-label {
    display: none;
  }

  .nl-ai-chat__launcher {
    width: 3.25rem;
    height: 3.25rem;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .nl-ai-chat__panel {
    width: calc(100vw - 1.75rem);
    height: min(78vh, 600px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nl-ai-chat__panel,
  .nl-ai-chat__typing span {
    animation: none;
  }

  .nl-ai-chat__launcher {
    transition: none;
  }
}
