/* NL AI Chatbot — isolated from theme (Woodmart/WooCommerce) */

#nl-chatbot-root,
#nl-chatbot-root *,
#nl-chatbot-root *::before,
#nl-chatbot-root *::after {
  box-sizing: border-box;
}

#nl-chatbot-root {
  --nl-chatbot-primary: #9b1847;
  --nl-chatbot-primary-dark: #7a1238;
  --nl-chatbot-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
  --nl-chatbot-radius: 16px;
  position: fixed;
  z-index: 999999;
  font-family: Cairo, Tahoma, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#nl-chatbot-root.nl-chatbot--bottom-right {
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  left: auto;
}

#nl-chatbot-root.nl-chatbot--bottom-left {
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  left: max(20px, env(safe-area-inset-left, 0px));
  right: auto;
}

#nl-chatbot-root .nl-chatbot__svg {
  display: block;
  flex-shrink: 0;
}

/* Reset theme button/input styles inside widget */
#nl-chatbot-root button,
#nl-chatbot-root textarea {
  font-family: inherit;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

#nl-chatbot-root .nl-chatbot__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  color: inherit;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s ease, opacity 0.15s ease;
}

#nl-chatbot-root .nl-chatbot__icon-btn:hover {
  background: rgba(255, 255, 255, 0.14) !important;
}

#nl-chatbot-root .nl-chatbot__hint-close {
  color: #94a3b8;
}

#nl-chatbot-root .nl-chatbot__hint-close:hover {
  background: rgba(0, 0, 0, 0.05) !important;
  color: #64748b;
}

/* Backdrop */
#nl-chatbot-root .nl-chatbot__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 999998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

#nl-chatbot-root.nl-chatbot--open .nl-chatbot__backdrop {
  opacity: 1;
  visibility: visible;
}

#nl-chatbot-root .nl-chatbot__backdrop[hidden] {
  display: block !important;
}

/* Chat panel — fixed to viewport */
#nl-chatbot-root .nl-chatbot__panel {
  position: fixed;
  z-index: 999999;
  width: min(400px, calc(100vw - 40px));
  height: min(560px, calc(100dvh - 120px));
  background: #fff;
  border-radius: var(--nl-chatbot-radius);
  box-shadow: var(--nl-chatbot-shadow);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
  pointer-events: none;
}

#nl-chatbot-root.nl-chatbot--bottom-right .nl-chatbot__panel {
  right: max(20px, env(safe-area-inset-right, 0px));
  left: auto;
  bottom: max(88px, calc(80px + env(safe-area-inset-bottom, 0px)));
}

#nl-chatbot-root.nl-chatbot--bottom-left .nl-chatbot__panel {
  left: max(20px, env(safe-area-inset-left, 0px));
  right: auto;
  bottom: max(88px, calc(80px + env(safe-area-inset-bottom, 0px)));
}

#nl-chatbot-root.nl-chatbot--open .nl-chatbot__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#nl-chatbot-root .nl-chatbot__panel[hidden] {
  display: none !important;
}

/* Header */
#nl-chatbot-root .nl-chatbot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  background: var(--nl-chatbot-primary);
  color: #fff;
  flex-shrink: 0;
}

#nl-chatbot-root .nl-chatbot__header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#nl-chatbot-root .nl-chatbot__header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

#nl-chatbot-root .nl-chatbot__header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

#nl-chatbot-root .nl-chatbot__title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#nl-chatbot-root .nl-chatbot__close {
  color: #fff;
  flex-shrink: 0;
}

/* Messages */
#nl-chatbot-root .nl-chatbot__messages {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f4f6fb;
}

#nl-chatbot-root .nl-chatbot__bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

#nl-chatbot-root .nl-chatbot__bubble--bot {
  align-self: flex-start;
  background: #fff;
  color: #1e293b;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-right-radius: 4px;
  white-space: normal;
}

#nl-chatbot-root .nl-chatbot__bubble--user {
  align-self: flex-end;
  background: var(--nl-chatbot-primary);
  color: #fff;
  border-bottom-left-radius: 4px;
}

#nl-chatbot-root .nl-chatbot__bubble--typing {
  padding: 12px 16px;
  min-height: 40px;
  display: flex;
  align-items: center;
}

