@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800&family=DM+Sans:wght@300;400;500&display=swap');

:root {
  --aicb-accent:        #2563EB;
  --aicb-accent-d:      #1d4ed8;
  --aicb-header-bg:     linear-gradient(135deg,#0f1d40 0%,#1a3a6e 55%,#1e293b 100%);
  --aicb-panel-bg:      #1a2744;
  --aicb-dark:          #1e293b;
  --aicb-input:         #0f172a;
  --aicb-border:        rgba(37,99,235,0.25);
  --aicb-qbtn-bg:       rgba(37,99,235,0.15);
  --aicb-qbtn-text:     rgba(255,255,255,0.8);
  --aicb-text:          #f1f5f9;
  --aicb-bubble-bot:    #1e293b;
  --aicb-bubble-user:   var(--aicb-accent);
  --aicb-bubble-text:   #f1f5f9;
}

/* FAB */
#aicb-fab {
  position:fixed; bottom:80px;
  width:58px; height:58px;
  background:var(--aicb-accent);
  border:none; border-radius:50%; cursor:pointer;
  box-shadow:0 6px 20px rgba(0,0,0,0.25);
  display:flex; align-items:center; justify-content:center;
  z-index:999999;
  transition:transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  animation:aicb-fab-in .6s cubic-bezier(.34,1.56,.64,1) .8s both;
}
@keyframes aicb-fab-in {
  from{transform:scale(0) rotate(-180deg);opacity:0}
  to  {transform:scale(1) rotate(0);opacity:1}
}
#aicb-fab.aicb-right { right:24px; }
#aicb-fab.aicb-left  { left: 24px; }
#aicb-fab:hover { transform:scale(1.09); box-shadow:0 8px 28px rgba(0,0,0,.35); }
#aicb-fab.aicb-open { transform:scale(1); }

.aicb-fab-icon  { position:absolute; fill:white; width:24px; height:24px; transition:opacity .22s,transform .22s; }
.aicb-fab-close { position:absolute; fill:white; width:22px; height:22px; opacity:0; transform:rotate(-90deg) scale(.5); transition:opacity .22s,transform .22s; }
#aicb-fab.aicb-open .aicb-fab-icon  { opacity:0; transform:rotate(90deg) scale(.5); }
#aicb-fab.aicb-open .aicb-fab-close { opacity:1; transform:rotate(0) scale(1); }

/* Notification dot */
#aicb-notif {
  position:absolute; top:4px; right:4px;
  width:13px; height:13px; background:#ef4444;
  border-radius:50%; border:2px solid #fff; display:none;
}

/* PANEL */
#aicb-panel {
  position:fixed;
  width:380px; max-width:calc(100vw - 24px);
  height:570px; max-height:calc(100vh - 110px);
  display:flex; flex-direction:column;
  background:var(--aicb-panel-bg);
  border-radius:18px;
  border:1px solid var(--aicb-border);
  box-shadow:0 30px 70px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.04);
  overflow:hidden;
  z-index:999998;
  transform:scale(.88) translateY(18px);
  opacity:0; pointer-events:none;
  transition:transform .4s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
}
#aicb-panel.aicb-right { right:24px; bottom:150px; transform-origin:bottom right; }
#aicb-panel.aicb-left  { left: 24px; bottom:150px; transform-origin:bottom left; }
#aicb-panel.aicb-open  { transform:scale(1) translateY(0); opacity:1; pointer-events:all; }

