:root {
  --bp-chat-violet: #6941d9;
  --bp-chat-violet-dark: #4f2bb7;
  --bp-chat-honey: #f4b740;
  --bp-chat-ink: #221d2b;
  --bp-chat-muted: #746d7c;
  --bp-chat-border: #e8e2ed;
  --bp-chat-surface: #ffffff;
  --bp-chat-canvas: #f7f5fa;
  --bp-chat-success: #3e8b43;
}

.bp-ai-webchat-root,
.bp-ai-webchat-root * { box-sizing: border-box; }

.bp-ai-webchat-root [hidden] { display: none !important; }

.bp-ai-webchat-root {
  position: fixed;
  z-index: 2147482000;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--bp-chat-ink);
  line-height: 1.4;
  text-align: left;
}

.bp-ai-webchat-root button,
.bp-ai-webchat-root textarea,
.bp-ai-webchat-root input { font: inherit; }

.bp-ai-webchat-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #7a4bec, #5632c2);
  box-shadow: 0 12px 30px rgba(79, 43, 183, .34), 0 3px 8px rgba(34, 29, 43, .18);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.bp-ai-webchat-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(79, 43, 183, .4), 0 3px 8px rgba(34, 29, 43, .18); }
.bp-ai-webchat-launcher:focus-visible { outline: 3px solid rgba(105, 65, 217, .28); outline-offset: 4px; }
.bp-ai-webchat-launcher span { display: grid; place-items: center; width: 30px; height: 30px; }
.bp-ai-webchat-launcher svg { width: 30px; height: 30px; }
.bp-ai-webchat-launcher-close { display: none !important; }
.bp-ai-webchat-launcher.is-open .bp-ai-webchat-launcher-message { display: none; }
.bp-ai-webchat-launcher.is-open .bp-ai-webchat-launcher-close { display: grid !important; }
.bp-ai-webchat-launcher b {
  position: absolute;
  top: -2px;
  right: -1px;
  min-width: 21px;
  height: 21px;
  padding: 2px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #d73c4c;
  font-size: 11px;
  line-height: 15px;
  text-align: center;
}

.bp-ai-webchat-panel {
  position: absolute;
  right: 0;
  bottom: 80px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  width: min(392px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 120px));
  min-height: 460px;
  overflow: hidden;
  border: 1px solid rgba(63, 47, 82, .12);
  border-radius: 22px;
  background: var(--bp-chat-surface);
  box-shadow: 0 24px 70px rgba(37, 24, 55, .23), 0 6px 18px rgba(37, 24, 55, .12);
  transform-origin: right bottom;
  animation: bp-chat-open .22s ease-out;
}

