/* STELLA Multi-Store Widget v2.2 — SIIL Ostomy Crystal Glass Editorial Palette
 * 100% First-Party Self-Hosted across siilostomy.com, siilostomy.org, ostomybelt.org & ostomybagcovers.com.
 * All classes prefixed stella- to avoid collisions with storefront CSS. */

.stella-root {
  --stella-ink: #0f0f0f;
  --stella-ink-hover: #222220;
  --stella-canvas: #faf8f4;
  --stella-surface: #ffffff;
  --stella-border: #e6e2da;
  --stella-border-strong: #d5cfc4;
  --stella-gold: #b89b6a;
  --stella-live: #1b8f4f;
  --stella-muted: #6e6a63;
  --stella-ease: cubic-bezier(0.32, 0.72, 0, 1);

  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2147483645;
  font-family: "Albert Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  letter-spacing: -0.008em;
  font-variant-numeric: tabular-nums;
  color: var(--stella-ink);
  pointer-events: none;
  -webkit-font-smoothing: antialiased;
}

/* Left-docked mode for siilostomy.com (clears bottom-right scroll-top & aligns with PDP buy-bar chat button) */
.stella-root.stella-dock-left {
  right: auto;
  left: 20px;
}

/* Language-hint bar lift on siilostomy.com (composite transform = 0.00 CLS) */
html.siil-lh-bar-on .stella-root.stella-dock-left:not(.stella-is-open) {
  transform: translateY(calc(-1 * var(--siil-lh-bar-offset, 48px)));
}

/* Storefront overlay & checkout guards (never cover Cart Drawer, Checkout, Order-Pay, Popups, or Ambassador pages) */
body.siil-drawer-open .stella-root:not(.stella-is-open),
body.woocommerce-checkout .stella-root,
body.woocommerce-order-pay .stella-root,
body:has(.siil-cg-page) .stella-root,
body:has(.cmplz-cookiebanner.cmplz-show:not(.cmplz-hidden):not(.cmplz-dismissed)) .stella-root:not(.stella-is-open) {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.stella-root * { box-sizing: border-box; }

/* Mobile Backdrop Veil (tap outside to close cleanly) */
.stella-veil {
  display: none;
}

/* Launcher Bubble */
.stella-bubble {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  background: var(--stella-ink);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.24), 0 1px 3px rgba(15, 15, 15, 0.12);
  transition: transform .18s var(--stella-ease), background-color .18s ease, box-shadow .18s ease, opacity .18s ease;
  margin-left: auto;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stella-root.stella-dock-left .stella-bubble {
  margin-left: 0;
  margin-right: auto;
}
.stella-bubble:hover {
  background: var(--stella-ink-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 15, 15, 0.30);
}
.stella-bubble:active { transform: scale(0.96); }
.stella-bubble:focus-visible { outline: 2px solid var(--stella-gold); outline-offset: 3px; }
.stella-unread-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--stella-live);
  color: #ffffff;
  border: 2px solid var(--stella-surface);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(15, 15, 15, 0.22);
}

/* Panel */
.stella-panel {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  width: 386px;
  max-width: calc(100vw - 32px);
  height: 568px;
  max-height: calc(var(--stella-vvh, 100dvh) - 44px);
  background: var(--stella-surface);
  border: 1px solid var(--stella-border);
  border-radius: 18px;
  box-shadow: 0 20px 52px rgba(15, 15, 15, 0.22), 0 2px 8px rgba(15, 15, 15, 0.08);
  overflow: hidden;
  animation: stella-panel-in .2s var(--stella-ease);
}
@keyframes stella-panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.stella-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--stella-ink);
  color: #ffffff;
  padding: 12px 12px 12px 15px;
  flex: 0 0 auto;
}
.stella-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.stella-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1c1b19;
  border: 1.5px solid var(--stella-gold);
  color: #faf8f4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.stella-header-text { min-width: 0; }
