/* AI chatbot widget */
.cb { --cb-p: var(--primary, #5b21b6); font-family: inherit; }
.cb svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cb-fab {
  position: fixed; right: 16px; bottom: 74px; z-index: 160; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--cb-p); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--cb-p) 45%, transparent); transition: transform .2s;
}
.cb-fab:hover { transform: scale(1.06); }
.cb-fab svg { width: 26px; height: 26px; grid-area: 1 / 1; transition: opacity .2s, transform .2s; }
.cb-fab .cb-ic-close { opacity: 0; transform: rotate(-90deg); }
.cb.open .cb-fab .cb-ic-open { opacity: 0; transform: rotate(90deg); }
.cb.open .cb-fab .cb-ic-close { opacity: 1; transform: none; }
.cb-dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent, #f97316); border: 2px solid #fff; }
.cb.seen .cb-dot { display: none; }
.cb-fab::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--cb-p); animation: cbPulse 2.4s ease-out infinite; }
.cb.seen .cb-fab::before { display: none; }
@keyframes cbPulse { from { transform: scale(1); opacity: .7; } to { transform: scale(1.6); opacity: 0; } }

.cb-panel {
  position: fixed; right: 16px; bottom: 142px; z-index: 161; width: 380px; max-width: calc(100vw - 32px);
  height: min(600px, calc(100vh - 170px)); background: #fff; border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 18px 50px rgba(16, 12, 40, .25);
  transform-origin: bottom right; animation: cbIn .2s ease-out;
}
.cb-panel[hidden] { display: none; }
@keyframes cbIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.cb-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--cb-p); color: #fff; }
.cb-av { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.cb-title { flex: 1; min-width: 0; line-height: 1.25; }
.cb-title b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-title small { font-size: 12px; opacity: .9; display: inline-flex; align-items: center; gap: 5px; }
.cb-title small i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; }
.cb-btn { width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: #fff; cursor: pointer; display: grid; place-items: center; }
.cb-btn:hover { background: rgba(255,255,255,.15); }
.cb-btn svg { width: 19px; height: 19px; }

.cb-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f6f6fa; overscroll-behavior: contain; }
.cb-msg { flex: none; max-width: 86%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55; word-wrap: break-word; white-space: pre-line; }
.cb-bot { align-self: flex-start; background: #fff; color: var(--text, #1f2937); border: 1px solid #ececf3; border-bottom-left-radius: 4px; }
.cb-user { align-self: flex-end; background: var(--cb-p); color: #fff; border-bottom-right-radius: 4px; }
.cb-msg a { color: var(--cb-p); font-weight: 600; text-decoration: underline; }
.cb-user a { color: #fff; }
.cb-msg ul { margin: 4px 0; padding-left: 18px; white-space: normal; }
.cb-msg li { margin: 2px 0; }
.cb-typing { display: inline-flex; gap: 4px; padding: 13px 15px; }
.cb-typing span { width: 7px; height: 7px; border-radius: 50%; background: #b4b4c4; animation: cbDot 1.2s infinite; }
.cb-typing span:nth-child(2) { animation-delay: .15s; } .cb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cbDot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.cb-products { flex: none; align-self: stretch; display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: thin; }
.cb-card { flex: 0 0 150px; background: #fff; border: 1px solid #ececf3; border-radius: 12px; padding: 8px; text-decoration: none; color: var(--text, #1f2937); display: flex; flex-direction: column; gap: 4px; transition: border-color .15s; }
.cb-card:hover { border-color: var(--cb-p); }
.cb-card img { width: 100%; height: 90px; object-fit: contain; background: #fff; border-radius: 8px; }
.cb-card .n { font-size: 12.5px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.cb-card .p { font-size: 14px; font-weight: 800; color: var(--cb-p); }
.cb-card .p s { font-size: 11px; color: #9ca3af; font-weight: 500; margin-left: 4px; }
.cb-card .s { font-size: 11px; color: #15803d; font-weight: 600; }
.cb-card .s.out { color: #b45309; }

.cb-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; background: #f6f6fa; }
.cb-chips[hidden] { display: none; }
.cb-chip { border: 1px solid color-mix(in srgb, var(--cb-p) 35%, white); background: #fff; color: var(--cb-p); border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-family: inherit; font-weight: 600; }
.cb-chip:hover { background: var(--cb-p); color: #fff; }

.cb-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid #ececf3; background: #fff; }
.cb-form textarea { flex: 1; resize: none; border: 1px solid #e2e2ea; border-radius: 12px; padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.4; max-height: 110px; outline: none; background: #fafafc; }
.cb-form textarea:focus { border-color: var(--cb-p); background: #fff; }
.cb-form button { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--cb-p); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.cb-form button:disabled { opacity: .5; cursor: default; }
.cb-foot { font-size: 11px; color: #9ca3af; text-align: center; padding: 0 12px 8px; background: #fff; }
.cb-foot a { color: inherit; }

@media (max-width: 991px) {
  .cb-fab { bottom: calc(132px + env(safe-area-inset-bottom)); width: 52px; height: 52px; }
  body.has-buybar .cb-fab { bottom: calc(196px + env(safe-area-inset-bottom)); }
  .cb-panel { bottom: calc(194px + env(safe-area-inset-bottom)); height: min(560px, calc(100vh - 220px)); }
}
@media (max-width: 640px) {
  .cb-panel { right: 0; left: 0; bottom: 0; top: 0; width: 100%; max-width: none; height: auto; border-radius: 0; z-index: 400; }
  .cb.open .cb-fab { display: none; }
  .cb-msg { font-size: 15px; }
  .cb-form textarea { font-size: 16px; } /* stops iPhone zoom */
}
@media print { .cb { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .cb-fab::before, .cb-panel, .cb-typing span { animation: none; } }
