/* ==========================================================================
   Cartally Chatbot Widget — Premium UI
   Shadow DOM scoped styles
   ========================================================================== */

.cb-demo-host {
  --cartally-red: #ff1717;
  --cartally-red-dark: #d91f0f;
  --cartally-black: #050505;
  --cartally-text: #181818;
  --cartally-muted: #777777;
  --cartally-border: rgba(0, 0, 0, 0.08);
  --cartally-soft-border: rgba(0, 0, 0, 0.05);
  --cartally-bg: #ffffff;
  --cartally-surface: #f7f7f7;
  --cartally-surface-2: #eeeeee;

  --cartally-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
  --cartally-soft-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
  --cartally-launcher-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);

  --accent-primary: var(--cartally-red);
  --accent-on: #ffffff;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-soft: cubic-bezier(0.32, 0.72, 0.24, 1);

  --font-family:
    'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    'Segoe UI', sans-serif;

  font-family: var(--font-family);
  color: var(--cartally-text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

button {
  font-family: inherit;
  color: inherit;
}

/* ──────────────────────────────────────────────
   Launcher + quick input zone
   ────────────────────────────────────────────── */
.quick-input-zone {
  position: absolute;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  z-index: 1;
}
.quick-input-zone.position-left {
  right: auto;
  left: 24px;
  flex-direction: row-reverse;
}

.chat-launcher {
  width: 60px;
  height: 60px;
  flex: 0 0 60px;
  border-radius: 999px;
  background: var(--cartally-black);
  color: #fff;
  border: none;
  padding: 0;
  box-shadow: var(--cartally-launcher-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 200ms var(--ease-out), box-shadow 200ms ease;
}
.chat-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.26);
}
.chat-launcher:active {
  transform: scale(0.96);
}
.chat-launcher svg {
  width: 26px;
  height: 26px;
}
.chat-launcher.hidden {
  display: none;
}

/* Separate X button outside the pill */
.quick-input-close {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--cartally-border);
  opacity: 0;
  transform: translateX(16px) scale(0.8);
  pointer-events: none;
  transition:
    opacity 280ms var(--ease-soft),
    transform 320ms var(--ease-soft),
    background 160ms ease,
    color 160ms ease;
}
.quick-input-close svg {
  width: 14px;
  height: 14px;
}
.quick-input-close:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--cartally-text);
}

/* Quick input bar (input + send) */
.quick-input {
  width: 0;
  max-width: 0;
  height: 52px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.14);
  border: 1px solid var(--cartally-border);
  display: flex;
  align-items: center;
  padding: 6px 6px 6px 18px;
  gap: 8px;
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  overflow: hidden;
  transition:
    opacity 260ms var(--ease-soft) 40ms,
    transform 320ms var(--ease-soft) 40ms,
    width 380ms var(--ease-soft),
    max-width 380ms var(--ease-soft),
    padding 320ms var(--ease-soft);
}

.quick-input-zone:hover .quick-input,
.quick-input-zone.is-open .quick-input,
.quick-input:focus-within {
  width: min(260px, calc(100vw - 160px));
  max-width: min(260px, calc(100vw - 160px));
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.quick-input-zone:hover .quick-input-close,
.quick-input-zone.is-open .quick-input-close,
.quick-input:focus-within ~ .quick-input-close,
.quick-input-zone:focus-within .quick-input-close {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.quick-input input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--cartally-text);
  min-width: 0;
}
.quick-input input::placeholder {
  color: rgba(0, 0, 0, 0.45);
}

.quick-input-send {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.45);
  transition:
    background 160ms ease,
    transform 160ms ease,
    color 160ms ease;
}
.quick-input-send.active {
  background: var(--cartally-black);
  color: #fff;
}
.quick-input-send:hover {
  transform: scale(1.05);
}
.quick-input-send svg {
  width: 16px;
  height: 16px;
}

/* ──────────────────────────────────────────────
   Chat window (panel)
   ────────────────────────────────────────────── */
