:root {
  color-scheme: light;
  --miriam1-teal: #4ab4af;
  --miriam1-bg: #ffffff;
  --miriam1-surface: #f9f9f9;
  --miriam1-text: #222;
  --miriam1-muted: #6b7280;
  --miriam1-font: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .15);
}

#chat-bubble {
  position: fixed;
  inset: auto 20px 20px auto;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  background: var(--miriam1-teal);
  box-shadow: 0 0 0 2px white, var(--shadow);
  z-index: 9998;
  cursor: pointer;
  border: none;
  transition: transform .15s ease, box-shadow .15s ease;
  outline: 0;
}

#chat-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .2);
  animation-play-state: paused;
}

#chat-bubble:active {
  transform: translateY(0);
}

#chat-bubble .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: var(--shadow);
}

#chat-bubble[data-unread]:not([data-unread="0"]) .badge {
  display: flex;
}

#chat-window {
  position: fixed;
  right: 20px;
  bottom: 95px;
  width: 420px;
  max-width: 90vw;
  height: 620px;
  max-height: 75vh;
  background: var(--miriam1-bg);
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  z-index: 9999;
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: var(--miriam1-font);
}

@media (max-width: 640px) {
  #chat-window {
    inset: auto 0 0 0;
    width: 100vw;
    height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: none;
    border-radius: 16px 16px 0 0;
  }
}

#chat-header {
  background: var(--miriam1-teal);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#chat-header .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: none;
  /* Quitamos el fondo de color */
  font-weight: 700;
  font-size: 0;
  /* Ocultamos la letra si aún existiera */
  line-height: 32px;
  text-align: center;
  display: block;
}

#chat-header .title {
  font-weight: 700;
  line-height: 1.2;
}

#chat-header .subtitle {
  font-size: 12px;
  opacity: .9;
}

#chat-tools {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

#chat-clear,
#chat-close {
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

#chat-messages {
  flex: 1;
  padding: 14px;
  overflow: auto;
  background: var(--miriam1-surface);
  scroll-behavior: smooth;
}

.msg {
  max-width: 85%;
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn .3s ease-out;
}

.msg p,
.msg ul,
.msg ol {
  margin: 0 0 .5rem 0;
}

.msg p:last-child {
  margin: 0;
}

.msg ul,
.msg ol {
  padding-left: 20px;
}

.msg time {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--miriam1-muted);
}

.msg.user {
  margin-left: auto;
  background: #e9e9eb;
  color: #333;
  border-bottom-right-radius: 6px;
}

.msg.bot {
  margin-right: auto;
  background: var(--miriam1-teal);
  color: #fff;
  border-bottom-left-radius: 6px;
  font-family: var(--miriam1-font);
  font-size: 14px;
  line-height: 1.5;
}

.msg.bot a {
  color: #fff;
  text-decoration: underline;
  font-weight: 600;
}

.msg.bot a:hover {
  text-decoration: none;
}

/* Los títulos (ahora en negrita) un poco más grandes */
.msg.bot strong,
.msg.bot b {
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
}

/* Si aún no funciona, añade también esta más específica */
#chat-messages .msg.bot strong,
#chat-messages .msg.bot b {
  font-size: 16px !important;
  font-weight: 700 !important;
}

.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .6;
  animation: blink 1s infinite;
}

.dot:nth-child(2) {
  animation-delay: .15s;
}

.dot:nth-child(3) {
  animation-delay: .3s;
}

@keyframes blink {

  0%,
  80%,
  100% {
    opacity: .2;
  }

  40% {
    opacity: 1;
  }
}

#chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  background: var(--miriam1-bg);
  border-top: 1px solid #e5e7eb;
}

#chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #cfd4dc;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 42px;
  max-height: 120px;
  font: 14px/1.4 var(--miriam1-font);
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}

#chat-input:focus {
  outline: none;
  border-color: var(--miriam1-teal);
  box-shadow: 0 0 0 .2rem rgba(74, 180, 175, .25);
}

#send-btn {
  height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  background: var(--miriam1-teal);
  transition: filter .15s, transform .1s;
  display: inline-grid;
  place-items: center;
}

#send-btn:hover {
  filter: brightness(1.05);
}

#send-btn:active {
  transform: translateY(1px);
}

#send-btn[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

/* 1. Mantenemos la animación de salto que te gusta */
@keyframes bubble-bounce {

  0%,
  75%,
  100% {
    transform: translateY(0);
  }

  85% {
    transform: translateY(-16px);
  }

  95% {
    transform: translateY(2px);
  }
}

/* 2. Hacemos que la animación sea más rápida y frecuente */
#chat-bubble.is-animating {
  /* Duración de 2.8s (en vez de 4s), empieza tras 2s, y se repite infinitamente */
  animation: bubble-bounce 2.8s ease-in-out 2s infinite;
}

/* [NUEVO] Animación de pulso suave cuando no está en hover */
@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 180, 175, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(74, 180, 175, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(74, 180, 175, 0);
  }
}

#chat-bubble:not(:hover) {
  animation: pulse-glow 2s infinite;
}

#chat-bubble .proactive-message {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  background-color: var(--miriam1-bg);
  color: var(--miriam1-text);
  padding: 10px 15px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px);
  visibility: hidden;
  transition: opacity .3s, transform .3s, visibility .3s;
  z-index: -1;
}

#chat-bubble .proactive-message::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 20px;
  border-width: 6px;
  border-style: solid;
  border-color: var(--miriam1-bg) transparent transparent transparent;
}

#chat-bubble .proactive-message.visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  z-index: 9997;
}

#chat-window * {
  box-sizing: border-box;
}

/* --- INICIO: ESTILOS PARA BOTONES DE RESPUESTA RÁPIDA --- */

.msg.bot .chat-button-container {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.msg.bot .chat-button {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 8px 14px;
  cursor: pointer;
  font-family: var(--miriam1-font);
  font-size: 14px;
  font-weight: 500;
  transition: background-color .2s, opacity .2s;
}

.msg.bot .chat-button:hover {
  background-color: rgba(255, 255, 255, 0.35);
}

.msg.bot .chat-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: rgba(0, 0, 0, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

/* --- INICIO: MEJORAS VISUALES DE LA VENTANA DE CHAT --- */

/* 2. Animación de entrada para la VENTANA (Slide Up + Fade) */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#chat-window[style*="display: flex"] {
  animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 3. Animación de entrada para los mensajes */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- FIN: MEJORAS VISUALES DE LA VENTANA DE CHAT --- */