/* --- Botón flotante --- */
#chat-toggle-btn {
  position: fixed;
  bottom: 64px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: #343a40;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(52, 58, 64, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  z-index: 9999;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#chat-toggle-btn:hover {
  background-color: #1d2124;
  transform: scale(1.08);
}

#chat-toggle-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 58, 64, 0.35);
}

/* Badge de notificación (opcional, para uso futuro) */
#chat-toggle-btn .chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #dc3545;
  border-radius: 50%;
  font-size: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid #fff;
}

/* --- Ventana del chat --- */
#chat-window {
  position: fixed;
  bottom: 140px;
  right: 28px;
  width: 320px;
  /* Alto: un punto más que antes (420), nunca más que la pantalla. El
     max-height descuenta el hueco del botón flotante (bottom: 140px). */
  height: 500px;
  max-height: calc(100vh - 180px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  /* estado inicial: oculto y desplazado hacia abajo */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#chat-window.chat-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Header --- */
#chat-window .chat-header {
  background-color: #343a40;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: 12px 12px 0 0;
}

#chat-window .chat-header .chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

#chat-window .chat-header .chat-title .chat-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

#chat-window .chat-header .chat-status {
  font-size: 0.72rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 1px;
}

#chat-window .chat-header .chat-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

#chat-window .chat-header .chat-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

#chat-window .chat-header .chat-close-btn:focus {
  outline: none;
}

/* --- Área de mensajes --- */
#chat-window .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fa;
}

#chat-window .chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-window .chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chat-window .chat-messages::-webkit-scrollbar-thumb {
  background: #ced4da;
  border-radius: 4px;
}

/* Modal lista de reacciones */
.chat-rea-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10010;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.chat-rea-modal.open {
  display: flex;
}
.chat-rea-modal-content {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}
.chat-rea-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #343a40;
  color: #fff;
}
.chat-rea-modal-title {
  font-size: 0.95rem;
  font-weight: 600;
}
.chat-rea-modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.85;
}
.chat-rea-modal-close:hover { opacity: 1; }
.chat-rea-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
}
.chat-rea-tab {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.chat-rea-tab:hover { background: #e9ecef; }
.chat-rea-tab.active {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}
.chat-rea-tab-count {
  font-size: 0.7rem;
  opacity: 0.8;
  font-weight: 600;
}
.chat-rea-list {
  overflow-y: auto;
  padding: 4px 0;
  flex: 1;
}
.chat-rea-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f3f5;
}
.chat-rea-row:last-child { border-bottom: none; }
.chat-rea-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.chat-rea-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.chat-rea-avatar-fb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #adb5bd;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.chat-rea-info {
  flex: 1;
  min-width: 0;
}
.chat-rea-nom {
  font-size: 0.85rem;
  font-weight: 600;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-rea-fec {
  font-size: 0.72rem;
  color: #868e96;
}
.chat-rea-emoji {
  font-size: 1.3rem;
  flex-shrink: 0;
}
.chat-rea-empty {
  padding: 30px 16px;
  text-align: center;
  color: #868e96;
  font-size: 0.85rem;
}

/* Separador de fechas tipo WhatsApp */
.chat-date-divider {
  display: flex;
  justify-content: center;
  margin: 14px 0 8px;
}
.chat-date-divider > span {
  background: rgba(0, 0, 0, 0.08);
  color: #555;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  text-transform: capitalize;
  letter-spacing: 0.3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Burbujas de mensaje */
.chat-bubble {
  position: relative;          /* ancla del botón copiar */
  max-width: 80%;
  padding: 8px 28px 8px 12px;  /* hueco derecho reservado al botón copiar */
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.45;
  word-break: break-word;
}

.chat-bubble.chat-bubble-agent {
  background: #fff;
  color: #343a40;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-bubble.chat-bubble-user {
  background: #007bff;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-bubble .bubble-time {
  display: block;
  font-size: 0.65rem;
  margin-top: 4px;
  opacity: 0.65;
  text-align: right;
}

/* --- Footer / input --- */
#chat-window .chat-footer {
  padding: 10px 12px;
  border-top: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  flex-shrink: 0;
}

#chat-window .chat-footer #chat-input {
  flex: 1;
  border: 1px solid #ced4da;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: none;
  background: #f8f9fa;
  color: #343a40;
  line-height: 1.4;
  height: 36px;
  overflow: hidden;
}

#chat-window .chat-footer #chat-input:focus {
  border-color: #6c757d;
  box-shadow: 0 0 0 2px rgba(52, 58, 64, 0.18);
  background: #fff;
}

#chat-window .chat-footer #chat-input::placeholder {
  color: #adb5bd;
}

#chat-window .chat-footer .chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #343a40;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: background-color 0.15s, transform 0.15s;
}