.chat-window {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 390px;
  height: min(700px, calc(100vh - 40px));
  background: var(--cartally-bg);
  border-radius: 28px;
  border: 1px solid var(--cartally-border);
  box-shadow: var(--cartally-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transform-origin: bottom right;
  z-index: 2;
  transition:
    opacity 240ms var(--ease-out),
    transform 240ms var(--ease-out),
    visibility 0s linear 240ms,
    width 420ms var(--ease-soft),
    height 420ms var(--ease-soft),
    right 420ms var(--ease-soft),
    bottom 420ms var(--ease-soft),
    border-radius 420ms var(--ease-soft);
}
.chat-window.position-left {
  right: auto;
  left: 24px;
  transform-origin: bottom left;
}

.chat-window[data-state='open'],
.chat-window[data-state='expanded'] {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition:
    opacity 240ms var(--ease-out),
    transform 240ms var(--ease-out),
    visibility 0s linear 0s,
    width 420ms var(--ease-soft),
    height 420ms var(--ease-soft),
    right 420ms var(--ease-soft),
    bottom 420ms var(--ease-soft),
    left 420ms var(--ease-soft),
    border-radius 420ms var(--ease-soft);
}

/* Expanded mode — keep bottom-right anchoring so width/height/right/bottom
   transitions cleanly between states (no left/top swap). */
.chat-window.expanded {
  width: min(70vw, 1120px);
  height: min(82vh, 860px);
  right: calc((100vw - min(70vw, 1120px)) / 2);
  bottom: calc((100vh - min(82vh, 860px)) / 2);
  border-radius: 32px;
}

@media (min-width: 1800px) {
  .chat-window.expanded {
    width: min(62vw, 1180px);
    right: calc((100vw - min(62vw, 1180px)) / 2);
  }
}

@media (max-width: 1100px) {
  .chat-window.expanded {
    width: calc(100vw - 48px);
    height: calc(100vh - 48px);
    right: 24px;
    bottom: 24px;
  }
}

/* ──────────────────────────────────────────────
   Header
   ────────────────────────────────────────────── */
.header-icon {
  position: absolute;
  top: 12px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--cartally-text);
  transition: background 180ms ease, transform 220ms var(--ease-out);
  z-index: 4;
}
.header-icon:hover {
  background: rgba(0, 0, 0, 0.07);
  transform: scale(1.05);
}
.header-icon:active {
  transform: scale(0.94);
}
.header-icon svg {
  width: 16px;
  height: 16px;
  transition: transform 320ms var(--ease-soft);
}

.expand-btn {
  left: 12px;
}
.new-chat-btn {
  right: 58px;
}
.close-btn {
  right: 12px;
}

.chat-window.expanded .expand-btn svg {
  transform: rotate(180deg);
}

/* Floating agent pill — flat, no chrome, just the store logo */
.agent-pill {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 3;
  max-width: calc(100% - 120px);
  pointer-events: none;
}

.agent-pill-brand {
  max-height: 32px;
  max-width: 180px;
  object-fit: contain;
  display: block;
}

.agent-pill-fallback {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--cartally-text);
  font-size: 14px;
  white-space: nowrap;
}

.agent-pill-fallback-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent-primary);
  color: var(--accent-on);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  position: relative;
  overflow: hidden;
}

.agent-online-dot {
  position: absolute;
  right: 0;
  top: 0;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid #fff;
}

/* ──────────────────────────────────────────────
   Messages
   ────────────────────────────────────────────── */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 80px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

/* Backdrop blur strip behind floating header — fades in on scroll */
.chat-header-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 84px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.85) 0%,
    rgba(255, 255, 255, 0.55) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) 45%,
    rgba(0, 0, 0, 0) 100%
  );
  mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) 45%,
    rgba(0, 0, 0, 0) 100%
  );
  opacity: 0;
  transition: opacity 220ms ease;
  z-index: 2;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}