#nl-chatbot-root .nl-chatbot__typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 10px;
}

#nl-chatbot-root .nl-chatbot__typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--nl-chatbot-primary);
  opacity: 0.35;
  animation: nl-chatbot-dot-bounce 1.1s ease-in-out infinite;
}

#nl-chatbot-root .nl-chatbot__typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

#nl-chatbot-root .nl-chatbot__typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes nl-chatbot-dot-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

#nl-chatbot-root .nl-chatbot__bubble--streaming::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-inline-start: 2px;
  vertical-align: text-bottom;
  background: var(--nl-chatbot-primary);
  opacity: 0.7;
  animation: nl-chatbot-cursor 0.9s step-end infinite;
}

#nl-chatbot-root .nl-chatbot__bubble a,
#nl-chatbot-root .nl-chatbot__bubble .nl-chatbot__link {
  color: var(--nl-chatbot-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  word-break: break-word;
}

#nl-chatbot-root .nl-chatbot__bubble a:hover,
#nl-chatbot-root .nl-chatbot__bubble .nl-chatbot__link:hover {
  color: var(--nl-chatbot-primary-dark);
}

#nl-chatbot-root .nl-chatbot__bubble strong {
  font-weight: 700;
}

#nl-chatbot-root .nl-chatbot__bubble ul {
  margin: 8px 0 4px;
  padding: 0 20px 0 0;
  list-style: disc;
}

#nl-chatbot-root .nl-chatbot__bubble li {
  margin: 6px 0;
}

@keyframes nl-chatbot-cursor {
  0%,
  50% {
    opacity: 0.7;
  }
  51%,
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #nl-chatbot-root .nl-chatbot__typing-dots span,
  #nl-chatbot-root .nl-chatbot__bubble--streaming::after {
    animation: none;
  }
}

/* Form */
#nl-chatbot-root .nl-chatbot__form {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e8ecf3;
  background: #fff;
  flex-shrink: 0;
}

#nl-chatbot-root .nl-chatbot__input {
  flex: 1;
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  resize: none !important;
  overflow-y: auto;
  border: 1px solid #d8dee9 !important;
  border-radius: 12px !important;
  padding: 10px 14px !important;
  font-size: 16px !important;
  line-height: 1.45 !important;
  background: #fff !important;
  color: #1e293b !important;
  box-shadow: none !important;
}

#nl-chatbot-root .nl-chatbot__input:focus {
  outline: none !important;
  border-color: var(--nl-chatbot-primary) !important;
  box-shadow: 0 0 0 3px rgba(155, 24, 71, 0.12) !important;
}

#nl-chatbot-root .nl-chatbot__send {
  width: 44px;
  height: 44px;
  border-radius: 12px !important;
  background: var(--nl-chatbot-primary) !important;
  color: #fff !important;
  flex-shrink: 0;
}

#nl-chatbot-root .nl-chatbot__send:hover {
  background: var(--nl-chatbot-primary-dark) !important;
}

#nl-chatbot-root .nl-chatbot__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Predefined-questions dropdown */
#nl-chatbot-root .nl-chatbot__suggest {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e8ecf3;
}

#nl-chatbot-root .nl-chatbot__suggest-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  background: #fff !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--nl-chatbot-primary) !important;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#nl-chatbot-root .nl-chatbot__suggest-toggle:hover {
  background: rgba(155, 24, 71, 0.05) !important;
}

#nl-chatbot-root .nl-chatbot__suggest-chev {
  transition: transform 0.2s ease;
}

#nl-chatbot-root .nl-chatbot__suggest--open .nl-chatbot__suggest-chev {
  transform: rotate(180deg);
}

#nl-chatbot-root .nl-chatbot__suggest-list {
  max-height: 232px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eef1f6;
  background: #f9fafc;
  animation: nl-chatbot-suggest-in 0.2s ease;
}

#nl-chatbot-root .nl-chatbot__suggest-list[hidden] {
  display: none !important;
}

#nl-chatbot-root .nl-chatbot__suggest-item {
  text-align: start;
  background: #fff !important;
  border: 1px solid rgba(155, 24, 71, 0.16) !important;
  border-radius: 12px !important;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.45;
  color: #334155 !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

