/* ── KB Chatbot Widget ─────────────────────────────────────────── */
.kbchat-wrap {
  position: fixed;
  bottom: 24px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.kbchat--hide-mobile { display: none; }
@media (min-width: 640px) { .kbchat--hide-mobile { display: block; } }

/* ── Bubble ──────────────────────────────────────────────────── */
.kbchat-bubble {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.kbchat-bubble:hover { transform: scale(1.08); box-shadow: 0 8px 32px rgba(0,0,0,.3); }
.kbchat-unread {
  position: absolute;
  top: -4px; right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── Window ──────────────────────────────────────────────────── */
.kbchat-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  max-height: 580px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: kbchat-pop .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes kbchat-pop {
  from { opacity: 0; transform: scale(.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
[style*="left:24px"] .kbchat-window { right: auto; left: 0; }

@media (max-width: 480px) {
  .kbchat-window { width: calc(100vw - 16px); right: -4px; bottom: 72px; max-height: calc(100vh - 120px); }
}

/* ── Header ──────────────────────────────────────────────────── */
.kbchat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  flex-shrink: 0;
}
.kbchat-header-left { display: flex; align-items: center; gap: 10px; }
.kbchat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  color: #fff; overflow: hidden;
  flex-shrink: 0; position: relative;
}
.kbchat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kbchat-online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
}
.kbchat-bot-name { color: #fff; font-weight: 700; font-size: 15px; }
.kbchat-status   { color: rgba(255,255,255,.8); font-size: 11px; }
.kbchat-header-actions { display: flex; gap: 6px; }
.kbchat-close-btn, .kbchat-clear-btn {
  background: rgba(255,255,255,.2);
  border: none; color: #fff; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.kbchat-close-btn:hover, .kbchat-clear-btn:hover { background: rgba(255,255,255,.35); }

/* ── Title bar ───────────────────────────────────────────────── */
.kbchat-title-bar {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .5px;
  flex-shrink: 0;
}

/* ── Messages ────────────────────────────────────────────────── */
.kbchat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.kbchat-msg { display: flex; align-items: flex-end; gap: 8px; }
.kbchat-msg--bot  { flex-direction: row; }
.kbchat-msg--user { flex-direction: row-reverse; }

.kbchat-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f3f4f6;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  overflow: hidden;
}
.kbchat-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.kbchat-bubble-text {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.kbchat-msg--bot  .kbchat-bubble-text { background: #f3f4f6; color: #1e1e1e; border-bottom-left-radius: 4px; }
.kbchat-msg--user .kbchat-bubble-text { color: #fff; border-bottom-right-radius: 4px; }

/* Typing indicator */
.kbchat-typing .kbchat-bubble-text {
  background: #f3f4f6;
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
}
.kbchat-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #aaa;
  animation: kbchat-bounce .8s infinite;
}
.kbchat-dot:nth-child(2) { animation-delay: .15s; }
.kbchat-dot:nth-child(3) { animation-delay: .3s; }
@keyframes kbchat-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* ── WhatsApp bar ────────────────────────────────────────────── */
.kbchat-wa-bar { padding: 12px 14px; background: #f9fafb; flex-shrink: 0; }
.kbchat-wa-text { font-size: 13px; color: #666; margin: 0 0 8px; }
.kbchat-wa-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s;
}
.kbchat-wa-btn:hover { opacity: .88; }

/* ── Input row ───────────────────────────────────────────────── */
.kbchat-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.kbchat-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color .15s;
}
.kbchat-input:focus { border-color: #aaa; }
.kbchat-send {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s;
}
.kbchat-send:hover  { opacity: .88; }
.kbchat-send:active { transform: scale(.93); }
.kbchat-send:disabled { opacity: .5; cursor: not-allowed; }

/* ── Footer ──────────────────────────────────────────────────── */
.kbchat-footer {
  text-align: center;
  font-size: 11px;
  color: #ccc;
  padding: 4px 0 8px;
  flex-shrink: 0;
}
.kbchat-footer a { color: #ccc; text-decoration: none; }