.chat-window.is-scrolled .chat-header-backdrop {
  opacity: 1;
}
.messages::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 999px;
}
.messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-window.expanded .messages {
  padding-left: 42px;
  padding-right: 42px;
}

.message-row {
  display: flex;
  flex-direction: column;
  animation: messageIn 200ms var(--ease-out);
}
.message-row.user {
  align-items: flex-end;
}
.message-row.agent {
  align-items: flex-start;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.user {
  align-self: flex-end;
  background: var(--cartally-black);
  color: #fff;
  border-radius: 18px;
  padding: 10px 14px;
  max-width: 78%;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.agent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  align-self: flex-start;
  max-width: 88%;
}

.agent-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--cartally-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cartally-text);
  font-weight: 800;
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
}
.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.agent-message-content {
  font-size: 14px;
  line-height: 1.45;
  color: var(--cartally-text);
  white-space: pre-wrap;
  word-wrap: break-word;
  padding-top: 4px;
}

.message.error .agent-message-content {
  color: #b91c1c;
}

/* Typewriter caret */
.agent-message-content.is-typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: -2px;
  opacity: 0.7;
  animation: caretBlink 900ms steps(2, end) infinite;
}
@keyframes caretBlink {
  50% {
    opacity: 0;
  }
}

/* Timestamp on hover */
.timestamp {
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 160ms ease, transform 160ms ease;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.45);
  margin-top: 4px;
  pointer-events: none;
}
.message-row:hover .timestamp {
  opacity: 1;
  transform: translateY(0);
}
.message-row.user .timestamp {
  align-self: flex-end;
  margin-right: 4px;
}
.message-row.agent .timestamp {
  align-self: flex-start;
  margin-left: 40px;
}

/* ──────────────────────────────────────────────
   Typing indicator
   ────────────────────────────────────────────── */
.message.agent.typing-indicator {
  align-items: center;
}
.message.agent.typing-indicator .agent-avatar {
  margin-top: 0;
}
.message.agent.typing-indicator .agent-message-content {
  padding-top: 0;
  display: flex;
  align-items: center;
  min-height: 30px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 18px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: #111;
  border-radius: 999px;
  display: inline-block;
  animation: premiumDotBounce 1.45s infinite ease-in-out;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.18s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes premiumDotBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.38;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.thinking-text {
  position: relative;
  color: rgba(0, 0, 0, 0.55);
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  display: inline-block;
  line-height: 18px;
  animation: thinkingIn 220ms var(--ease-out);
}
.thinking-text::after {
  content: '';
  position: absolute;
  top: 0;
  left: -80%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.95),
    transparent
  );
  animation: shimmer 1.4s infinite;
  pointer-events: none;
}
@keyframes shimmer {
  0% {
    left: -80%;
  }
  100% {
    left: 130%;
  }
}

.thinking-text::after {
  animation-duration: 4.2s;
}
@keyframes thinkingIn {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ──────────────────────────────────────────────
   Product carousel
   ────────────────────────────────────────────── */
.product-carousel-wrap {
  position: relative;
  align-self: stretch;
  flex-shrink: 0;
  min-height: 290px;
}
.product-carousel {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  flex-shrink: 0;
  min-height: 290px;
  scroll-behavior: smooth;
}
.product-carousel::-webkit-scrollbar {
  display: none;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--cartally-border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cartally-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 200ms var(--ease-out),
    background 160ms ease;
  padding: 0;
}
.carousel-arrow.left {
  left: 4px;
}
.carousel-arrow.right {
  right: 4px;
}
.carousel-arrow.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.carousel-arrow:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-50%) scale(1.06);
}
.carousel-arrow svg {
  width: 16px;
  height: 16px;
}