.stella-title {
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.005em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stella-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.80);
  margin-top: 2px;
}
.stella-live-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: var(--stella-live);
  box-shadow: 0 0 0 2px rgba(27, 143, 79, 0.24);
  flex: 0 0 auto;
}
.stella-close {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  transition: background-color .15s ease, color .15s ease, transform .12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stella-close:hover { color: #ffffff; background: rgba(255, 255, 255, 0.18); }
.stella-close:active { transform: scale(0.93); }
.stella-close:focus-visible { outline: 2px solid var(--stella-gold); outline-offset: 1px; }

/* Messages Feed */
.stella-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 15px 14px 12px;
  background: var(--stella-canvas);
}

.stella-msg {
  max-width: 86%;
  padding: 10px 13.5px;
  border-radius: 15px;
  margin-bottom: 10px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.5;
}
.stella-bot {
  background: var(--stella-surface);
  border: 1px solid var(--stella-border);
  border-bottom-left-radius: 5px;
  margin-right: auto;
  color: var(--stella-ink);
  box-shadow: 0 1px 2px rgba(15, 15, 15, 0.03);
}
.stella-user {
  background: var(--stella-ink);
  color: #ffffff;
  border-bottom-right-radius: 5px;
  margin-left: auto;
}

/* Inline & Standalone Link Pills */
.stella-inline-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.stella-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  padding: 6.5px 11.5px;
  border-radius: 999px;
  background: var(--stella-canvas);
  border: 1px solid var(--stella-border-strong);
  color: var(--stella-ink) !important;
  text-decoration: none !important;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  max-width: 100%;
  transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
}
.stella-link-pill:hover {
  background: #f1ede5;
  border-color: var(--stella-gold);
}
.stella-link-pill:active { transform: scale(0.98); }
.stella-link-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stella-link-pill svg { flex: 0 0 auto; opacity: 0.72; }
.stella-bot strong { font-weight: 600; color: var(--stella-ink); }