#chat-window .chat-footer .chat-send-btn:hover {
  background-color: #1d2124;
  transform: scale(1.05);
}

#chat-window .chat-footer .chat-send-btn:focus {
  outline: none;
}

/* --- Responsive: pantallas pequeñas --- */
@media (max-width: 400px) {
  #chat-window {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    height: 560px;
    max-height: calc(100vh - 120px);
  }

  #chat-toggle-btn {
    right: 16px;
    bottom: 20px;
  }
}

/* ============================================================
   Badge de no leídos (contador numérico)
   ============================================================ */
#chat-toggle-btn .chat-badge-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  background: #e8162a;
  border-radius: 13px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 3px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.55);
  animation: badge-pulse 1.8s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ============================================================
   Burbujas de evento automático (notificación de venta)
   ============================================================ */
.chat-bubble.chat-bubble-event {
  align-self: center;
  max-width: 95%;
  background: #d4edda;
  color: #155724;
  border-radius: 10px;
  border-left: 3px solid #28a745;
  font-size: 0.8rem;
  padding: 7px 11px;
}

.chat-bubble.chat-bubble-event .bubble-event-icon {
  margin-right: 5px;
  color: #28a745;
}

/* El texto del aviso puede traer saltos de línea (avisos multilínea que el
   cliente no sepa pintar como tarjeta): se respetan, sin conservar sangrías. */
.chat-bubble .bubble-event-text {
  white-space: pre-line;
}

/* ============================================================
   Burbuja para notificación de evento creado (morado)
   Mismo layout que .chat-bubble-event con paleta distinta.
   ============================================================ */
.chat-bubble.chat-bubble-evento {
  align-self: center;
  max-width: 95%;
  background: #ede5f7;
  color: #4b287a;
  border-radius: 10px;
  border-left: 3px solid #6f42c1;
  font-size: 0.8rem;
  padding: 7px 11px;
}

.chat-bubble.chat-bubble-evento .bubble-event-icon {
  margin-right: 5px;
  color: #6f42c1;
}

/* ============================================================
   Burbuja para notificación de primera venta (azul podio)
   Tono azul derivado del borde de avatar en "Primera Venta".
   ============================================================ */
.chat-bubble.chat-bubble-primera-venta {
  align-self: center;
  max-width: 95%;
  background: #e0efff;
  color: #0b3d7a;
  border-radius: 10px;
  border-left: 3px solid #3b82f6;
  font-size: 0.8rem;
  padding: 7px 11px;
}

.chat-bubble.chat-bubble-primera-venta .bubble-event-icon {
  margin-right: 5px;
  color: #3b82f6;
}

/* ============================================================
   Burbuja para notificación de medalla asignada (naranja)
   ============================================================ */
.chat-bubble.chat-bubble-medalla {
  align-self: center;
  max-width: 95%;
  background: #fff3e0;
  color: #8a4b08;
  border-radius: 10px;
  border-left: 3px solid #fd7e14;
  font-size: 0.8rem;
  padding: 7px 11px;
}

.chat-bubble.chat-bubble-medalla .bubble-event-icon {
  margin-right: 5px;
  color: #fd7e14;
}

/* ============================================================
   Burbuja para premio de ruleta (rosa)

   Faltaba su base legacy: solo existían los colores por token en
   nw-ui/components.css, así que sin el kit —o antes de que cargue— la
   burbuja se quedaba sin radio, sin padding propio y SIN FILETE, porque
   `border-left-color` no pinta nada mientras el estilo del borde sea
   `none`. Mismo layout que las demás, con la paleta de la ruleta.
   ============================================================ */
.chat-bubble.chat-bubble-ruleta {
  align-self: center;
  max-width: 95%;
  background: #fde7f1;
  color: #8c2455;
  border-radius: 10px;
  border-left: 3px solid #e5498d;
  font-size: 0.8rem;
  padding: 7px 11px;
}

.chat-bubble.chat-bubble-ruleta .bubble-event-icon {
  margin-right: 5px;
  color: #e5498d;
}

/* ============================================================
   Alerta operativa de la API de integración (subtipo `api`):
   el freno de ritmo dejó de premiar. Solo la ven los usuarios de
   rol Administrador (chat_destinatario). Gris a propósito: no es
   una celebración, es un aviso.
   ============================================================ */
.chat-bubble.chat-bubble-api {
  align-self: center;
  max-width: 95%;
  background: #eceff3;
  color: #3f4a56;
  border-radius: 10px;
  border-left: 3px solid #6c7a89;
  font-size: 0.8rem;
  padding: 7px 11px;
}

.chat-bubble.chat-bubble-api .bubble-event-icon {
  margin-right: 5px;
}

/* Las burbujas automáticas fijan su propio padding: se les devuelve el
   hueco derecho del botón copiar. */
