:root {
  --cb-color: #3aada8;
  --cb-radius: 16px;
  --cb-shadow: 0 8px 32px rgba(0,0,0,.18);
}

/* 2026-07-14 (Eduardo: "vamos a quitar el icono... y lo vamos a sustituir
   por la herramienta de traduccion"): el icono flotante y su burbuja de
   eslogan se ocultan - Dogyngo (antes "Mario") sigue disponible tal cual
   desde el menu lateral ("Habla con Dogyngo"), que llama a
   window.abrirChatbotIA() (ver chatbot-v4.js) sin tocar esa logica. Oculto
   por CSS y no borrado del DOM/JS a proposito: revertirlo es una linea si
   hiciera falta, y evita tocar la logica de arrastre del boton (bastante
   enredada con el propio #cb-btn) sin necesidad real. El hueco visual lo
   ocupa ahora #traductor-btn (ver traductor/static/traductor/css/traductor.css). */
#cb-btn, #cb-slogan { display: none !important; }

/* ── Botón flotante — logo contenido, no a sangre completa ── */
#cb-btn {
  position: fixed;
  bottom: 40px;
  right: 24px;
  width: 76px;
  height: 76px;
  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: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* ── Burbuja de eslóganes de Dogyngo (refuerzo de marca, chat cerrado) ── */
#cb-slogan {
  position: fixed;
  bottom: 60px;
  right: 112px;
  max-width: 220px;
  background: #fff;
  color: #1f2933;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.35;
  padding: .6rem .85rem;
  border-radius: 14px;
  box-shadow: var(--cb-shadow);
  z-index: 9997;
  opacity: 0;
  transform: translateY(6px) scale(.96);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
#cb-slogan::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: 18px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
}
#cb-slogan.cb-slogan--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
@media (prefers-color-scheme: dark) {
  #cb-slogan, #cb-slogan::after { background: #22303f; color: #f1f5f9; }
}
@media (max-width: 480px) {
  #cb-slogan { right: 96px; max-width: 170px; font-size: .76rem; }
}

/* ── Caja del chat ── */
#cb-box {
  position: fixed;
  bottom: 128px;
  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%; }
}

/* ==========================================================================
   2026-07-17 (Eduardo: "Dogyngo integrado en la web, no un chat aparte") -
   modo incrustado: el panel vive en el flujo normal de la pagina (bienvenida
   tras matricularse, "levantar la mano" en un ejercicio, preguntas en
   /profesorado/), nunca como overlay flotante. Icono/eslogan/pantalla
   completa no tienen sentido aqui - solo el panel de mensajes, siempre en
   su sitio. Ver data-modo en chatbot-v4.js/widget.html.
   ========================================================================== */
#chatbot-ia-root.cb-inline #cb-btn,
#chatbot-ia-root.cb-inline #cb-slogan { display: none !important; }
#chatbot-ia-root.cb-inline #cb-box {
  position: static;
  width: 100%;
  height: 420px;
  max-height: 60vh;
  opacity: 1;
  transform: none;
  pointer-events: all;
  box-shadow: none;
  border: 1px solid var(--t-line, rgba(0,0,0,.1));
  margin: 0;
}
#chatbot-ia-root.cb-inline #cb-box:not(.cb-open) { display: none; }
#chatbot-ia-root.cb-inline #cb-box.cb-full { width: 100%; height: 420px; max-height: 60vh; }
#chatbot-ia-root.cb-inline #cb-full { display: none; }

/* ==========================================================================
   2026-07-26 (Eduardo: "el diseño del chat que aparece rompe toda la
   experiencia, debes integrarlo mejor, 100% y con el estilo de diseño
   correspondiente"): el widget usaba una paleta propia fija (teal
   --cb-color, fondo crema #fdf6f0, blancos duros) y chrome de "ventana
   flotante" (minimizar/cerrar) que tenía sentido cuando SÍ era un overlay
   suelto, pero no dentro de la tarjeta del ejercicio. Todo esto reemplaza
   los colores fijos por las --t-* del tema activo (se re-tema solo con
   modo Kids/oscuro, sin tocar este CSS de nuevo) y quita el chrome que ya
   no pinta nada aquí. Solo afecta a .cb-inline - el widget flotante
   normal (icono global) no se toca. */
#chatbot-ia-root.cb-inline #cb-box {
  background: var(--t-bg);
  border-radius: var(--t-radius, 14px);
}
#chatbot-ia-root.cb-inline #cb-header {
  background: var(--t-panel);
  color: var(--t-text);
  border-bottom: 1px solid var(--t-line);
  border-radius: var(--t-radius, 14px) var(--t-radius, 14px) 0 0;
}
#chatbot-ia-root.cb-inline #cb-header .cb-dot { background: var(--t-accent); }
#chatbot-ia-root.cb-inline .cb-ctrl { background: var(--t-accent-faint, rgba(0,0,0,.06)); color: var(--t-text); }
#chatbot-ia-root.cb-inline .cb-ctrl:hover { background: var(--t-accent); color: #fff; }
/* "Minimizar" y "Cerrar" hacian lo mismo en la practica dentro de una
   tarjeta ya controlada por el boton "Levantar la mano" - un solo control
   (cerrar) es mas claro que dos iconos casi identicos. */
#chatbot-ia-root.cb-inline #cb-min { display: none; }
#chatbot-ia-root.cb-inline #cb-messages { background: var(--t-bg); }
#chatbot-ia-root.cb-inline .cb-msg.bot {
  background: var(--t-panel);
  border: 1px solid var(--t-line);
  color: var(--t-text);
}
#chatbot-ia-root.cb-inline .cb-msg.user { background: var(--t-accent); color: #fff; }
#chatbot-ia-root.cb-inline .cb-msg.aviso {
  background: var(--t-accent2-faint, #fff7ed);
  border-color: var(--t-accent2, #fdba74);
  color: var(--t-text);
}
#chatbot-ia-root.cb-inline #cb-footer {
  background: var(--t-panel);
  border-top: 1px solid var(--t-line);
  border-radius: 0 0 var(--t-radius, 14px) var(--t-radius, 14px);
}
#chatbot-ia-root.cb-inline #cb-input {
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  color: var(--t-text);
}
#chatbot-ia-root.cb-inline #cb-input:focus { border-color: var(--t-accent); }
#chatbot-ia-root.cb-inline #cb-mic { background: var(--t-bg); border-color: var(--t-line); }
#chatbot-ia-root.cb-inline #cb-mic:hover { border-color: var(--t-accent); }
#chatbot-ia-root.cb-inline #cb-send { background: var(--t-accent); }
#chatbot-ia-root.cb-inline #cb-powered { background: var(--t-panel); color: var(--t-muted); }