.product-card {
  min-width: 200px;
  max-width: 220px;
  min-height: 280px;
  background: transparent;
  border-radius: 16px;
  overflow: hidden;
  border: 0;
  box-shadow: none;
  scroll-snap-align: start;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  padding: 6px;
  transition: transform 240ms var(--ease-out), background-color 240ms ease,
    box-shadow 240ms ease;
}
.product-card:hover {
  transform: translateY(-2px);
  background-color: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.product-card:hover .product-image-wrap img {
  transform: scale(1.03);
}

.chat-window.expanded .product-card {
  min-width: 240px;
  max-width: 280px;
  min-height: 320px;
}
.chat-window.expanded .product-carousel-wrap,
.chat-window.expanded .product-carousel {
  min-height: 330px;
}

.product-image-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: transparent;
  border-radius: 12px;
  margin: 0 0 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-image-wrap img {
  max-width: 90%;
  max-height: 90%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  transition: transform 280ms var(--ease-out);
}

.product-body {
  padding: 0 4px 4px;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  gap: 4px;
}

.product-title {
  font-size: 13px;
  font-weight: 600;
  color: #222;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 16px;
  font-weight: 800;
  color: #222;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ──────────────────────────────────────────────
   Input area
   ────────────────────────────────────────────── */
.chat-input-area {
  position: relative;
  padding-top: 4px;
  flex-shrink: 0;
}

.chat-input-shell {
  margin: 0 16px 8px;
  min-height: 52px;
  border-radius: 26px;
  background: #fff;
  border: 1px solid var(--cartally-border);
  box-shadow: var(--cartally-soft-shadow);
  display: flex;
  align-items: center;
  padding: 6px;
  gap: 6px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.chat-input-shell:focus-within {
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.chat-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 96px;
  min-height: 28px;
  color: var(--cartally-text);
  padding: 4px 6px;
}
.chat-input::placeholder {
  color: rgba(0, 0, 0, 0.45);
}

.input-icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 999px;
  border: none;
  background: rgba(0, 0, 0, 0.04);
  color: var(--cartally-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
  padding: 0;
}
.input-icon-button:hover {
  background: rgba(0, 0, 0, 0.07);
  transform: scale(1.05);
}
.input-icon-button:active {
  transform: scale(0.94);
}
.input-icon-button svg {
  width: 16px;
  height: 16px;
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.input-tooltip {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 12px);
  background: #1f1f1f;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  padding: 10px 14px;
  border-radius: 12px;
  white-space: normal;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  transition: opacity 180ms ease, transform 180ms var(--ease-out);
  z-index: 6;
}
.input-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.send-button {
  background: rgba(0, 0, 0, 0.10);
  color: rgba(0, 0, 0, 0.45);
}
.send-button.active {
  background: var(--cartally-black);
  color: #fff;
}
.send-button:disabled {
  cursor: not-allowed;
}

/* ──────────────────────────────────────────────
   Emoji picker
   ────────────────────────────────────────────── */
.emoji-picker {
  position: absolute;
  bottom: 72px;
  right: 18px;
  background: #fff;
  border-radius: 22px;
  padding: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--cartally-border);
  display: none;
  grid-template-columns: repeat(8, 32px);
  gap: 6px;
  z-index: 5;
}
.emoji-picker.open {
  display: grid;
  animation: emojiPickerIn 180ms var(--ease-out);
}
@keyframes emojiPickerIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.emoji-button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
  padding: 0;
  line-height: 1;
}
.emoji-button:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: scale(1.08);
}

/* ──────────────────────────────────────────────
   Powered by
   ────────────────────────────────────────────── */
.powered-by {
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(0, 0, 0, 0.5);
  padding-bottom: 6px;
  flex-shrink: 0;
}
.powered-by-logo {
  width: 14px;
  height: 14px;
  object-fit: contain;
}
.powered-by a {
  color: #000;
  text-decoration: none;
  font-weight: 600;
  transition: color 160ms ease;
}
.powered-by a:hover,
.powered-by a:active,
.powered-by a:focus-visible {
  color: #000;
  text-decoration: underline;
  text-decoration-color: #7477e0;
  text-underline-offset: 2px;
}

/* ──────────────────────────────────────────────
   Focus — subtle, no jagged red boxes on inputs
   ────────────────────────────────────────────── */
