/* ============================================================
   MASCOTA.CSS — Widget flotante de Monji + chat integrado
   Todo en un solo widget: ya NO existe un botón de chat aparte.
   El propio Monji es el botón; su "globo" ahora es el panel
   completo del chat (fondo blanco, crece hacia arriba desde
   su cabeza).
   ============================================================ */

#monji-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  width: 110px;
  height: 150px;
  font-family: Arial, sans-serif;
}

/* --- Halo difuminado detrás de Monji --- */
#monji-widget::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8%;
  width: 92%;
  height: 78%;
  transform: translateX(-50%);
  background: radial-gradient(
    circle,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.32) 45%,
    rgba(0, 0, 0, 0) 75%
  );
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}

/* --- Botón con la figura completa de Monji --- */
.monji-boton {
  position: relative;
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: grab;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform 0.2s ease, filter 0.2s ease;
  filter:
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.85))
    drop-shadow(0 6px 14px rgba(139, 0, 0, 0.6));
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.monji-boton:hover {
  transform: scale(1.06);
  filter:
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.85))
    drop-shadow(0 8px 18px rgba(139, 0, 0, 0.8));
}

.monji-boton:active {
  cursor: grabbing;
  transform: scale(0.97);
}

.monji-boton img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom;
  -webkit-user-drag: none;
  position: relative;
  z-index: 1;
}

.monji-boton::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 58%;
  height: 12px;
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0) 72%
  );
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
}

@keyframes monji-flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.monji-boton {
  animation: monji-flotar 3s ease-in-out infinite;
}

.monji-arrastrando .monji-boton {
  animation: none;
  transition: none;
  cursor: grabbing;
}

.monji-arrastrando .monji-chat {
  transition: none;
}

/* ============================================================
   PANEL DE CHAT — antes era un globo de texto simple, ahora es
   el chat completo. Sigue siendo position: absolute a propósito
   (no afecta el tamaño de #monji-widget usado para el arrastre).

   bottom: calc(100% + ...) + altura automática = crece HACIA
   ARRIBA a medida que se agregan mensajes/opciones, con el
   "pico" del globo siempre pegado a la cabeza de Monji.
   ============================================================ */
.monji-chat {
  position: absolute;
  bottom: calc(100% + 14px);
  right: -10px;
  width: 300px;
  max-width: min(86vw, 300px);
  max-height: 70vh;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.monji-chat.monji-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Pico del globo, ahora blanco (apunta hacia Monji) */
.monji-chat::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 34px;
  border-width: 8px 8px 0 8px;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,0.12));
}

/* Encabezado pequeño dentro del panel blanco */
.monji-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.monji-chat-header .monji-chat-titulo {
  font-weight: 700;
  font-size: 14px;
  color: #111;
  display: flex;
  align-items: center;
  gap: 6px;
}
.monji-chat-header .monji-chat-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid #c81e1e;
}
.monji-chat-header .monji-chat-titulo .dot {
  width: 7px; height: 7px; border-radius: 50%; background: #2ecc71; display: inline-block;
}
.monji-chat-header .monji-chat-cerrar {
  background: none;
  border: none;
  color: #999;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.monji-chat-header .monji-chat-cerrar:hover { color: #333; }

/* Mensajes: crecen hacia arriba porque el panel está anclado por
   "bottom", así que el contenido nuevo empuja el panel hacia arriba
   en vez de desbordarse hacia abajo. */
.monji-chat-mensajes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 4px;
  overflow-y: auto;
}
.monji-chat-mensajes::-webkit-scrollbar { width: 5px; }
.monji-chat-mensajes::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.monji-fila { display: flex; }
.monji-fila.bot { justify-content: flex-start; }
.monji-fila.user { justify-content: flex-end; }

.monji-burbuja {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.42;
  animation: monji-burbuja-in 0.16s ease;
}
@keyframes monji-burbuja-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.monji-fila.bot .monji-burbuja {
  background: #f1f1f3;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

/* Enlaces dentro de una respuesta del bot (ej. mailto de envíos):
   se pintan en el rojo de marca en vez del azul por defecto del
   navegador, para que combinen con el resto del widget. */
.monji-fila.bot .monji-burbuja a {
  color: #b0192a;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.monji-fila.bot .monji-burbuja a:hover {
  color: #c81e1e;
}
.monji-fila.user .monji-burbuja {
  background: #c81e1e;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Indicador "escribiendo..." sobre fondo blanco */
.monji-typing {
  display: flex;
  gap: 4px;
  padding: 10px 13px;
  background: #f1f1f3;
  border-radius: 13px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.monji-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #b0192a;
  animation: monji-typing-bounce 1.1s infinite;
}
.monji-typing span:nth-child(2) { animation-delay: .15s; }
.monji-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes monji-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Opciones (preguntas frecuentes) */
.monji-chat-opciones {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px 14px;
  flex-shrink: 0;
}
.monji-opcion-btn {
  background: #fff;
  border: 1.5px solid #c81e1e;
  color: #b0192a;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.monji-opcion-btn:hover { background: #c81e1e; color: #fff; }
.monji-opcion-btn:active { transform: scale(0.98); }

/* --- Responsive --- */
@media (max-width: 480px) {
  #monji-widget {
    bottom: 14px;
    right: 14px;
    width: 84px;
    height: 114px;
  }

  .monji-chat {
    width: 78vw;
    right: -6px;
  }
}