/* =============================================================
   chatbot.css
   Estilos exclusivos del widget de chatbot.
   Todos los selectores usan el prefijo "cb-" para evitar
   conflictos con Bootstrap y con style.css.
   ============================================================= */


/* ── Botón flotante ─────────────────────────────────────────── */

#cb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #25D366;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .22);
  transition: transform .18s ease, box-shadow .18s ease;
  padding: 0;
  overflow: hidden;
}

#cb-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}

/* Íconos dentro del botón: transición entre WA y X */
#cb-toggle .cb-icon-wa,
#cb-toggle .cb-icon-x {
  position: absolute;
  transition: opacity .18s ease, transform .18s ease;
}

#cb-toggle .cb-icon-x            { opacity: 0; transform: rotate(-45deg) scale(.7); }
#cb-toggle.cb-open .cb-icon-wa   { opacity: 0; transform: rotate(45deg)  scale(.7); }
#cb-toggle.cb-open .cb-icon-x    { opacity: 1; transform: rotate(0deg)   scale(1);  }


/* ── Panel del chat ─────────────────────────────────────────── */

#cb-popup {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 30%;
  max-height: 85%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 36px rgba(0, 0, 0, .20);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  background: #ece5dd;

  /* Estado inicial: oculto */
  transform: translateY(14px) scale(.97);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
}

#cb-popup.cb-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Adaptación a pantallas pequeñas */
@media (max-width: 420px) {
  #cb-popup {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 90px;
  }
}


/* ── Cabecera del chat ──────────────────────────────────────── */

.cb-header {
  background: #075e54;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.cb-header-name   { font-size: 15px; font-weight: 600; line-height: 1.2; }
.cb-header-status { font-size: 12px; opacity: .75; }


/* ── Área de mensajes ───────────────────────────────────────── */

.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scroll-behavior: smooth;
}

.cb-msg {
  max-width: 84%;
  padding: 8px 11px 5px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}

/* Mensaje entrante (bot) */
.cb-msg.in {
  background: #fff;
  align-self: flex-start;
  border-top-left-radius: 2px;
  color: #111;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

/* Mensaje saliente (usuario) */
.cb-msg.out {
  background: #d9fdd3;
  align-self: flex-end;
  border-top-right-radius: 2px;
  color: #111;
}

.cb-msg-time {
  font-size: 10px;
  color: #8a8a8a;
  text-align: right;
  margin-top: 2px;
}

/* Indicador "escribiendo..." */
.cb-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 2px;
}

.cb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: cbBounce 1.1s infinite;
}

.cb-dot:nth-child(2) { animation-delay: .18s; }
.cb-dot:nth-child(3) { animation-delay: .36s; }

@keyframes cbBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-5px); }
}


/* ── Panel de opciones ──────────────────────────────────────── */

.cb-options {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  background: #f0ece5;
  border-top: 1px solid rgba(0, 0, 0, .08);
}

.cb-opt-label {
  font-size: 11px;
  color: #777;
  padding: 0 2px 1px;
}

.cb-opt-btn {
  background: #fff;
  border: 1px solid #e0ddd8;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  color: #222;
  transition: background .12s;
  display: flex;
  align-items: center;
  gap: 9px;
}

.cb-opt-btn:hover { background: #f5f5f5; }

.cb-opt-icon  { font-size: 17px; flex-shrink: 0; }
.cb-opt-meta  { display: flex; flex-direction: column; }
.cb-opt-title { font-size: 13px; }
.cb-opt-sub   { font-size: 11px; color: #777; margin-top: 1px; }


/* ── Botón de WhatsApp ──────────────────────────────────────── */

.cb-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #25D366;
  color: #fff !important;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: background .15s;
  width: 100%;
}

.cb-wa-btn:hover { background: #1ebe5d; }


/* ── Botón "Volver" ─────────────────────────────────────────── */

.cb-back-btn {
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #666;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .12s;
  align-self: flex-start;
}

.cb-back-btn:hover { background: #eaeaea; }


/* ── Tarjeta de agente asignado ─────────────────────────────── */

.cb-agent-card {
  background: #fff;
  border: 1px solid #e0ddd8;
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
}

.cb-agent-name { font-size: 14px; font-weight: 600; color: #222; }
.cb-agent-role { font-size: 12px; color: #666; margin-top: 1px; }

.cb-badge {
  display: inline-block;
  font-size: 11px;
  background: #e6f9ee;
  color: #1a7a3e;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 5px;
}

/* Separador de fecha/hora entre mensajes */
.cb-divider {
  text-align: center;
  font-size: 11px;
  color: #999;
  padding: 2px 0;
}