.cb-demo-host input,
.cb-demo-host textarea {
  outline: none !important;
}
.cb-demo-host input:focus,
.cb-demo-host input:focus-visible,
.cb-demo-host textarea:focus,
.cb-demo-host textarea:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
button:focus,
a:focus {
  outline: none;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.18);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────
   Responsive
   ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .chat-window {
    width: min(420px, calc(100vw - 24px));
    height: calc(100dvh - 32px);
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 640px) {
  .quick-input-zone {
    right: 12px;
    bottom: 12px;
  }
  .quick-input,
  .quick-input-close {
    display: none;
  }
  .chat-window,
  .chat-window.expanded {
    width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    right: 6px;
    bottom: 6px;
    border-radius: 24px;
  }
  .messages {
    padding-left: 16px;
    padding-right: 16px;
  }
  .agent-pill {
    max-width: calc(100% - 120px);
  }
  .expand-btn {
    display: none;
  }
  .new-chat-btn {
    left: 12px;
    right: auto;
  }

  /* When the on-screen keyboard is open we want a calm "clean slate":
     hide the floating logo / expand button / emoji button / blur strip.
     Conversation slides upward (out of view); user can still scroll up
     to bring it back into the visible area. */
  .chat-window.keyboard-open .agent-pill,
  .chat-window.keyboard-open .expand-btn,
  .chat-window.keyboard-open .chat-header-backdrop,
  .chat-window.keyboard-open .emoji-btn {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 220ms ease, transform 220ms var(--ease-out);
  }
  .chat-window.keyboard-open .messages {
    padding-top: 24px;
    padding-bottom: 70vh;
    transition: padding 240ms var(--ease-out);
  }
}

@media (max-width: 640px) {
  /* Always hide the emoji picker trigger on mobile per UX request. */
  .emoji-btn {
    display: none !important;
  }
}

/* ──────────────────────────────────────────────
   Reduced motion
   ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Demo-only overrides (light DOM, embedded inside marketing page section)
   ========================================================================== */

/* Host wrapper acts as the positioning context that the real chatbot has. */
.cb-demo-host {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    /* Disable :host's font-family override on the wrapper, but keep it on
       descendants so the embedded chat looks identical to the real widget. */
    font-family: var(--font-family);
}

/* Hide elements we don't show in the demo */
.cb-demo-host .quick-input-zone,
.cb-demo-host .chat-launcher {
    display: none !important;
}

/* Pin the chat window inside the host instead of fixed bottom-right */
.cb-demo-host .chat-window {
    position: absolute;
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 24px;
    transition: none; /* let the open/closed look settle instantly */
}