#nl-chatbot-root .nl-chatbot__suggest-item:hover {
  background: rgba(155, 24, 71, 0.06) !important;
  border-color: var(--nl-chatbot-primary) !important;
}

#nl-chatbot-root .nl-chatbot__suggest-item:active {
  transform: scale(0.99);
}

@keyframes nl-chatbot-suggest-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #nl-chatbot-root .nl-chatbot__suggest-list {
    animation: none;
  }
}

/* FAB launcher */
#nl-chatbot-root .nl-chatbot__fab-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  position: relative;
  z-index: 1000000;
  pointer-events: auto;
}

#nl-chatbot-root.nl-chatbot--bottom-left .nl-chatbot__fab-wrap {
  align-items: flex-start;
}

#nl-chatbot-root .nl-chatbot__hint {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px 12px 40px;
  box-shadow: var(--nl-chatbot-shadow);
  border: 1px solid rgba(155, 24, 71, 0.12);
  max-width: 280px;
  cursor: pointer;
  animation: nl-chatbot-hint-in 0.4s ease;
}

#nl-chatbot-root .nl-chatbot__hint[hidden] {
  display: none !important;
}

#nl-chatbot-root .nl-chatbot__hint-close {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
}

#nl-chatbot-root .nl-chatbot__hint-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 14px;
  color: var(--nl-chatbot-primary);
}

#nl-chatbot-root .nl-chatbot__hint-text {
  margin: 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
}

#nl-chatbot-root .nl-chatbot__fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none !important;
  background: var(--nl-chatbot-primary) !important;
  color: #fff !important;
  cursor: pointer;
  box-shadow: var(--nl-chatbot-shadow);
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#nl-chatbot-root.nl-chatbot--launcher-expanded .nl-chatbot__fab {
  border-radius: 999px;
  padding: 14px 22px;
  min-height: 52px;
}

#nl-chatbot-root.nl-chatbot--launcher-compact .nl-chatbot__fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
}

#nl-chatbot-root.nl-chatbot--launcher-compact .nl-chatbot__fab-label {
  display: none;
}

#nl-chatbot-root .nl-chatbot__fab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  line-height: 0;
}

#nl-chatbot-root .nl-chatbot__fab-icon .nl-chatbot__svg--fab {
  width: 26px;
  height: 26px;
  display: block;
}

#nl-chatbot-root.nl-chatbot--launcher-compact .nl-chatbot__fab-icon,
#nl-chatbot-root.nl-chatbot--launcher-compact .nl-chatbot__fab-icon .nl-chatbot__svg--fab {
  width: 28px;
  height: 28px;
}

#nl-chatbot-root .nl-chatbot__fab:hover {
  transform: translateY(-2px);
}

#nl-chatbot-root.nl-chatbot--open .nl-chatbot__fab-wrap {
  display: none;
}

/* App fullscreen */
body.nl-chatbot-app #nl-chatbot-root.nl-chatbot--in-app.nl-chatbot--open .nl-chatbot__panel {
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
  bottom: 0;
  right: 0;
  left: 0;
}

body.nl-chatbot-open {
  overflow: hidden;
}

/* Above Woodmart app-bottom-nav (~74px + margins) on phones */
@media (max-width: 1024px) {
  #nl-chatbot-root {
    --nl-chatbot-nav-offset: max(
      100px,
      calc(74px + 24px + env(safe-area-inset-bottom, 0px))
    );
  }

  #nl-chatbot-root.nl-chatbot--bottom-right,
  #nl-chatbot-root.nl-chatbot--bottom-left {
    bottom: var(--nl-chatbot-nav-offset) !important;
  }

  #nl-chatbot-root.nl-chatbot--bottom-right .nl-chatbot__panel,
  #nl-chatbot-root.nl-chatbot--bottom-left .nl-chatbot__panel {
    bottom: calc(var(--nl-chatbot-nav-offset) + 72px) !important;
  }
}

@media (max-width: 640px) {
  #nl-chatbot-root.nl-chatbot--open .nl-chatbot__panel {
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
  }
}

@keyframes nl-chatbot-hint-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
