/* ── AI Chatbot Chat Widget ───────────────────────────────
   All styles scoped to #aicb-root.
   Uses !important only on position/z-index so themes can't break layout.
   ─────────────────────────────────────────────────────── */

#aicb-root,
#aicb-root * {
  box-sizing: border-box !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
}

#aicb-root {
  position: fixed !important;
  bottom: 28px !important;
  z-index: 2147483647 !important;
}
#aicb-root.aicb-right { right: 28px; }
#aicb-root.aicb-left  { left:  28px; }

/* ── Toggle button ── */
#aicb-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--aicb-c, #2563eb);
  color: var(--aicb-c, #2563eb);
  box-shadow: 0 6px 24px rgba(0,0,0,.30);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
  padding: 0;
  outline: none;
}
#aicb-btn:hover { transform: scale(1.08); box-shadow: 0 8px 28px rgba(0,0,0,.36); }

.aicb-open-icon  { display: flex; }
.aicb-close-icon { display: none;  font-size: 22px; color: #fff; font-style: normal; line-height: 1; }

#aicb-root.aicb-open .aicb-open-icon  { display: none; }
#aicb-root.aicb-open .aicb-close-icon { display: flex; }

/* ── Chat window ── */
#aicb-window {
  position: absolute;
  bottom: 76px;
  width: 360px;
  max-width: 92vw;
  height: 490px;
  max-height: 72vh;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#aicb-window[hidden] { display: none !important; }

#aicb-root.aicb-right #aicb-window { right: 0; }
#aicb-root.aicb-left  #aicb-window { left: 0; }

/* Header */
#aicb-header {
  background: var(--aicb-c, #2563eb);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.aicb-header-inner { display: flex; align-items: center; gap: 10px; }
.aicb-bot-avatar   { font-size: 26px; line-height: 1; }
.aicb-bot-name     { color: #fff; font-weight: 700; font-size: 15px; }
.aicb-bot-status   { color: rgba(255,255,255,.8); font-size: 11px; margin-top: 1px; }
#aicb-close        { background: none; border: none; color: rgba(255,255,255,.85); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 4px; border-radius: 4px; }
#aicb-close:hover  { color: #fff; background: rgba(255,255,255,.15); }

/* Messages area */
#aicb-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #f4f6f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#aicb-msgs::-webkit-scrollbar { width: 4px; }
#aicb-msgs::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* Bubbles */
.aicb-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.aicb-bubble.aicb-bot {
  background: #fff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.aicb-bubble.aicb-user {
  background: var(--aicb-c, #2563eb);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* List formatting inside bot bubble */
.aicb-bubble ol,
.aicb-bubble ul   { margin: 8px 0 4px 18px; padding: 0; }
.aicb-bubble li   { margin-bottom: 6px; line-height: 1.45; }
.aicb-bubble li .aicb-item-detail {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}
.aicb-bubble strong { font-weight: 700; }
.aicb-bubble p    { margin: 0 0 6px; }
.aicb-bubble p:last-child { margin-bottom: 0; }

/* Typing dots */
.aicb-typing { align-self: flex-start; }
.aicb-dots   { display: flex; gap: 4px; padding: 12px 14px; }
.aicb-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #9ca3af;
  animation: aicb-bounce 1.2s infinite;
}
.aicb-dots span:nth-child(2) { animation-delay: .2s; }
.aicb-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes aicb-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* Input row */
#aicb-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}
#aicb-input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 13.5px;
  outline: none;
  background: #f9fafb;
  transition: border-color .15s;
}
#aicb-input:focus { border-color: var(--aicb-c,#2563eb); background: #fff; }
#aicb-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--aicb-c, #2563eb);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
#aicb-send:hover  { opacity: .88; }
#aicb-send:active { opacity: .75; }

@media (max-width: 480px) {
  #aicb-window { width: 95vw; height: 78vh; }
  #aicb-root.aicb-right { right: 12px; bottom: 12px; }
  #aicb-root.aicb-left  { left: 12px;  bottom: 12px; }
}
