/* NatureTech customer-support chatbot — vanilla widget styles.
   Tokens align with chrome.css palette: gold #E6B149, ink #1A1628,
   purple-deep #1E1236, green #2D6A4F, cream #F7F3E9, lavender #F0EBF7.
   RTL-aware via inset-inline-start/end. */

/* -------------------- launcher pill (sitewide, ~bottom) -------------------- */

.nt-chat-launcher {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 9990;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #2D6A4F 0%, #6B3FA0 100%);
  color: #fff;
  box-shadow: 0 10px 28px rgba(30, 18, 54, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  font: inherit;
}
.nt-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(30, 18, 54, 0.35);
}
.nt-chat-launcher__icon { display: inline-flex; }
.nt-chat-launcher__badge {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #E6B149;
  color: #1A1628;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  display: none; /* shown when count > 0 */
  align-items: center;
  justify-content: center;
}

/* Hide launcher while chrome's mobile bottom dock is visible to avoid overlap */
@media (max-width: 899px) {
  .nt-chat-launcher { bottom: 80px; }
}

/* -------------------- panel -------------------- */

.nt-chat-panel[hidden] { display: none; }
.nt-chat-panel {
  position: fixed;
  bottom: 24px;
  inset-inline-end: 24px;
  z-index: 9991;
  width: min(420px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 80px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(30, 18, 54, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity 0.18s ease;
  font-family: 'Heebo', 'IBM Plex Sans Hebrew', system-ui, sans-serif;
  color: #1A1628;
}
.nt-chat-panel.is-open { transform: translateY(0) scale(1); opacity: 1; }

@media (max-width: 540px) {
  .nt-chat-panel {
    inset-inline-end: 0;
    inset-inline-start: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
  }
  /* hide the launcher while panel is open on mobile so it doesn't
     overlap the composer. */
  body:has(.nt-chat-panel.is-open) .nt-chat-launcher { display: none; }
}

/* -------------------- panel header -------------------- */

.nt-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #2D6A4F 0%, #6B3FA0 100%);
  color: #F7F3E9;
}
.nt-chat-panel__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}
.nt-chat-panel__title-name {
  font-family: 'IBM Plex Sans Hebrew', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.nt-chat-panel__title-sub {
  font-size: 12px;
  font-weight: 300;
  color: rgba(247, 243, 233, 0.78);
}
.nt-chat-panel__close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: rgba(247, 243, 233, 0.85);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.nt-chat-panel__close:hover { background: rgba(247, 243, 233, 0.14); color: #fff; }

/* -------------------- message list -------------------- */

.nt-chat-panel__list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAF9FC;
}
.nt-chat-panel__list::-webkit-scrollbar { width: 6px; }
.nt-chat-panel__list::-webkit-scrollbar-thumb { background: #D8D3C5; border-radius: 3px; }

.nt-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  max-width: 100%;
}
.nt-chat-msg__bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nt-chat-msg--user { align-items: flex-end; }
.nt-chat-msg--user .nt-chat-msg__bubble {
  background: #1E1236;
  color: #F7F3E9;
  border-bottom-right-radius: 4px; /* tail toward user */
}
[dir="rtl"] .nt-chat-msg--user .nt-chat-msg__bubble {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 4px;
}

.nt-chat-msg--assistant { align-items: flex-start; }
.nt-chat-msg--assistant .nt-chat-msg__bubble {
  background: #fff;
  border: 1px solid #F0EBF7;
  color: #1A1628;
  border-bottom-left-radius: 4px;
  /* Markdown emits explicit <br> tags for line breaks; let normal
     whitespace rules collapse the internal whitespace between HTML
     blocks (lists etc.) instead of preserving every \n. */
  white-space: normal;
}
[dir="rtl"] .nt-chat-msg--assistant .nt-chat-msg__bubble {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}

/* -------------------- markdown inside assistant bubbles -------------------- */
.nt-chat-msg--assistant .nt-chat-msg__bubble strong {
  font-weight: 600;
  color: #1E1236;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble em {
  font-style: italic;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble code {
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: #F0EBF7;
  color: #1E1236;
  padding: 1px 6px;
  border-radius: 4px;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble a {
  color: #6B3FA0;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble a:hover {
  color: #2D6A4F;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble ul,
.nt-chat-msg--assistant .nt-chat-msg__bubble ol {
  margin: 6px 0;
  padding-inline-start: 22px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble li {
  line-height: 1.55;
}
.nt-chat-msg--assistant .nt-chat-msg__bubble ul { list-style: disc; }
.nt-chat-msg--assistant .nt-chat-msg__bubble ol { list-style: decimal; }
/* Trim leading/trailing <br> the renderer can leave around list blocks */
.nt-chat-msg--assistant .nt-chat-msg__bubble > br:first-child,
.nt-chat-msg--assistant .nt-chat-msg__bubble > br:last-child,
.nt-chat-msg--assistant .nt-chat-msg__bubble ul + br,
.nt-chat-msg--assistant .nt-chat-msg__bubble ol + br,
.nt-chat-msg--assistant .nt-chat-msg__bubble br + ul,
.nt-chat-msg--assistant .nt-chat-msg__bubble br + ol {
  display: none;
}

/* "Thinking..." placeholder while the agent is searching the KB / catalog
   before any text arrives. Three bouncing dots in a real bubble shell. */
.nt-chat-msg__bubble.is-pending {
  min-width: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 16px;
}
.nt-chat-msg__bubble.is-pending::before,
.nt-chat-msg__bubble.is-pending::after,
.nt-chat-msg__bubble.is-pending > .nt-chat-dot {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6B3FA0;
  display: inline-block;
  animation: ntChatBounce 1.1s ease-in-out infinite;
}
.nt-chat-msg__bubble.is-pending::before { animation-delay: -0.32s; }
.nt-chat-msg__bubble.is-pending > .nt-chat-dot { animation-delay: -0.16s; }
@keyframes ntChatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* -------------------- suggested questions -------------------- */

.nt-chat-panel__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 18px 12px;
  background: #FAF9FC;
}
.nt-chat-chip {
  background: #fff;
  border: 1px solid #F0EBF7;
  color: #1A1628;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-align: start;
}
.nt-chat-chip:hover {
  border-color: #6B3FA0;
  color: #6B3FA0;
  background: #fff;
}

/* -------------------- composer -------------------- */

.nt-chat-panel__compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid #F0EBF7;
  background: #fff;
}
.nt-chat-panel__input {
  border: 1px solid #D8D3C5;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: #1A1628;
  background: #FAF9FC;
  resize: none;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.nt-chat-panel__input:focus {
  border-color: #6B3FA0;
  box-shadow: 0 0 0 3px rgba(107, 63, 160, 0.12);
}
.nt-chat-panel__input:disabled { opacity: 0.6; cursor: progress; }

/* -------------------- product card (in-chat) -------------------- */

.nt-chat-product-card {
  background: #fff;
  border: 1px solid #F0EBF7;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: 92%;
  align-self: flex-start;
  box-shadow: 0 4px 14px rgba(30, 18, 54, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.nt-chat-product-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(30, 18, 54, 0.1);
}

.nt-chat-product-card--loading {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nt-chat-product-card__skeleton {
  width: 60%;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #F0EBF7 0%, #FAF9FC 50%, #F0EBF7 100%);
  background-size: 200% 100%;
  animation: ntChatSkeleton 1.4s ease-in-out infinite;
}
@keyframes ntChatSkeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.nt-chat-product-card__media {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #F7F3E9 0%, #F0EBF7 100%);
  overflow: hidden;
}
.nt-chat-product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nt-chat-product-card__body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nt-chat-product-card__name {
  font-family: 'IBM Plex Sans Hebrew', sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #1A1628;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nt-chat-product-card__short {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(26, 22, 40, 0.65);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nt-chat-product-card__price-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}
.nt-chat-product-card__price {
  font-family: 'IBM Plex Sans Hebrew', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #1E1236;
}
.nt-chat-product-card__price-old {
  font-size: 12px;
  color: rgba(26, 22, 40, 0.45);
  text-decoration: line-through;
}
.nt-chat-product-card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}
.nt-chat-product-card__btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s, opacity 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.nt-chat-product-card__btn:disabled { opacity: 0.7; cursor: progress; }
.nt-chat-product-card__btn--primary {
  background: linear-gradient(135deg, #2D6A4F 0%, #6B3FA0 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(45, 106, 79, 0.22);
}
.nt-chat-product-card__btn--primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(45, 106, 79, 0.3); color: #fff; }
.nt-chat-product-card__btn--primary.is-success { background: #2D6A4F; }
.nt-chat-product-card__btn--secondary {
  background: #fff;
  color: #6B3FA0;
  border: 1.5px solid #6B3FA0;
}
.nt-chat-product-card__btn--secondary:hover { background: #6B3FA0; color: #fff; }
.nt-chat-product-card__oos {
  font-size: 12px;
  color: #C4203C;
  font-weight: 600;
  margin-top: 4px;
}
[dir="rtl"] .nt-chat-product-card { align-self: flex-start; }

/* Default single-card layout has no nt-chat-product-card__main wrapper
   styles to set. The wrapper is a flex container so image + body share
   the same border radius / overflow behaviour as the card. */
.nt-chat-product-card__main {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}
.nt-chat-product-card__main:hover { color: inherit; text-decoration: none; }

/* -------------------- multi-card horizontal scroll-strip -------------------- */
/* When the agent emits 2+ product_card blocks in a single turn, the widget
   renders them as a horizontal scroll-strip instead of stacking vertically.
   Vertical footprint becomes one ~280px row regardless of card count, so
   text bubbles around the recommendation stay in view. */
.nt-chat-product-strip {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge legacy */
  align-self: stretch;
  width: 100%;
  padding: 4px 2px 6px;
  scroll-padding-inline-start: 4px;
  /* Touch hint: only allow horizontal panning so the page below isn't
     hijacked by accidental vertical drags on the strip. */
  touch-action: pan-x;
}
.nt-chat-product-strip::-webkit-scrollbar { display: none; }

/* Compact card sits inside the strip. Fixed width so the "peek" of the
   next card emerges naturally from container width (~1.8 visible on a
   360px phone, ~2.3 on desktop panel). */
.nt-chat-product-card--compact {
  flex: 0 0 168px;
  max-width: 168px;
  scroll-snap-align: start;
  align-self: stretch;
  margin: 0;
  display: flex;
  flex-direction: column;
}
.nt-chat-product-card--compact .nt-chat-product-card__main {
  flex: 1;
  min-height: 0;
}
.nt-chat-product-card--compact .nt-chat-product-card__media {
  aspect-ratio: 4 / 3;
}
.nt-chat-product-card--compact .nt-chat-product-card__body {
  padding: 8px 10px 6px;
  gap: 4px;
  flex: 1;
}
.nt-chat-product-card--compact .nt-chat-product-card__name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  -webkit-line-clamp: 2;
  min-height: 2.6em; /* keep two lines reserved so card heights match */
}
.nt-chat-product-card--compact .nt-chat-product-card__price {
  font-size: 14px;
}
.nt-chat-product-card--compact .nt-chat-product-card__price-old {
  font-size: 11px;
}
.nt-chat-product-card--compact .nt-chat-product-card__actions {
  display: flex;
  flex-direction: column;
  grid-template-columns: none;
  gap: 0;
  padding: 0 10px 10px;
  margin-top: 0;
}
.nt-chat-product-card--compact .nt-chat-product-card__btn {
  font-size: 12px;
  padding: 9px 10px;
  width: 100%;
  min-height: 40px; /* tap-friendly on mobile */
}
.nt-chat-product-card--compact .nt-chat-product-card__oos {
  padding: 0 10px 10px;
}

/* Skeleton loader inside compact mode (smaller). */
.nt-chat-product-card--compact.nt-chat-product-card--loading {
  height: 240px;
}

/* Tighter peek on small phones so two cards fit comfortably. */
@media (max-width: 380px) {
  .nt-chat-product-card--compact { flex: 0 0 152px; max-width: 152px; }
}

/* Slightly larger cards on desktop where the panel is 420px wide and
   168px would show ~2.3 cards (looks fine but a hair tighter than ideal). */
@media (min-width: 540px) {
  .nt-chat-product-card--compact { flex: 0 0 176px; max-width: 176px; }
}

/* -------------------- in-chat contact form -------------------- */

.nt-chat-inquiry {
  background: #fff;
  border: 1px solid #F0EBF7;
  border-radius: 14px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  width: 100%;
  max-width: 92%;
  box-shadow: 0 4px 14px rgba(30, 18, 54, 0.06);
  box-sizing: border-box;
}
.nt-chat-inquiry__title {
  font-family: 'IBM Plex Sans Hebrew', sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  color: #1A1628;
}
.nt-chat-inquiry__note {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(26, 22, 40, 0.65);
  margin: 0;
}
.nt-chat-inquiry__input,
.nt-chat-inquiry__textarea {
  width: 100%;
  border: 1px solid #D8D3C5;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  color: #1A1628;
  background: #FAF9FC;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.nt-chat-inquiry__textarea {
  resize: vertical;
  min-height: 70px;
  line-height: 1.4;
}
.nt-chat-inquiry__input:focus,
.nt-chat-inquiry__textarea:focus {
  border-color: #6B3FA0;
  box-shadow: 0 0 0 3px rgba(107, 63, 160, 0.12);
}
.nt-chat-inquiry__honeypot {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.nt-chat-inquiry__status {
  font-size: 12px;
  color: rgba(26, 22, 40, 0.65);
  min-height: 0;
}
.nt-chat-inquiry__status.is-error { color: #C4203C; }
.nt-chat-inquiry__submit {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, #2D6A4F 0%, #6B3FA0 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(45, 106, 79, 0.22);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  align-self: flex-start;
}
.nt-chat-inquiry__submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(45, 106, 79, 0.3);
}
.nt-chat-inquiry__submit:disabled { opacity: 0.7; cursor: progress; transform: none; }
.nt-chat-inquiry--ok { border-color: #2D6A4F; background: #F2F8F5; }
.nt-chat-inquiry--ok .nt-chat-inquiry__title { color: #2D6A4F; }

.nt-chat-panel__send {
  width: 44px;
  height: 44px;
  align-self: end;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2D6A4F 0%, #6B3FA0 100%);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 4px 14px rgba(45, 106, 79, 0.22);
}
.nt-chat-panel__send:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(45, 106, 79, 0.3); }
.nt-chat-panel__compose.is-busy .nt-chat-panel__send {
  opacity: 0.6;
  pointer-events: none;
}
[dir="rtl"] .nt-chat-panel__send-icon svg { transform: scaleX(-1); }