/* Keep visible regardless of data-state — we always render in "open" state */
.cb-demo-host .chat-window {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* Stage-driven message reveals.
   Hidden rows are removed from layout entirely (display:none) so the
   .messages container's scrollHeight reflects only visible content.
   When a row gains `.is-visible` it re-mounts with a slide-in animation. */
.cb-demo-host .message-row,
.cb-demo-host .product-carousel-wrap {
    display: none;
    animation: none;
}

.cb-demo-host .message-row.is-visible {
    display: flex;
    animation: cbDemoMsgIn 280ms var(--ease-out) both;
}

.cb-demo-host .product-carousel-wrap.is-visible {
    display: block;
    animation: cbDemoMsgIn 320ms var(--ease-out) both;
}

@keyframes cbDemoMsgIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Always show the header backdrop in the demo so messages fade nicely
   under the floating header when the chat auto-scrolls. */
.cb-demo-host .chat-header-backdrop {
    opacity: 1 !important;
}

/* Picked-product highlight + cursor + ripple (final stage) */
.cb-demo-cursor {
    position: absolute;
    width: 26px;
    height: 26px;
    color: #050505;
    pointer-events: none;
    opacity: 0;
    transform: translate(40px, 50px);
    transition: opacity 0.3s ease, transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.cb-demo-cursor svg {
    width: 100%;
    height: 100%;
}

.cb-demo-host[data-cursor="show"] .cb-demo-cursor {
    opacity: 1;
    transform: translate(0, 0);
}

.cb-demo-host[data-cursor="click"] .cb-demo-cursor {
    opacity: 1;
    transform: translate(0, 0) scale(0.85);
}

.cb-demo-host .product-card.is-picked {
    background-color: #fff;
    box-shadow:
        inset 0 0 0 2px var(--cartally-black),
        0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.cb-demo-host .product-card.is-picked::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    pointer-events: none;
    animation: cbDemoRipple 0.7s ease-out forwards;
}

.cb-demo-host .product-card {
    position: relative;
}

@keyframes cbDemoRipple {
    0%   { box-shadow: 0 0 0 0   rgba(5, 5, 5, 0.45); }
    100% { box-shadow: 0 0 0 24px rgba(5, 5, 5, 0); }
}

/* Pick toast — slides up below the chat window */
.cb-demo-pick-toast {
    position: absolute;
    left: 50%;
    bottom: -28px;
    transform: translate(-50%, 12px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: #ffff81;
    color: #0b0b0b;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 11;
}

.cb-demo-pick-toast strong {
    color: #0b0b0b;
    font-weight: 800;
}

.cb-demo-pick-toast .material-symbols-rounded {
    font-size: 18px;
    color: #0b0b0b;
}

.cb-demo-host[data-toast="show"] .cb-demo-pick-toast {
    opacity: 1;
    transform: translate(-50%, 0);
}


/* Demo placeholder product thumb (no real images in marketing demo) */
.cb-demo-host .cb-demo-thumb {
    width: 100%;
    height: 100%;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f7f7f7, #eeeeee);
    border-radius: 12px;
    color: var(--cartally-black);
}

.cb-demo-host .cb-demo-thumb .material-symbols-rounded {
    font-size: 56px;
    opacity: 0.55;
}

/* Real product photo inside demo card */
.cb-demo-host .cb-demo-photo {
    width: 100%;
    height: 100%;
    min-height: 140px;
    object-fit: contain;
    object-position: center;
    display: block;
    padding: 6px;
    border-radius: 12px;
    background: #f7f7f7;
}

/* ---------- Lock manual scrolling — page scroll drives everything ---------- */
.cb-demo-host .messages {
    /* Programmatic smooth scroll (scrollTo) needs an actual scroll container.
       overflow:auto + pointer-events:none = no user wheel/touch but JS scroll
       still works. Scrollbar visually hidden. */
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    pointer-events: none;
    scrollbar-width: none;
}

.cb-demo-host .messages::-webkit-scrollbar {
    display: none;
}

.cb-demo-host .product-carousel {
    overflow: hidden;            /* no horizontal manual scroll */
    pointer-events: none;
    /* Tighter packing — cards closer together. */
    gap: 6px;
    padding: 4px 4px;
    min-height: 240px;
}

.cb-demo-host .product-carousel-wrap {
    min-height: 240px;
}

.cb-demo-host .carousel-arrow {
    display: none;               /* no manual nav in the demo */
}

/* Tighter product cards so all three sit comfortably in 390px wide window */
.cb-demo-host .product-card {
    min-width: 118px;
    max-width: 130px;
    min-height: 220px;
    padding: 4px;
}

.cb-demo-host .product-card .product-image-wrap {
    margin-bottom: 6px;
}

.cb-demo-host .product-card .product-title {
    font-size: 12px;
    -webkit-line-clamp: 2;
}

.cb-demo-host .product-card .product-price {
    font-size: 14px;
}

.cb-demo-host .cb-demo-thumb {
    min-height: 110px;
}

.cb-demo-host .cb-demo-thumb .material-symbols-rounded {
    font-size: 44px;
}

/* Disable the input area's interactivity — it's just for show */
.cb-demo-host .chat-input-area {
    pointer-events: none;
}

