#bkai-root, #bkai-root * { box-sizing: border-box; }
#bkai-root {
  --bkai-radius: 14px;
  font-family: var(--bkai-font);
  direction: rtl;
  position: fixed;
  bottom: var(--bkai-bottom);
  z-index: 999990;
  color: var(--bkai-text);
  line-height: 1.8;
  font-size: 14px;
}
#bkai-root.bkai-right { right: var(--bkai-side); }
#bkai-root.bkai-left { left: var(--bkai-side); }

/* Launcher */
.bkai-launcher {
  display: flex; align-items: center; gap: 10px;
  border: 0; cursor: pointer; padding: 0; background: none;
  font-family: inherit;
}
.bkai-left .bkai-launcher { flex-direction: row-reverse; }
.bkai-launcher-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--bkai-primary); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  transition: transform .2s, background .2s;
  position: relative;
}
.bkai-launcher-icon::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 var(--bkai-primary); opacity: .5;
  animation: bkai-pulse 2.4s infinite;
}
.bkai-open .bkai-launcher-icon::after { animation: none; }
.bkai-launcher:hover .bkai-launcher-icon { background: var(--bkai-primary-dark); transform: scale(1.05); }
.bkai-launcher-icon svg { width: 28px; height: 28px; }
.bkai-launcher-label {
  background: #fff; color: var(--bkai-text);
  padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap;
}
.bkai-open .bkai-launcher-label { display: none; }
@keyframes bkai-pulse { 0% { box-shadow: 0 0 0 0 rgba(204,0,0,.45); } 70% { box-shadow: 0 0 0 14px rgba(204,0,0,0); } 100% { box-shadow: 0 0 0 0 rgba(204,0,0,0); } }

/* Panel */
.bkai-panel {
  position: absolute; bottom: 76px;
  width: 380px; height: 600px; max-height: calc(100vh - 110px);
  background: var(--bkai-bg);
  border-radius: var(--bkai-radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.bkai-right .bkai-panel { right: 0; }
.bkai-left .bkai-panel { left: 0; }
.bkai-open .bkai-panel { opacity: 1; transform: none; pointer-events: auto; }

.bkai-head {
  background: linear-gradient(135deg, var(--bkai-primary), var(--bkai-primary-dark));
  color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px;
}
.bkai-avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.bkai-avatar svg { width: 22px; height: 22px; }
.bkai-head-text { flex: 1; min-width: 0; }
.bkai-title { font-weight: 700; font-size: 15px; }
.bkai-sub { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bkai-sub::before { flex: none; }
.bkai-sub::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #3ee07a; }
.bkai-iconbtn { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.bkai-iconbtn:hover { background: rgba(255,255,255,.28); }
.bkai-iconbtn svg { width: 18px; height: 18px; }

.bkai-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.bkai-msg { max-width: 86%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.bkai-msg.bot { align-self: flex-start; background: #fff; border-top-right-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.bkai-msg.user { align-self: flex-end; background: var(--bkai-primary); color: #fff; border-top-left-radius: 4px; }
.bkai-msg.err { background: #fff3f3; color: #a00; border: 1px solid #f3c4c4; }
.bkai-msg a { color: var(--bkai-primary); font-weight: 600; }
.bkai-msg.user a { color: #fff; }
.bkai-msg img.bkai-userimg { display: block; max-width: 180px; border-radius: 10px; margin-bottom: 6px; }

.bkai-typing { align-self: flex-start; background: #fff; padding: 12px 16px; border-radius: 14px; display: flex; gap: 4px; }
.bkai-typing span { width: 7px; height: 7px; border-radius: 50%; background: #bbb; animation: bkai-dot 1.2s infinite; }
.bkai-typing span:nth-child(2) { animation-delay: .2s; }
.bkai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bkai-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Products */
.bkai-products { display: flex; flex-direction: column; gap: 8px; align-self: stretch; }
.bkai-card { display: flex; gap: 10px; background: #fff; border-radius: 12px; padding: 8px; text-decoration: none !important; color: var(--bkai-text) !important; border: 1px solid #eee; transition: border-color .15s, box-shadow .15s; }
.bkai-card:hover { border-color: var(--bkai-primary); box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.bkai-card img, .bkai-card .bkai-noimg { width: 64px; height: 64px; border-radius: 8px; object-fit: contain; background: #fafafa; flex: none; }
.bkai-card-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.bkai-card-name { font-size: 13px; font-weight: 600; line-height: 1.6; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bkai-card-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; font-size: 12px; }
.bkai-price { color: var(--bkai-primary); font-weight: 700; }
.bkai-sku { color: #999; direction: ltr; }
.bkai-out { color: #999; }

.bkai-maplink { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px dashed var(--bkai-primary); color: var(--bkai-primary) !important; padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; text-decoration: none !important; }
.bkai-maplink svg { width: 16px; height: 16px; }

.bkai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bkai-chip { background: #fff; border: 1px solid var(--bkai-primary); color: var(--bkai-primary); border-radius: 16px; padding: 4px 12px; font-size: 12px; cursor: pointer; font-family: inherit; }
.bkai-chip:hover { background: var(--bkai-primary); color: #fff; }

/* Footer */
.bkai-preview { display: none; padding: 8px 12px 0; background: #fff; }
.bkai-preview.show { display: flex; align-items: center; gap: 8px; }
.bkai-preview img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.bkai-preview button { border: 0; background: #eee; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.bkai-foot { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; background: #fff; border-top: 1px solid #eee; }
.bkai-input { flex: 1; border: 1px solid #e3e3e3; border-radius: 12px; padding: 9px 12px; resize: none; max-height: 110px; min-height: 42px; font-family: inherit; font-size: 14px; color: var(--bkai-text); outline: none; background: #fafafa; line-height: 1.6; }
.bkai-input:focus { border-color: var(--bkai-primary); background: #fff; }
.bkai-btn { flex: none; width: 42px; height: 42px; border-radius: 12px; border: 0; cursor: pointer; display: grid; place-items: center; }
.bkai-btn svg { width: 20px; height: 20px; }
.bkai-send { background: var(--bkai-primary); color: #fff; }
.bkai-send:hover { background: var(--bkai-primary-dark); }
.bkai-send:disabled { opacity: .5; cursor: default; }
.bkai-attach { background: #f1f1f1; color: #666; }
.bkai-attach:hover { color: var(--bkai-primary); }
.bkai-note { text-align: center; font-size: 11px; color: #999; padding: 0 0 8px; background: #fff; }
.bkai-note a { color: inherit; }

@media (max-width: 520px) {
  .bkai-open .bkai-launcher { display: none; }
  .bkai-panel { position: fixed; inset: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; bottom: 0; }
  .bkai-launcher-label { display: none; }
}

.bkai-launcher:hover {
  background-color: transparent!important;
}
