/* =====================================================
   BIMedge Chatbot Widget — chatbot.css
   ===================================================== */

/* ---------- Launcher button ---------- */
#bim-launcher {
  position: fixed;
  z-index: 99998;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--bim-accent, #1a56db);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  transition: transform .2s ease, box-shadow .2s ease;
  user-select: none;
  bottom: 24px;
  right: 24px;   /* overridden by JS for bottom-left */
}
#bim-launcher:hover  { transform: scale(1.08); box-shadow: 0 6px 26px rgba(0,0,0,.30); }
#bim-launcher:active { transform: scale(.96); }
#bim-launcher svg    { width: 26px; height: 26px; }

/* unread badge */
#bim-badge {
  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;
}

/* ---------- Chat window ---------- */
#bim-window {
  position: fixed;
  z-index: 99999;
  bottom: 92px;
  right: 24px;
  width: 370px;
  max-height: 600px;
  border-radius: 18px;
  background: #f9fafb;
  box-shadow: 0 12px 48px rgba(0,0,0,.20), 0 2px 8px rgba(0,0,0,.10);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  transform: translateY(16px);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
}
#bim-window.bim-open {
  display: flex;
  animation: bimSlideUp .25s ease forwards;
}
@keyframes bimSlideUp {
  from { opacity:0; transform:translateY(16px); }
  to   { opacity:1; transform:translateY(0); }
}

/* position: bottom-left */
body.bim-pos-left #bim-launcher { right:auto; left:24px; }
body.bim-pos-left #bim-window   { right:auto; left:24px; }

/* ---------- Header ---------- */
#bim-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: #fff;
  flex-shrink: 0;
}
#bim-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#bim-hinfo   { flex:1; line-height:1.3; }
#bim-hname   { display:block; font-weight:700; font-size:15px; }
#bim-hstatus { display:block; font-size:11px; opacity:.85; }
#bim-minimize {
  background:none; border:none; color:#fff; cursor:pointer;
  opacity:.8; padding:4px; border-radius:4px; line-height:0;
  transition: opacity .15s;
}
#bim-minimize:hover { opacity:1; background:rgba(255,255,255,.15); }
#bim-minimize svg   { width:18px; height:18px; }

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

/* ---------- Individual messages ---------- */
.bim-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
}
.bim-msg-bot  { align-self: flex-start; }
.bim-msg-user { align-self: flex-end; flex-direction: row-reverse; }

.bim-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  line-height: 1.5;
  word-break: break-word;
  font-size: 13.5px;
}
.bim-msg-bot  .bim-bubble { background:#fff; color:#1f2937; border-bottom-left-radius:4px; box-shadow:0 1px 3px rgba(0,0,0,.08); }
.bim-msg-user .bim-bubble { background: var(--bim-accent,#1a56db); color:#fff; border-bottom-right-radius:4px; }

.bim-msg-avatar {
  width:28px; height:28px; border-radius:50%;
  background: var(--bim-accent,#1a56db);
  color:#fff; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; font-size:13px; font-weight:700;
}

/* ---------- Option buttons ---------- */
.bim-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
  padding-left: 36px;
}
.bim-opt-btn {
  background: #fff;
  border: 1.5px solid var(--bim-accent,#1a56db);
  color: var(--bim-accent,#1a56db);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
  white-space: normal;
  line-height: 1.4;
}
.bim-opt-btn:hover  { background: var(--bim-accent,#1a56db); color:#fff; }
.bim-opt-btn:active { opacity:.85; }
.bim-opt-btn:disabled { opacity:.45; cursor:default; pointer-events:none; }

/* ---------- Inline form ---------- */
.bim-form-wrap {
  background:#fff;
  border-radius:14px;
  padding:14px;
  box-shadow:0 1px 4px rgba(0,0,0,.08);
  margin-left:36px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.bim-field label  { display:block; font-size:12px; color:#6b7280; margin-bottom:3px; font-weight:500; }
.bim-field input,
.bim-field textarea {
  width:100%; box-sizing:border-box;
  border:1px solid #d1d5db; border-radius:8px;
  padding:8px 10px; font-size:13px; color:#111827;
  outline:none; transition:border-color .15s;
  font-family:inherit; resize:vertical;
}
.bim-field input:focus,
.bim-field textarea:focus { border-color: var(--bim-accent,#1a56db); }
.bim-field textarea { min-height:64px; }
.bim-form-error  { font-size:12px; color:#ef4444; display:none; }
.bim-submit-btn {
  background: var(--bim-accent,#1a56db);
  color:#fff; border:none; border-radius:10px;
  padding:10px; font-size:13px; font-weight:600;
  cursor:pointer; transition:opacity .15s;
}
.bim-submit-btn:hover   { opacity:.9; }
.bim-submit-btn:disabled{ opacity:.6; cursor:not-allowed; }

/* ---------- Typing indicator ---------- */
#bim-typing {
  padding: 8px 14px 6px;
  display: flex;
  gap: 4px;
  align-items: center;
}
#bim-typing span {
  width:7px; height:7px; border-radius:50%;
  background:#9ca3af;
  animation: bimDot 1.2s infinite;
}
#bim-typing span:nth-child(2) { animation-delay:.2s; }
#bim-typing span:nth-child(3) { animation-delay:.4s; }
@keyframes bimDot {
  0%,80%,100% { transform:scale(1);   opacity:.5; }
  40%          { transform:scale(1.4); opacity:1;  }
}

/* ---------- Footer brand ---------- */
#bim-footer-brand {
  text-align:center; font-size:11px; color:#9ca3af;
  padding:6px; border-top:1px solid #f3f4f6; flex-shrink:0;
}
#bim-footer-brand a { color:#9ca3af; text-decoration:none; }
#bim-footer-brand a:hover { color:#6b7280; }

/* ---------- Responsive ---------- */
@media (max-width: 420px) {
  #bim-window { width:calc(100vw - 16px); right:8px; bottom:80px; max-height:85vh; }
  body.bim-pos-left #bim-window { left:8px; right:auto; }
}
