:root {
  --kcbt-primary: #0ea5e9;
  --kcbt-bg: #ffffff;
  --kcbt-text: #0f172a;
  --kcbt-muted: #64748b;
  --kcbt-border: #e2e8f0;
  --kcbt-radius: 14px;
  --kcbt-shadow: 0 10px 30px rgba(2, 6, 23, .15);
  --kcbt-z: 999999;
}

.kcbt-widget {
  position: fixed;
  bottom: 22px;
  z-index: var(--kcbt-z);
  font-family: IRANSans, Vazirmatn, Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  direction: rtl;
  color: var(--kcbt-text);
}
.kcbt-widget.kcbt-right { right: 22px; }
.kcbt-widget.kcbt-left  { left: 22px; }

.kcbt-toggle {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none; outline: none;
  background: var(--kcbt-primary);
  color: #fff; cursor: pointer;
  box-shadow: var(--kcbt-shadow);
  display: grid; place-items: center;
  transition: transform .2s ease, box-shadow .2s ease;
  animation: kcbt-bounce-in .5s ease;
}
.kcbt-toggle:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(2,6,23,.2); }

.kcbt-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 360px;
  max-width: 92vw;
  background: var(--kcbt-bg);
  border: 1px solid var(--kcbt-border);
  border-radius: var(--kcbt-radius);
  box-shadow: var(--kcbt-shadow);
  overflow: hidden;
  display: none;
  animation: kcbt-slide-up .25s ease;
}

.kcbt-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(14,165,233,.08), transparent);
  border-bottom: 1px solid var(--kcbt-border);
}
.kcbt-title { display:flex; align-items:center; gap:8px; font-weight:700; }
.kcbt-dot {
  width:10px;height:10px;border-radius:50%;background: var(--kcbt-primary);
  box-shadow: 0 0 0 6px rgba(14,165,233,.12);
}
.kcbt-close {
  background: transparent; border: none; color: var(--kcbt-muted);
  cursor: pointer; padding: 6px; border-radius: 6px;
}
.kcbt-close:hover { background: #f8fafc; color: #0f172a; }

.kcbt-prechat, .kcbt-body { padding: 14px; }

.kcbt-step label {
  display:block; margin-bottom:8px; color: var(--kcbt-text); font-weight:600;
}
.kcbt-input {
  width: 100%;
  border: 1px solid var(--kcbt-border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none; background: #fff;
}
.kcbt-input:focus { border-color: var(--kcbt-primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }

.kcbt-actions { margin-top: 10px; display:flex; justify-content:flex-end; gap:10px; }
.kcbt-actions.space { justify-content: space-between; }

.kcbt-btn {
  border: 1px solid var(--kcbt-border); background:#fff; color: var(--kcbt-text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
}
.kcbt-btn:hover { background: #f8fafc; }
.kcbt-btn.kcbt-primary { background: var(--kcbt-primary); color:#fff; border-color: var(--kcbt-primary); }
.kcbt-btn.kcbt-ghost { background: transparent; }

.kcbt-error { margin-top:8px; color:#ef4444; min-height:18px; font-size:13px; }

.kcbt-messages { max-height: 360px; overflow: auto; display: flex; flex-direction: column; gap:8px; padding: 4px 2px 8px 2px; }
.kcbt-msg { max-width: 85%; padding: 10px 12px; border-radius: 12px; line-height: 1.6; font-size: 14px; }
.kcbt-msg.user { align-self: flex-start; background: #f1f5f9; border-top-right-radius: 4px; }
.kcbt-msg.bot  { align-self: flex-end; background: rgba(14,165,233,.1); border-top-left-radius: 4px; border: 1px solid rgba(14,165,233,.15); }

.kcbt-inputbar {
  display:flex; align-items: center; gap: 8px; margin-top: 10px;
  border:1px solid var(--kcbt-border); border-radius: 12px; padding: 6px 8px; background:#fff;
}
.kcbt-inputbar textarea {
  resize: none; border: none; outline: none; width: 100%; font: inherit; line-height: 1.5; max-height: 120px;
}
.kcbt-send {
  background: var(--kcbt-primary); color:#fff; border:none; width:36px; height:36px; border-radius:10px; cursor:pointer;
}
.kcbt-send:hover { filter: brightness(1.05); }
.kcbt-powered { text-align:center; color: var(--kcbt-muted); font-size:12px; margin-top:6px; }

.kcbt-suggestions { display:flex; flex-wrap: wrap; gap:6px; margin: 6px 0 2px; }
.kcbt-chip { background:#f1f5f9; color:#0f172a; border:1px solid #e2e8f0; padding:6px 10px; border-radius: 100px; cursor: pointer; font-size: 12px; }
.kcbt-chip:hover { background:#e2e8f0; }

@keyframes kcbt-slide-up { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes kcbt-bounce-in {
  0% { transform: scale(.9); opacity:.5; }
  60%{ transform: scale(1.05); opacity:1; }
  100%{ transform: scale(1); }
}

@media (max-width: 480px) {
  .kcbt-panel {
    width: calc(100vw - 24px);
    right: 0;
  }
}