@keyframes bp-chat-open {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.bp-ai-webchat-header {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 11px;
  min-height: 74px;
  padding: 12px 13px 12px 16px;
  color: #fff;
  background: linear-gradient(118deg, #4c278e 0%, #6941d9 70%, #7650e6 100%);
}

.bp-ai-webchat-avatar {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .72);
  border-radius: 14px;
  color: #4a2a12;
  background: linear-gradient(145deg, #fff8cf, #efb640);
  font-weight: 800;
}
.bp-ai-webchat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bp-ai-webchat-heading { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.bp-ai-webchat-heading strong { overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.bp-ai-webchat-heading span { display: flex; align-items: center; gap: 6px; color: rgba(255, 255, 255, .78); font-size: 12px; }
.bp-ai-webchat-heading i { width: 7px; height: 7px; border-radius: 50%; background: #7de083; box-shadow: 0 0 0 3px rgba(125, 224, 131, .15); }
.bp-ai-webchat-minimize {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, .1);
  cursor: pointer;
}
.bp-ai-webchat-minimize:hover { background: rgba(255, 255, 255, .18); }
.bp-ai-webchat-minimize svg { width: 21px; height: 21px; }

.bp-ai-webchat-cartbar {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  padding: 9px 15px;
  border: 0;
  border-bottom: 1px solid #eee7f3;
  color: #493f53;
  background: #fbf8ff;
  font-size: 12px;
  cursor: pointer;
}
.bp-ai-webchat-cartbar:hover { background: #f5effd; }
.bp-ai-webchat-cartbar svg { width: 20px; height: 20px; color: var(--bp-chat-violet); }
.bp-ai-webchat-cartbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-ai-webchat-cartbar strong { font-size: 12px; }

.bp-ai-webchat-messages {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 24px;
  background:
    radial-gradient(circle at 12% 4%, rgba(105, 65, 217, .05), transparent 25%),
    linear-gradient(#faf9fc, #f7f5fa);
  scrollbar-width: thin;
  scrollbar-color: #cfc5d8 transparent;
}
.bp-ai-webchat-messages::-webkit-scrollbar { width: 6px; }
.bp-ai-webchat-messages::-webkit-scrollbar-thumb { border-radius: 6px; background: #cfc5d8; }

.bp-ai-webchat-message { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 0 12px; }
.bp-ai-webchat-message.is-user { align-items: flex-end; }
.bp-ai-webchat-bubble {
  max-width: 88%;
  padding: 11px 13px;
  border: 1px solid #e7e0eb;
  border-radius: 16px 16px 16px 5px;
  color: #302a37;
  background: #fff;
  box-shadow: 0 2px 6px rgba(38, 25, 49, .04);
  font-size: 14px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.is-user .bp-ai-webchat-bubble {
  border-color: #6740d0;
  border-radius: 16px 16px 5px 16px;
  color: #fff;
  background: linear-gradient(135deg, #7450df, #6238c6);
}
.bp-ai-webchat-message time { padding: 0 4px; color: #98909f; font-size: 10px; }

.bp-ai-webchat-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 16px; }
.bp-ai-webchat-actions button,
.bp-ai-webchat-card-actions button,
.bp-ai-webchat-card-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid #d8cbed;
  border-radius: 999px;
  color: #5933b3;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.bp-ai-webchat-actions button:hover,
.bp-ai-webchat-card-actions button:hover,
.bp-ai-webchat-card-actions a:hover { border-color: #a78ae0; background: #f5f0fc; }

.bp-ai-webchat-cart-card,
.bp-ai-webchat-lead {
  margin: 8px 0 16px;
  padding: 13px;
  border: 1px solid #e5dced;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 10px rgba(38, 25, 49, .05);
}
.bp-ai-webchat-cart-card > div:not(.bp-ai-webchat-card-actions) { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; font-size: 12px; }
.bp-ai-webchat-cart-card > div:first-child { margin-bottom: 4px; padding-bottom: 9px; border-bottom: 1px solid #eee9f2; }
.bp-ai-webchat-cart-card > div span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-ai-webchat-cart-card small { display: block; margin: 5px 0; color: var(--bp-chat-muted); }
.bp-ai-webchat-card-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

.bp-ai-webchat-lead { border-color: #dbcdf0; background: linear-gradient(150deg, #fff, #fbf7ff); }
.bp-ai-webchat-lead > strong { display: block; margin-bottom: 5px; font-size: 14px; }
.bp-ai-webchat-lead p { margin: 0 0 11px; color: #6f6677; font-size: 12px; line-height: 1.45; }
.bp-ai-webchat-lead > input {
  display: block;
  width: 100%;
  height: 42px;
  margin: 7px 0;
  padding: 0 11px;
  border: 1px solid #ddd5e4;
  border-radius: 11px;
  color: var(--bp-chat-ink);
  background: #fff;
  font-size: 13px;
}
.bp-ai-webchat-lead > input:focus { border-color: var(--bp-chat-violet); outline: 3px solid rgba(105, 65, 217, .1); }
.bp-ai-webchat-lead label { display: flex; align-items: flex-start; gap: 5px; margin: 10px 1px; color: #746b7c; font-size: 10px; line-height: 1.35; }
.bp-ai-webchat-lead label input { flex: 0 0 auto; margin-top: 1px; accent-color: var(--bp-chat-violet); }
.bp-ai-webchat-lead > div { display: flex; align-items: center; gap: 8px; }
.bp-ai-webchat-lead button {
  min-height: 36px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--bp-chat-violet);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.bp-ai-webchat-lead button.is-link { color: #6c6274; background: transparent; font-weight: 500; }
.bp-ai-webchat-lead button:disabled { opacity: .55; cursor: wait; }

.bp-ai-webchat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 52px;
  height: 34px;
  margin: 0 0 12px;
  padding: 0 13px;
  border: 1px solid #e7e0eb;
  border-radius: 15px 15px 15px 5px;
  background: #fff;
}
.bp-ai-webchat-typing i { width: 5px; height: 5px; border-radius: 50%; background: #9b8da8; animation: bp-chat-typing 1s infinite ease-in-out; }
.bp-ai-webchat-typing i:nth-child(2) { animation-delay: .15s; }
.bp-ai-webchat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bp-chat-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

.bp-ai-webchat-status { padding: 9px 13px; border-top: 1px solid #efe9f2; color: #6d5c27; background: #fff8df; font-size: 11px; }
.bp-ai-webchat-status.is-error { color: #9d2e3b; background: #fff0f1; }
.bp-ai-webchat-status.is-success { color: #2e7334; background: #eff9ef; }

.bp-ai-webchat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: end;
  gap: 8px;
  padding: 10px 11px 9px 13px;
  border-top: 1px solid #eae4ee;
  background: #fff;
}
.bp-ai-webchat-composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 104px;
  resize: none;
  overflow-y: auto;
  padding: 10px 2px 8px;
  border: 0;
  outline: 0;
  color: #302a37;
  background: transparent;
  font-size: 14px;
  line-height: 1.45;
}
.bp-ai-webchat-composer textarea::placeholder { color: #9b939f; }
.bp-ai-webchat-composer button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: var(--bp-chat-violet);
  cursor: pointer;
}
.bp-ai-webchat-composer button:hover { background: var(--bp-chat-violet-dark); }
.bp-ai-webchat-composer button:disabled { opacity: .45; cursor: wait; }
.bp-ai-webchat-composer button svg { width: 21px; height: 21px; }
.bp-ai-webchat-footnote { padding: 0 13px 10px; color: #aaa2af; background: #fff; font-size: 9px; text-align: center; }
.bp-ai-webchat-footnote a { color: #8a79a0; text-decoration: underline; }

.bp-ai-webchat-invite {
  position: absolute;
  right: 0;
  bottom: 79px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  width: min(320px, calc(100vw - 32px));
  overflow: hidden;
  border: 1px solid #e5ddec;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(37, 24, 55, .2);
  animation: bp-chat-open .22s ease-out;
}
.bp-ai-webchat-invite-main { display: flex; flex-direction: column; gap: 3px; padding: 13px 4px 13px 15px; border: 0; color: var(--bp-chat-ink); background: transparent; text-align: left; cursor: pointer; }
.bp-ai-webchat-invite-main strong { font-size: 14px; }
.bp-ai-webchat-invite-main span { color: var(--bp-chat-muted); font-size: 11px; line-height: 1.4; }
.bp-ai-webchat-invite-close { display: grid; place-items: center; align-self: start; width: 30px; height: 30px; margin: 5px 4px 0 0; padding: 0; border: 0; border-radius: 50%; color: #8e8594; background: transparent; cursor: pointer; }
.bp-ai-webchat-invite-close:hover { background: #f4f0f7; }
.bp-ai-webchat-invite-close svg { width: 16px; height: 16px; }

@media (max-width: 600px) {
  .bp-ai-webchat-root { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
  .bp-ai-webchat-launcher { width: 58px; height: 58px; }
  .bp-ai-webchat-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bp-ai-webchat-open { overflow: hidden !important; }
  .bp-ai-webchat-header { min-height: 70px; }
  .bp-ai-webchat-messages { padding: 17px 13px 24px; }
  .bp-ai-webchat-bubble { max-width: 91%; font-size: 15px; }
  .bp-ai-webchat-footnote { padding-bottom: 7px; }
  .bp-ai-webchat-invite { bottom: 72px; }
  .bp-ai-webchat-launcher.is-open { visibility: hidden; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bp-ai-webchat-panel,
  .bp-ai-webchat-invite { animation: none; }
  .bp-ai-webchat-launcher { transition: none; }
}