.chat-bubble.chat-bubble-event,
.chat-bubble.chat-bubble-evento,
.chat-bubble.chat-bubble-primera-venta,
.chat-bubble.chat-bubble-medalla,
.chat-bubble.chat-bubble-ruleta,
.chat-bubble.chat-bubble-api {
  padding-right: 28px;
}

/* ============================================================
   Botón "copiar al portapapeles" (una por burbuja)
   Aparece al pasar el ratón sobre la burbuja; en táctil queda
   siempre visible, atenuado.
   ============================================================ */
.chat-copy-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #6c757d;
  font-size: 0.62rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s, background 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
  z-index: 2;
}

.chat-bubble:hover .chat-copy-btn,
.chat-copy-btn:focus,
.chat-copy-btn.copiado,
.chat-copy-btn.copia-error {
  opacity: 1;
  transform: scale(1);
}

.chat-copy-btn:hover  { color: #212529; background: #fff; }
.chat-copy-btn:focus  { outline: none; box-shadow: 0 0 0 2px rgba(52, 58, 64, 0.25); }
.chat-copy-btn.copiado     { color: #1d9e75; }
.chat-copy-btn.copia-error { color: #dc3545; }

@media (hover: none) {
  .chat-copy-btn { opacity: 0.7; transform: scale(1); }
}

/* ============================================================
   Tarjeta de "NUEVA VENTA" (mensaje automático de venta)
   El orden, los emojis y los datos los define el backend
   (helpers/chat_venta_helper.php); aquí solo se maqueta.
   ============================================================ */
.chat-venta-card {
  display: block;
  line-height: 1.4;
  /* Alineación propia: la burbuja vive dentro de contenedores que a veces
     centran texto, y una tarjeta centrada se lee fatal. */
  text-align: left;
  /* Cancela el pre-line de .bubble-event-text: aquí el salto lo da el marcado. */
  white-space: normal;
}

/* Todo el contenido de la tarjeta se alinea a la izquierda pase lo que pase:
   ni el centrado heredado de la burbuja ni el de un contenedor padre lo mueven.
   Sin esto, la segunda línea de un valor largo se queda flotando al centro. */
.chat-venta-card .cv-title,
.chat-venta-card .cv-rows,
.chat-venta-card .cv-label,
.chat-venta-card .cv-value,
.chat-venta-card .cv-foot {
  text-align: left;
}

.chat-venta-card .cv-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding-bottom: 5px;
  margin-bottom: 6px;
  border-bottom: 1px solid currentColor;
  /* El filete separa sin gritar: hereda el color del aviso, atenuado. */
  border-bottom-color: rgba(21, 87, 36, 0.18);
}

.chat-venta-card .cv-title-ico { font-size: 0.95rem; line-height: 1; }

/* Ficha de dos columnas: etiquetas a la izquierda (ancho del texto más largo)
   y valores en una única vertical. El grid vive aquí y cada `.cv-row` es
   `display:contents`, así las celdas de TODAS las filas comparten las mismas
   dos columnas y nada queda escalonado. */
.chat-venta-card .cv-rows {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 3px;
  align-items: baseline;
}

.chat-venta-card .cv-row { display: contents; }

.chat-venta-card .cv-label {
  margin: 0;
  font-weight: 600;
  opacity: 0.8;
  white-space: nowrap;   /* la etiqueta nunca parte: fija el ancho de columna */
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.chat-venta-card .cv-emoji {
  font-style: normal;
  width: 1.15em;
  flex: 0 0 1.15em;
  text-align: center;
}

.chat-venta-card .cv-value {
  margin: 0;
  min-width: 0;
  font-weight: 600;
  /* Nombres y catálogos vienen en MAYÚSCULAS y sin espacios de cortesía:
     que parta donde haga falta antes que desbordar la burbuja. */
  overflow-wrap: anywhere;
}

.chat-venta-card .cv-foot {
  margin-top: 7px;
  padding-top: 5px;
  border-top: 1px solid rgba(21, 87, 36, 0.18);
  font-weight: 600;
}

/* Burbuja estrecha (móvil): las dos columnas no caben, se apilan. La etiqueta
   queda encima de su valor y ambos arrancan en el mismo margen. */
@media (max-width: 360px) {
  .chat-venta-card .cv-rows {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 5px;
  }
  .chat-venta-card .cv-label { opacity: 0.7; font-size: 0.95em; }
}

/* Sin el icono genérico del aviso: la tarjeta ya trae el suyo en el título. */
.chat-bubble.chat-bubble-venta .bubble-event-icon { display: none; }

/* El contenedor del texto es un <span> inline: como bloque, la tarjeta ocupa
   todo el ancho de la burbuja y su grid mide bien las columnas. */
.chat-bubble.chat-bubble-venta .bubble-event-text {
  display: block;
  text-align: left;
}

.chat-bubble.chat-bubble-venta { max-width: 100%; }

/* ============================================================
   Tarjeta de "PREMIO EN LA RULETA"

   El aviso era una línea de texto y se pidió que se notara más. Sube a
   tarjeta con tres alturas de lectura: el rótulo, quién ganó y —lo
   grande— qué ganó. El contenido lo arma chat-widget.js desde
   `cha_params`; aquí solo se maqueta.

   Los colores van en este archivo en su versión legacy (rosa fijo) y se
   redefinen por token en nw-ui/components.css, como el resto del chat.
   ============================================================ */
.chat-rul-card {
  display: block;
  line-height: 1.35;
  text-align: left;
  /* Cancela el pre-line de .bubble-event-text: aquí el salto lo da el marcado. */
  white-space: normal;
}

.chat-rul-card .cr-title,
.chat-rul-card .cr-nom,
.chat-rul-card .cr-premio { text-align: left; }

.chat-rul-card .cr-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding-bottom: 4px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(190, 24, 93, 0.20);
}

.chat-rul-card .cr-title-ico { font-size: 0.95rem; line-height: 1; }

.chat-rul-card .cr-nom {
  font-weight: 600;
  font-size: 0.82rem;
  opacity: 0.85;
}

/* El premio es lo que se ha ganado: es la línea que se lee de un vistazo. */
.chat-rul-card .cr-premio {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.chat-rul-card .cr-premio-ico {
  font-size: 1.1rem;
  line-height: 1;
  /* Un guiño, no una feria: dos vueltas y se queda quieto. */
  animation: chat-rul-pop 0.6s ease-out 2;
}

@keyframes chat-rul-pop {
  0%, 100% { transform: scale(1)    rotate(0deg); }
  35%      { transform: scale(1.28) rotate(-12deg); }
  70%      { transform: scale(1.12) rotate(9deg); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-rul-card .cr-premio-ico { animation: none; }
}

/* Sin el icono genérico del aviso: la tarjeta trae el suyo en el título. */
.chat-bubble.chat-bubble-premio .bubble-event-icon { display: none; }

/* El contenedor del texto es un <span> inline: como bloque, la tarjeta ocupa
   todo el ancho de la burbuja. */
.chat-bubble.chat-bubble-premio .bubble-event-text {
  display: block;
  text-align: left;
}

.chat-bubble.chat-bubble-premio { max-width: 100%; }

/* ============================================================
   Nombre del autor sobre la burbuja (mensajes manuales)
   ============================================================ */
.chat-msg-wrapper {
  display: flex;
  flex-direction: column;
}

.chat-msg-wrapper .bubble-author {
  font-size: 0.65rem;
  font-weight: 600;
  color: #6c757d;
  margin-bottom: 2px;
  padding-left: 4px;
}

.chat-msg-wrapper.mine .bubble-author {
  text-align: right;
  padding-right: 4px;
}

/* ============================================================
   Reacciones bajo cada burbuja
   ============================================================ */
.chat-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.chat-reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  padding: 1px 7px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.chat-reaction-pill:hover {
  background: #f1f3f5;
  border-color: #adb5bd;
}

.chat-reaction-pill.yo-reaccione {
  background: #e7f3ff;
  border-color: #74b9ff;
}

.chat-reaction-pill .rea-count {
  font-size: 0.7rem;
  color: #495057;
}

/* ============================================================
   Picker de reacciones (popup al hover/click)
   ============================================================ */
.reaction-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 24px;
  padding: 5px 8px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  z-index: 10010;
  opacity: 0;
  transform: translateY(6px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.reaction-picker.picker-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.reaction-picker .rea-opt {
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.12s;
  line-height: 1;
  padding: 2px;
  border-radius: 50%;
}

.reaction-picker .rea-opt:hover {
  transform: scale(1.35);
}

/* Wrapper de burbuja con posición relativa para el picker */
.chat-bubble-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   Loader de lazy load (scroll hacia arriba)
   ============================================================ */
.chat-load-more {
  text-align: center;
  padding: 8px 0 4px;
  font-size: 0.75rem;
  color: #6c757d;
}

.chat-load-more .spinner-border {
  width: 14px;
  height: 14px;
  border-width: 2px;
  vertical-align: middle;
  margin-right: 5px;
}

/* ============================================================
   Input deshabilitado (solo lectura para agentes)
   ============================================================ */
#chat-window .chat-footer.readonly-mode {
  background: #f8f9fa;
}

#chat-window .chat-footer.readonly-mode #chat-input {
  background: #e9ecef;
  color: #adb5bd;
  cursor: default;
}

#chat-window .chat-footer.readonly-mode .chat-send-btn {
  opacity: 0.4;
  cursor: not-allowed;
}
