:root {
  --cb-color: #3aada8;
  --cb-radius: 16px;
  --cb-shadow: 0 8px 32px rgba(0,0,0,.18);
}

/* ── Botón flotante — logo contenido, no a sangre completa ── */
#cb-btn {
  position: fixed;
  bottom: 40px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cb-color);
  border: none;
  cursor: grab;
  font-size: 24px;
  box-shadow: var(--cb-shadow);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
#cb-btn:hover { transform: scale(1.08); }
#cb-btn:active { cursor: grabbing; }
#cb-btn img {
  width: 66%;
  height: 66%;
  object-fit: contain;
  border-radius: 0;
}

/* ── Caja del chat ── */
#cb-box {
  position: fixed;
  bottom: 108px;
  right: 24px;
  width: 340px;
  height: 480px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s, transform .22s, width .25s, height .25s, bottom .25s, right .25s;
}
#cb-box.cb-open {
  opacity: 1;
  transform: none;
  pointer-events: all;
}

/* Pantalla completa: 80% del viewport, centrado */
#cb-box.cb-full {
  width: 80vw;
  height: 80vh;
  max-height: 80vh;
  right: 10vw;
  bottom: 10vh;
}

/* ── Cabecera: solo nombre + estado + controles (sin imagen) ── */
#cb-header {
  background: var(--cb-color);
  color: #fff;
  padding: 12px 14px;
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.cb-header-nombre { letter-spacing: .01em; }
#cb-header .cb-dot {
  width: 8px; height: 8px;
  background: #a7f3d0;
  border-radius: 50%;
  display: inline-block;
}
.cb-controles { margin-left: auto; display: flex; gap: 4px; }
.cb-ctrl {
  background: rgba(255,255,255,.16);
  border: none;
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.cb-ctrl:hover { background: rgba(255,255,255,.3); }

/* ── Mensajes ── */
#cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fdf6f0;
}

.cb-msg {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
}
#cb-box.cb-full .cb-msg { max-width: 62%; font-size: .95rem; }
.cb-msg.bot {
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  padding-right: 34px;
}
.cb-msg.user {
  background: var(--cb-color);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.cb-msg.aviso {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #7c2d12;
  align-self: center;
  max-width: 92%;
  font-size: .82rem;
  text-align: center;
  white-space: pre-line;
  padding-right: 13px;
}

/* Altavoz por mensaje */
.cb-speak {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .8rem;
  opacity: .45;
  padding: 2px;
  transition: opacity .15s, transform .15s;
}
.cb-speak:hover { opacity: 1; }
.cb-speak--on { opacity: 1; transform: scale(1.15); }

.cb-msg.typing span {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--cb-color);
  border-radius: 50%;
  margin: 0 2px;
  animation: cb-pulse .9s infinite;
}
.cb-msg.typing span:nth-child(2) { animation-delay: .15s; }
.cb-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cb-pulse {
  0%,80%,100% { transform: scale(0.7); opacity:.5; }
  40% { transform: scale(1); opacity:1; }
}

/* ── Pie: micrófono + entrada + enviar ── */
#cb-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(0,0,0,.07);
  background: #fff;
  flex-shrink: 0;
}
#cb-mic {
  background: #fff;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 8px;
  width: 38px;
  cursor: pointer;
  font-size: .95rem;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
#cb-mic:hover { border-color: var(--cb-color); }
#cb-mic.cb-mic--on {
  background: #fde8e8;
  border-color: #ef4444;
  animation: cb-mic-pulso 1.1s infinite;
}
@keyframes cb-mic-pulso {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.35); }
  55% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
#cb-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .88rem;
  outline: none;
  background: #fff;
  color: #2d2d2d;
}
#cb-input:focus { border-color: var(--cb-color); }
#cb-send {
  background: var(--cb-color);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 1rem;
  transition: opacity .15s;
  flex-shrink: 0;
}
#cb-send:disabled { opacity: .5; cursor: default; }

#cb-powered {
  text-align: center;
  font-size: .68rem;
  color: #888;
  opacity: .6;
  padding: 4px 0 6px;
  background: #fff;
  flex-shrink: 0;
}

@media (max-width: 500px) {
  #cb-box { width: calc(100vw - 32px); right: 16px; }
  #cb-box.cb-full { width: calc(100vw - 16px); height: 86vh; right: 8px; bottom: 7vh; }
  #cb-box.cb-full .cb-msg { max-width: 84%; }
}