/* HEADER */
.aicb-header {
  background:var(--aicb-header-bg);
  padding:14px 16px;
  display:flex; align-items:center; gap:11px;
  border-bottom:1px solid var(--aicb-border);
  flex-shrink:0; position:relative; overflow:hidden;
}
.aicb-header::before {
  content:''; position:absolute; inset:0;
  background:repeating-linear-gradient(45deg,transparent,transparent 10px,rgba(37,99,235,.03) 10px,rgba(37,99,235,.03) 11px);
}
.aicb-hav {
  width:46px; height:46px;
  background:#ffffff;
  border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; position:relative;
  box-shadow:0 4px 14px rgba(0,0,0,.3);
  padding:4px; box-sizing:border-box; z-index:1;
}
.aicb-hav img { width:100%; height:100%; object-fit:contain; border-radius:8px; display:block; }
.aicb-hav svg { width:24px; height:24px; fill:var(--aicb-accent); }
.aicb-hav-dot {
  position:absolute; bottom:-2px; right:-2px; z-index:2;
  width:12px; height:12px;
  border-radius:50%; border:2px solid var(--aicb-panel-bg);
  animation:aicb-pulse 2.5s infinite;
  transition:background .5s ease;
}
/* Status LED colors */
.aicb-hav-dot.status-ok      { background:#22c55e; }
.aicb-hav-dot.status-busy    { background:#f59e0b; animation:none; }
.aicb-hav-dot.status-error   { background:#ef4444; animation:none; }
.aicb-hav-dot.status-unknown { background:#94a3b8; animation:none; }
@keyframes aicb-pulse {
  0%,100%{box-shadow:0 0 0 0 rgba(34,197,94,.5)}
  50%    {box-shadow:0 0 0 5px rgba(34,197,94,0)}
}

.aicb-hinfo  { flex:1; z-index:1; }
.aicb-hname  { font-family:'Syne',sans-serif; font-weight:700; font-size:14px; color:#fff; }
.aicb-hsub   { font-size:11px; color:rgba(255,255,255,.45); margin-top:1px; }
.aicb-hbadge {
  font-size:9px; padding:3px 7px; border-radius:20px; z-index:1;
  background:rgba(37,99,235,.2); border:1px solid rgba(37,99,235,.4);
  color:rgba(255,255,255,.6); letter-spacing:.08em; text-transform:uppercase;
  font-family:'DM Sans',sans-serif; white-space:nowrap;
}

/* MESSAGES */
.aicb-msgs {
  flex:1; overflow-y:auto;
  padding:15px 13px; display:flex; flex-direction:column; gap:11px;
  scroll-behavior:smooth;
}
.aicb-msgs::-webkit-scrollbar { width:3px; }
.aicb-msgs::-webkit-scrollbar-thumb { background:rgba(37,99,235,.3); border-radius:10px; }

.aicb-msg { display:flex; gap:8px; animation:aicb-msg-in .33s cubic-bezier(.34,1.56,.64,1) both; }
.aicb-msg.aicb-user { flex-direction:row-reverse; }
@keyframes aicb-msg-in {
  from{opacity:0;transform:translateY(9px) scale(.96)}
  to  {opacity:1;transform:translateY(0) scale(1)}
}

.aicb-av {
  width:30px; height:30px; border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; margin-top:2px;
  padding:2px; box-sizing:border-box;
}
.aicb-av.aicb-bot  { background:#ffffff; }
.aicb-av.aicb-bot  img { width:100%; height:100%; object-fit:contain; border-radius:6px; display:block; }
.aicb-av.aicb-bot  svg { width:65%; fill:var(--aicb-accent); }
.aicb-av.aicb-user { background:rgba(255,255,255,.1); padding:4px; }
.aicb-av.aicb-user svg { width:75%; fill:rgba(255,255,255,.6); }

.aicb-bubble {
  max-width:82%; padding:9px 13px; border-radius:14px;
  font-size:13px; line-height:1.68; color:var(--aicb-bubble-text);
  font-family:'DM Sans',sans-serif;
}
.aicb-bubble.aicb-bot  { background:var(--aicb-bubble-bot); border:1px solid rgba(255,255,255,.07); border-bottom-left-radius:3px; }
.aicb-bubble.aicb-user { background:var(--aicb-bubble-user); border-bottom-right-radius:3px; box-shadow:0 3px 10px rgba(0,0,0,.2); }
.aicb-bubble strong { color:#fff; font-weight:600; }
.aicb-bubble a { color:#93c5fd; text-decoration:underline; word-break:break-all; }
.aicb-bubble code { background:rgba(255,255,255,.12); padding:1px 5px; border-radius:4px; font-size:12px; }

/* TYPING */
.aicb-typing-dot { display:flex; gap:5px; padding:10px 13px; align-items:center; }
.aicb-typing-dot span {
  width:7px; height:7px; border-radius:50%;
  background:rgba(37,99,235,.7); animation:aicb-bounce 1.4s infinite both;
}
.aicb-typing-dot span:nth-child(2){animation-delay:.18s}
.aicb-typing-dot span:nth-child(3){animation-delay:.36s}
@keyframes aicb-bounce {
  0%,80%,100%{transform:scale(.7);opacity:.5}
  40%         {transform:scale(1);opacity:1}
}

/* QUICK REPLIES */
.aicb-quick {
  padding:0 10px 8px; display:flex; flex-wrap:wrap; gap:6px; flex-shrink:0;
}
.aicb-qbtn {
  font-size:12px; padding:5px 12px; border-radius:20px; cursor:pointer;
  background:var(--aicb-qbtn-bg); border:1px solid rgba(255,255,255,.15);
  color:var(--aicb-qbtn-text); font-family:'DM Sans',sans-serif;
  transition:all .18s; white-space:nowrap;
}
.aicb-qbtn:hover { opacity:.85; transform:translateY(-1px); }

/* INPUT */
.aicb-inputbar {
  display:flex; align-items:flex-end; gap:8px;
  padding:11px 13px; background:var(--aicb-input);
  border-top:1px solid var(--aicb-border); flex-shrink:0;
}
.aicb-inputwrap {
  flex:1; background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.1); border-radius:12px; padding:2px 4px;
}
.aicb-inputwrap:focus-within { border-color:var(--aicb-accent); }
#aicb-textarea {
  width:100%; background:transparent; border:none; outline:none;
  color:var(--aicb-text); font-size:13px; font-family:'DM Sans',sans-serif;
  padding:7px 9px; resize:none; line-height:1.5; max-height:78px;
  overflow-y:auto;
}
#aicb-textarea::placeholder { color:rgba(255,255,255,.3); }
#aicb-send {
  width:38px; height:38px; background:var(--aicb-accent);
  border:none; border-radius:10px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; transition:background .2s, transform .15s;
}
#aicb-send:hover  { background:var(--aicb-accent-d); transform:scale(1.07); }
#aicb-send svg    { width:17px; height:17px; fill:white; }
#aicb-send:disabled { opacity:.45; cursor:not-allowed; transform:none; }

/* FOOTER */
.aicb-foot { text-align:center; font-size:10px; color:rgba(255,255,255,.2); padding:5px; font-family:'DM Sans',sans-serif; }

/* MOBILE */
@media(max-width:440px) {
  #aicb-panel { width:calc(100vw - 20px); }
  #aicb-panel.aicb-right{right:10px;bottom:84px;}
  #aicb-panel.aicb-left {left:10px;bottom:84px;}
}

/* ── LEAD CAPTURE FORM ── */
#aicb-lead-wrap { flex-shrink:0; overflow-y:auto; max-height:420px; }
.aicb-lead-form {
  padding:16px 14px;
  border-top:1px solid var(--aicb-border);
  background:var(--aicb-panel-bg);
}
.aicb-lead-title {
  font-family:'Syne',sans-serif; font-weight:700; font-size:14px;
  color:#fff; margin-bottom:6px;
}
.aicb-lead-desc {
  font-size:12px; color:rgba(255,255,255,.55); margin-bottom:14px; line-height:1.5;
}
.aicb-lead-fields { display:flex; flex-direction:column; gap:8px; }
.aicb-lead-row    { display:flex; gap:8px; }
.aicb-lead-row input { flex:1; min-width:0; }

.aicb-lead-fields input[type="text"],
.aicb-lead-fields input[type="email"],
.aicb-lead-fields input[type="tel"] {
  width:100%; box-sizing:border-box;
  background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.15);
  border-radius:8px; padding:8px 11px; color:#fff;
  font-size:13px; font-family:'DM Sans',sans-serif;
  outline:none; transition:border .18s;
}
.aicb-lead-fields input:focus { border-color:var(--aicb-accent); }
.aicb-lead-fields input::placeholder { color:rgba(255,255,255,.35); }

.aicb-lead-check {
  display:flex; align-items:flex-start; gap:8px; cursor:pointer;
  font-size:12px; color:rgba(255,255,255,.65); line-height:1.5;
}
.aicb-lead-check input[type="checkbox"] {
  width:15px; height:15px; margin-top:2px; flex-shrink:0;
  accent-color:var(--aicb-accent); cursor:pointer;
}
.aicb-lead-required { color:rgba(255,255,255,.8); }

.aicb-lead-error {
  background:rgba(239,68,68,.15); border:1px solid rgba(239,68,68,.4);
  border-radius:6px; padding:8px 10px; font-size:12px; color:#fca5a5;
}
.aicb-lead-btn {
  width:100%; padding:10px; background:var(--aicb-accent);
  border:none; border-radius:8px; color:#fff;
  font-size:14px; font-family:'Syne',sans-serif; font-weight:600;
  cursor:pointer; transition:background .2s;
  margin-top:4px;
}
.aicb-lead-btn:hover   { background:var(--aicb-accent-d); }
.aicb-lead-btn:disabled{ opacity:.5; cursor:not-allowed; }
