/* DexoBot widget styles */
.cb-toggle {
  position: fixed; bottom: 24px; right: 24px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; border: none; cursor: pointer;
  box-shadow: 0 12px 32px rgba(99,102,241,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  animation: cb-pulse 2.5s ease-in-out infinite;
}
.cb-toggle:hover { transform: scale(1.08) rotate(-6deg); }
.cb-toggle svg { width: 26px; height: 26px; }
.cb-toggle-logo { width: 38px; height: 38px; object-fit: contain; border-radius: 50%; }
.cb-toggle .cb-toggle-close { display: none; }
.cb-avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.cb-toggle.open .cb-toggle-open { display: none; }
.cb-toggle.open .cb-toggle-close { display: block; }
.cb-toggle-badge {
  position: absolute; top: -2px; right: -2px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px #0b0d12;
}
.cb-toggle.open .cb-toggle-badge { display: none; }
@keyframes cb-pulse {
  0%, 100% { box-shadow: 0 12px 32px rgba(99,102,241,.45), 0 0 0 0 rgba(99,102,241,.4); }
  50% { box-shadow: 0 12px 32px rgba(99,102,241,.45), 0 0 0 14px rgba(99,102,241,0); }
}

.cb-window {
  position: fixed; bottom: 100px; right: 24px;
  width: 400px; height: 600px;
  background: #0f1218;
  border: 1px solid #262c3a;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  display: none; flex-direction: column; overflow: hidden;
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
  color: #e7eaf3;
  transform-origin: bottom right;
  animation: cb-pop .25s cubic-bezier(.34,1.56,.64,1);
}
.cb-window.open { display: flex; }
@keyframes cb-pop {
  from { opacity: 0; transform: scale(.85) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.cb-window.fullscreen {
  width: 100vw; height: 100vh; bottom: 0; right: 0;
  border-radius: 0; border: none;
}
.cb-window.fullscreen .cb-messages-inner,
.cb-window.fullscreen .cb-input-inner,
.cb-window.fullscreen .cb-tools-inner,
.cb-window.fullscreen .cb-suggest { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }

.cb-header {
  background: linear-gradient(135deg, #1a1f2e 0%, #161a26 100%);
  padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #262c3a;
}
.cb-title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.cb-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.cb-avatar svg { width: 18px; height: 18px; color: #fff; }
.cb-avatar::after {
  content: ''; position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; background: #10b981;
  border: 2px solid #0f1218; border-radius: 50%;
}
.cb-status { font-size: 11px; color: #6b7388; font-weight: 400; }
.cb-actions { display: flex; gap: 4px; }
.cb-actions button {
  background: transparent; border: none; color: #9aa3b8;
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.cb-actions button:hover { background: rgba(255,255,255,.06); color: #e7eaf3; }
.cb-actions svg { width: 16px; height: 16px; }

.cb-messages { flex: 1; overflow-y: auto; background: #0b0d12; padding: 16px; }
.cb-messages-inner { display: flex; flex-direction: column; gap: 12px; }
.cb-messages::-webkit-scrollbar { width: 8px; }
.cb-messages::-webkit-scrollbar-thumb { background: #262c3a; border-radius: 4px; }
.cb-messages::-webkit-scrollbar-thumb:hover { background: #353c4d; }

.cb-msg-row { display: flex; gap: 10px; align-items: flex-start; animation: cb-msg-in .25s ease-out; }
.cb-msg-row.user { flex-direction: row-reverse; }
@keyframes cb-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.cb-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 12px; font-weight: 600;
}
.cb-msg-row.bot .cb-msg-avatar { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.cb-msg-row.user .cb-msg-avatar { background: #262c3a; color: #9aa3b8; }
.cb-msg-row.bot .cb-msg-avatar svg { width: 14px; height: 14px; }

.cb-msg {
  padding: 10px 14px; border-radius: 14px;
  max-width: 80%; line-height: 1.5; font-size: 14px;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.cb-msg p { margin: 0 0 6px; }
.cb-msg p:last-child { margin: 0; }
.cb-msg ul { margin: 4px 0; padding-left: 20px; }
.cb-msg pre { background: rgba(0,0,0,.4); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 6px 0; }
.cb-msg pre code { background: none; padding: 0; }
.cb-msg-row.user .cb-msg { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.cb-msg-row.bot .cb-msg { background: #1a1f2e; color: #e7eaf3; border: 1px solid #262c3a; border-bottom-left-radius: 4px; }
.cb-msg-row.err .cb-msg { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.cb-msg.cb-tool { opacity: .7; font-style: italic; font-size: 12px; }
.cb-msg code { background: rgba(0,0,0,.3); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.cb-msg a { color: #c7d2fe; text-decoration: underline; }

.cb-typing { display: inline-flex; gap: 4px; padding: 14px 16px !important; }
.cb-typing span { width: 7px; height: 7px; background: #6b7388; border-radius: 50%; animation: cb-bounce 1.2s infinite ease-in-out; }
.cb-typing span:nth-child(2) { animation-delay: .15s; }
.cb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cb-bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.cb-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; background: #0b0d12; }
.cb-suggest button {
  background: #1a1f2e; border: 1px solid #262c3a; color: #c7d2fe;
  padding: 6px 10px; border-radius: 999px; font-size: 12px; cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.cb-suggest button:hover { border-color: #6366f1; color: #fff; }

.cb-tools { padding: 8px 14px; background: #0f1218; border-top: 1px solid #262c3a; }
.cb-tools-inner { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.cb-tools label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: #9aa3b8; }
.cb-tools input[type="checkbox"] { accent-color: #6366f1; }
.cb-persona {
  background: #1a1f2e; border: 1px solid #262c3a; color: #c7d2fe;
  padding: 4px 8px; border-radius: 6px; font-size: 12px; cursor: pointer;
  margin-left: auto; font-family: inherit;
}
.cb-persona:focus { outline: none; border-color: #6366f1; }

.cb-input { background: #0f1218; border-top: 1px solid #262c3a; padding: 12px; }
.cb-input-inner { display: flex; gap: 8px; align-items: flex-end; }
.cb-input textarea {
  flex: 1; padding: 10px 14px;
  border: 1px solid #262c3a; background: #1a1f2e; color: #e7eaf3;
  border-radius: 12px; outline: none;
  font-size: 14px; font-family: inherit; resize: none;
  max-height: 120px; min-height: 40px; line-height: 1.4;
  transition: border-color .15s;
}
.cb-input textarea:focus { border-color: #6366f1; }
.cb-input textarea::placeholder { color: #6b7388; }
.cb-mic, .cb-send {
  border: none; width: 40px; height: 40px; border-radius: 12px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: transform .12s, box-shadow .2s, opacity .2s, background .2s;
}
.cb-mic { background: #1a1f2e; color: #9aa3b8; border: 1px solid #262c3a; }
.cb-mic:hover { color: #e7eaf3; }
.cb-mic.active { background: #ef4444; color: #fff; animation: cb-rec 1s infinite; }
@keyframes cb-rec { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.6); } 50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); } }
.cb-send { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; box-shadow: 0 4px 16px rgba(99,102,241,.35); }
.cb-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,.5); }
.cb-send:disabled { opacity: .5; cursor: not-allowed; }
.cb-send svg, .cb-mic svg { width: 18px; height: 18px; }
.cb-foot { text-align: center; font-size: 10px; color: #6b7388; margin-top: 6px; letter-spacing: .04em; }
.cb-foot strong { color: #c7d2fe; font-weight: 600; }

/* Lead modal */
.cb-lead {
  position: absolute; inset: 0; background: rgba(11,13,18,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 5; padding: 20px; backdrop-filter: blur(4px);
}
.cb-lead[hidden] { display: none !important; }
.cb-lead-card {
  background: #1a1f2e; border: 1px solid #262c3a; border-radius: 14px;
  padding: 20px; width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 8px;
}
.cb-lead-card h4 { margin: 0; font-size: 16px; }
.cb-lead-card p { margin: 0 0 4px; font-size: 13px; color: #9aa3b8; }
.cb-lead-card input, .cb-lead-card textarea {
  background: #0f1218; border: 1px solid #262c3a; color: #e7eaf3;
  padding: 8px 10px; border-radius: 8px; font-size: 13px; font-family: inherit; outline: none;
}
.cb-lead-card input:focus, .cb-lead-card textarea:focus { border-color: #6366f1; }
.cb-lead-actions { display: flex; gap: 8px; margin-top: 4px; }
.cb-lead-actions button {
  flex: 1; padding: 9px; border-radius: 8px; border: none; cursor: pointer;
  font-family: inherit; font-weight: 600; font-size: 13px;
}
#cb-lead-cancel { background: transparent; color: #9aa3b8; border: 1px solid #262c3a; }
#cb-lead-cancel:hover { color: #fff; }
#cb-lead-submit { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.cb-lead-status { font-size: 12px; color: #9aa3b8; min-height: 16px; }

@media (max-width: 480px) {
  .cb-window:not(.fullscreen) { width: calc(100vw - 24px); height: calc(100vh - 130px); right: 12px; bottom: 92px; }
  .cb-toggle { right: 16px; bottom: 16px; }
}