/* 1-Tap Copyable Coupon Pill */
.stella-coupon-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 1px 2px;
  padding: 2.5px 9px;
  border-radius: 999px;
  background: #f5efe3;
  border: 1px dashed var(--stella-gold);
  color: var(--stella-ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  vertical-align: baseline;
  transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stella-coupon-pill:hover { background: #ede3cf; border-style: solid; }
.stella-coupon-pill:active { transform: scale(0.97); }
.stella-coupon-pill-hint {
  font-weight: 500;
  font-size: 11px;
  color: var(--stella-muted);
}

/* Quick-Start Conversation Chips */
.stella-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 10px;
}
.stella-chip {
  appearance: none;
  background: var(--stella-surface);
  color: var(--stella-ink);
  border: 1px solid var(--stella-border-strong);
  border-radius: 999px;
  padding: 7px 12.5px;
  min-height: 34px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
  transition: background-color .15s ease, border-color .15s ease, transform .12s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stella-chip:hover {
  background: #f3efe7;
  border-color: var(--stella-ink);
}
.stella-chip:active { transform: scale(0.97); }
.stella-chip:focus-visible { outline: 2px solid var(--stella-ink); outline-offset: 1px; }

/* Typing Dots */
.stella-typing { display: inline-flex; gap: 4.5px; align-items: center; padding: 12px 15px; }
.stella-typing span {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: #8c8881;
  animation: stella-blink 1.2s infinite;
}
.stella-typing span:nth-child(2) { animation-delay: .2s; }
.stella-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes stella-blink {
  0%, 80%, 100% { opacity: .28; }
  40% { opacity: 1; }
}

/* Optional Follow-up Email Bar */
.stella-idform {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-top: 1px solid var(--stella-border);
  background: #fdfcf9;
}
.stella-idform-label { margin: 0 0 6px; font-size: 12px; color: var(--stella-muted); }
.stella-idform .stella-input { margin-bottom: 6px; }
.stella-idform-row { display: flex; gap: 8px; align-items: center; }
.stella-idform-save {
  background: var(--stella-ink);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
}
.stella-idform-save:hover { background: var(--stella-ink-hover); }
.stella-idform-skip {
  background: none;
  border: none;
  color: var(--stella-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  padding: 7px 8px;
  border-radius: 6px;
}
.stella-idform-skip:hover { color: var(--stella-ink); background: rgba(15, 15, 15, 0.05); }

/* Auto-Growing Composer Row */
.stella-form {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--stella-border);
  background: var(--stella-surface);
  flex: 0 0 auto;
}
.stella-input {
  width: 100%;
  padding: 9.5px 12px;
  border: 1px solid var(--stella-border-strong);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.42;
  font-family: inherit;
  outline: none;
  background: var(--stella-surface);
  color: var(--stella-ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.stella-input:focus {
  border-color: var(--stella-ink);
  box-shadow: 0 0 0 2px rgba(15, 15, 15, 0.06);
}
.stella-msg-input {
  flex: 1 1 auto;
  min-height: 42px;
  max-height: 98px;
  resize: none;
  overflow-y: auto;
}
.stella-send {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  background: var(--stella-ink);
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  transition: background-color .15s ease, transform .12s ease, opacity .15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stella-send:hover:not(:disabled) { background: var(--stella-ink-hover); }
.stella-send:active:not(:disabled) { transform: scale(0.95); }
.stella-send:disabled { opacity: .42; cursor: default; }
.stella-send:focus-visible { outline: 2px solid var(--stella-gold); outline-offset: 2px; }

/* Subtle Proactive Greeting Nudge (zero-CLS fixed element) */
.stella-nudge-wrap {
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.stella-root.stella-dock-left .stella-nudge-wrap {
  justify-content: flex-start;
}
.stella-nudge {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 286px;
  padding: 10.5px 12.5px;
  border-radius: 15px;
  border-bottom-right-radius: 4px;
  background: var(--stella-surface);
  color: var(--stella-ink);
  border: 1px solid var(--stella-border);
  box-shadow: 0 10px 28px rgba(15, 15, 15, 0.16);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  animation: stella-nudge-in .22s var(--stella-ease);
}
.stella-root.stella-dock-left .stella-nudge {
  border-bottom-right-radius: 15px;
  border-bottom-left-radius: 4px;
}
.stella-nudge:hover { background: var(--stella-canvas); }
.stella-nudge-text { flex: 1 1 auto; }
.stella-nudge-close {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--stella-muted);
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
}
.stella-nudge-close:hover { color: var(--stella-ink); background: rgba(15, 15, 15, 0.06); }
@keyframes stella-nudge-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .stella-panel, .stella-nudge, .stella-bubble, .stella-typing span {
    animation: none !important;
    transition: none !important;
  }
}

/* Mobile: backdrop veil, keyboard-safe height (--stella-vvh), and non-overlapping launcher */
@media (max-width: 768px) {
  .stella-root { bottom: 14px; right: 12px; left: 12px; }
  .stella-root.stella-dock-left { left: 12px; right: 12px; }
  .stella-bubble { margin-bottom: 66px; margin-left: auto; width: 48px; height: 48px; }
  /* On siilostomy.com, sticky buy bar (#siilPboBar) has its own integrated chat button and hides #siil-stella-open automatically;
     on non-bar views, keep the round launcher crisp at bottom-left */
  .stella-root.stella-dock-left .stella-bubble {
    margin-bottom: calc(2px + env(safe-area-inset-bottom, 0px));
    margin-left: 4px;
    margin-right: auto;
    width: 46px;
    height: 46px;
    background: #ffffff;
    color: var(--stella-ink);
    border: 1px solid var(--stella-border-strong);
    box-shadow: 0 4px 14px rgba(15, 15, 15, 0.18);
  }
  .stella-nudge-wrap { display: none !important; }
  .stella-root.stella-is-open .stella-veil {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: rgba(15, 15, 15, 0.40);
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }
  .stella-panel {
    width: 100%;
    max-width: 100%;
    height: min(560px, calc(var(--stella-vvh, 100dvh) - 24px));
    max-height: calc(var(--stella-vvh, 100dvh) - 24px);
  }
  .stella-close { flex: 0 0 44px; width: 44px; height: 44px; }
  .stella-send { flex: 0 0 44px; width: 44px; height: 44px; }
  /* 16px prevents iOS Safari from auto-zooming the page when tapping chat inputs */
  .stella-input { font-size: 16px; }
}
