:root {
  --chatbot-color-primario: #394975;
  --chatbot-color-primario-hover: #2e3c66;
  --chatbot-color-secundario: #ffffff;
  --chatbot-color-texto-usuario: #ffffff;
  --chatbot-color-texto-bot: #000000;
  --chatbot-color-fondo-bot: #f1f1f1;
  --chatbot-color-etiqueta-toggle: #F19387;
  --chatbot-color-fondo-toggle: #ffffff;
  --chatbot-color-opcion: #70ab9b;
  --chatbot-color-opcion-hover: #52796f;
  --chatbot-color-borde-input: #dddddd;
  --chatbot-color-focus-input: #4f46e5;
  --chatbot-color-focus-shadow: rgba(79, 70, 229, 0.2);
  --chatbot-color-loader: #0073aa;
  --chatbot-color-avatar-bot: #eeeeee;
  --chatbot-color-bot-border: #f1f1f1;
  --chatbot-color-user-border: #394975;
  --chatbot-color-label-text: #F19387;
}
/* Esconde el botón de modo si el backend dice que no se puede togglear */
:root:not([data-can-toggle-engine="1"]) #chatbot-mode-toggle { display:none !important; }


/* ======= GENERAL ======= */
/* Fuente general */
#chatbot-container, 
#chatbot-container * {
    font-family: 'Poppins', sans-serif !important;
    font-size: 14px;
}

#chatbot-toggle {
  bottom: 20px;
  right: 20px;
  background-color: var(--chatbot-color-fondo-toggle);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  z-index: 1000;
}

#chatbot-toggle-wrapper {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  z-index: 1000;
}

#chatbot-label {
    background-color: var(--chatbot-color-fondo-toggle);
    color: var(--chatbot-color-etiqueta-toggle);
    padding: 6px 14px;
    border-radius: 20px 0 0 20px;
    font-size: 13px;
    font-family: 'Poppins', sans-serif;
    margin-right: 8px;
    white-space: nowrap;
  
    /* Centrado interno */
    display: flex;
    align-items: center;
    justify-content: center;
  
    /* Bajarlo un poquito para que se vea más centrado respecto al círculo */
    margin-top: 4px;
  
    /* Altura mínima para que se vea más “pill” */
    min-height: 32px;
  
    /* Animación coqueto */
    animation: chatbotLabelBounce 3.2s ease-in-out infinite;
  }
  
  /* Quitar márgenes del <p> para que no empuje hacia arriba/abajo */
  #chatbot-label p {
    margin: 0;
    font-weight: 600;
  }
  
  

#chatbot-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 450px;
  border-radius: 90px;
  max-height: 600px; /* Altura máxima */
  background-color: var(--chatbot-color-secundario);
  border-radius: 1.5rem 1.5rem 0 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}


/* Responsive para móviles */
@media (max-width: 480px) {
  #chatbot-container {
    width: 95%;
    right: 2.5%;
    bottom: 80px;
    max-height: 90vh;
  }
}

#chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-color-primario), var(--chatbot-color-primario-hover));
  color: var(--chatbot-color-texto-usuario);
  padding: 16px;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  border-radius: 1.5rem 1.5rem 0 0;
  letter-spacing: 0.5px;
}


#chatbot-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px;
  max-height: 350px;
  scroll-behavior: smooth;
}




/* Mensajes */
.chatbot-message {
  margin: 10px 0;
  padding: 12px 16px;
  border-radius: 20px;
  max-width: 80%;
  clear: both;
  position: relative;
  word-wrap: break-word;
  font-size: 14px;
  
}

.chatbot-message.user {
  background-color: var(--chatbot-color-primario);
  color: var(--chatbot-color-texto-usuario);
  margin-left: auto;
  text-align: left;
}

.chatbot-message.user::after {
  content: "";
  position: absolute;
  bottom: 5px;
  right: -5px;
  border-style: solid;
  border-width: 10px 0 10px 10px;
  border-color: transparent transparent transparent var(--chatbot-color-primario);
}

.chatbot-message.bot {
  background-color: var(--chatbot-color-fondo-bot);
  color: var(--chatbot-color-texto-bot);
  margin-right: auto;
  text-align: left;
  line-height: 1.6;
}

.chatbot-message.bot::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: -5px;
  border-style: solid;
  border-width: 10px 10px 10px 0;
  border-color: transparent var(--chatbot-color-fondo-bot) transparent transparent;
}

/* Avatares opcionales */
.chatbot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 10px;
}

/* Input y botón */
#chatbot-input-container {
  display: flex;
  padding: 10px;
  border-top: 1px solid var(--chatbot-color-borde-input);
  background: white;
}

#chatbot-input {
  flex-grow: 1;
  border: 1px solid var(--chatbot-color-borde-input);
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
}

#chatbot-send {
  background-color: var(--chatbot-color-primario);
  color: var(--chatbot-color-texto-usuario);
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  margin-left: 8px;
  cursor: pointer;
  font-weight: bold;
}

#chatbot-send:hover {
  background-color: var(--chatbot-color-primario-hover);
}

/* Opciones */
.chatbot-options {
  margin-top: 10px;
}

.chatbot-option {
  display: inline-block;
  margin: 5px 5px 0 0;
  padding: 8px 14px;
  background-color: var(--chatbot-color-opcion);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.chatbot-option:hover {
  background-color: var(--chatbot-color-opcion-hover);
}

.chatbot-option:active {
  background-color: var(--chatbot-color-opcion);
}

/* Formularios */
.chatbot-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chatbot-form input {
  padding: 0.75rem 1rem;
  border: 1px solid #ccc;
  border-radius: 0.75rem;
  font-size: 1rem;
  width: 100%;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.chatbot-form input:focus {
  border-color: var(--chatbot-color-focus-input);
  box-shadow: 0 0 0 3px var(--chatbot-color-focus-shadow);
  outline: none;
}

#chatbot-send-form {
  background-color: var(--chatbot-color-primario);
  color: var(--chatbot-color-texto-usuario);
  border: none;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.3s;
}


/* Botón sutil, pero coqueto */
.chatbot-form button {
    width: 90%;
  padding: 10px 16px;
  background-color: var(--chatbot-color-primario);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  align-self: flex-start;
}

.chatbot-form button:hover {
  background-color: var(--chatbot-color-primario-hover);
  transform: translateY(-1px);
}

.chatbot-form button:active {
  transform: scale(0.97);
}

/* Loader estilo WhatsApp */
.typing-indicator {
  display: inline-block;
  margin-left: 5px;
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background-color: var(--chatbot-color-loader);
  border-radius: 50%;
  animation: blink 1.4s infinite both;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0% {
    opacity: 0.2;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

/* Animaciones */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}


#chatbot-toggle {
  animation: pulse 2.5s infinite;
  transition: transform 0.3s ease;
}

#chatbot-toggle:hover {
  transform: scale(1.1);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(57, 73, 117, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(57, 73, 117, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(57, 73, 117, 0);
  }
}

.chatbot-message-wrapper {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
    width: 100%;
    gap: 8px; /* Espacio entre avatar y mensaje */
}

.chatbot-message-wrapper.bot {
    flex-direction: row;
    justify-content: flex-start;
}

.chatbot-message-wrapper.user {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #eee;
    object-fit: cover;
    flex-shrink: 0;
}

/* Forzamos que los mensajes ocupen el espacio restante */
.chatbot-message {
    max-width: 80%;
    word-wrap: break-word;
    padding: 10px 15px;
    border-radius: 15px;
    position: relative;
}

/* Bot */
/* .chatbot-message.bot {
    background-color: #f1f1f1;
    color: #000;
    text-align: left;
} */

/* User */
/* .chatbot-message.user {
    background-color: #394975;
    color: #fff;
    text-align: left;
} */

.chatbot-loader {
  width: 24px;
  height: 24px;
  border: 3px solid #ccc;
  border-top: 3px solid var(--chatbot-color-primario);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 5px auto 5px 0;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.chatbot-option {
  transition: transform 0.2s ease, background-color 0.3s;
}

.chatbot-option:hover {
  transform: scale(1.05);
  background-color: #52796f;
}

.chatbot-form, .chatbot-form2 {
  /* opacity: 0;
  transform: translateY(20px); */
  animation: aparecerFormulario 0.5s forwards;
}

@keyframes aparecerFormulario {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}



.chatbot-loader {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #0073aa;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  margin: 10px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}



.chatbot-loader-message {
  padding: 10px;
  display: flex;
  justify-content: start;
  align-items: center;
  gap: 5px;
}

.chatbot-typing-indicator {
  display: flex;
  gap: 4px;
}

.chatbot-typing-indicator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #0073aa;
  border-radius: 50%;
  animation: chatbot-bounce 1.4s infinite ease-in-out both;
}

.chatbot-typing-indicator span:nth-child(1) {
  animation-delay: -0.32s;
}
.chatbot-typing-indicator span:nth-child(2) {
  animation-delay: -0.16s;
}
.chatbot-typing-indicator span:nth-child(3) {
  animation-delay: 0;
}

@keyframes chatbot-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  } 
  40% {
    transform: scale(1);
  }
}
/****************************/

/* ===== CTA GRID (único) ===== */
.chatbot-cta-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin: 12px auto 16px; /* auto horizontal = centrado */
  align-items: stretch;
  max-width: 92%; /* no ocupa todo el ancho del chat */
  box-sizing: border-box;

}


/* ===== CTA BUTTON (único) ===== */
.chatbot-cta-btn{
  /* base */
  box-sizing:border-box;
  appearance:none;
  border:1px solid #e7ecf5;
  background: linear-gradient(180deg,#ffffff 0%,#f8fafc 100%);
  color:#0f172a; /* slate-900 */
  border-radius:14px;
  padding:8px 14px;                /* aire cómodo */
  font:600 13.5px/1.3 "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  letter-spacing:.2px;
  text-align:left;

  /* una sola línea, sin cortes */
  height:auto;
  min-height:40px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;

  /* layout */
  display:inline-flex;
  align-items:center;
  justify-content:flex-start;
  gap:8px;

  /* estética moderna */
  box-shadow:
    0 1px 2px rgba(2,6,23,.06),
    0 6px 18px rgba(2,6,23,.06);
  transition:
    transform .12s ease,
    box-shadow .18s ease,
    border-color .18s ease,
    background-color .18s ease,
    opacity .18s ease;
  cursor:pointer;
}

/* sin pseudo-elemento fantasma */
.chatbot-cta-btn::before{ content:none; }



/* Hover/active/focus (sin tocar transform para no romper la animación) */
.chatbot-cta-btn:hover{ box-shadow:var(--cta-shadow-hover); border-color:#dfe6f2; }
.chatbot-cta-btn:active{ box-shadow:var(--cta-shadow); }
.chatbot-cta-btn:focus-visible{
  outline:none;
  border-color:#2b6fff;
  box-shadow:0 0 0 3px rgba(43,111,255,.2), var(--cta-shadow-hover);
}

/* Estado cargando/disabled */
.chatbot-cta-btn.is-loading,
.chatbot-cta-btn:disabled{
  opacity:.6; cursor:not-allowed; box-shadow:var(--cta-shadow);
}
.chatbot-cta-btn.is-loading::after{
  content:""; position:absolute; inset:0;
  background:linear-gradient(90deg,transparent,rgba(6,19,43,.06),transparent);
  animation:ctaShimmer 1.2s infinite;
}

/* Ripple span (por si lo usas) */
.chatbot-cta-btn .cta-ripple{
  position:absolute; border-radius:999px; pointer-events:none; opacity:.22;
  transform:scale(0); animation:ctaRipple .5s ease-out forwards;
  background:currentColor;
}

/* ===== Keyframes utilitarios ===== */
@keyframes ctaShimmer{
  0%{ transform:translateX(-100%); }
  100%{ transform:translateX(100%); }
}
@keyframes ctaRipple{
  to{ transform:scale(16); opacity:0; }
}

/* ===== Animación SECUENCIAL para QUICK ACTIONS ===== */
/* Ciclo 8s: cada botón vibra ~1.2s y descansa el resto, en secuencia 1→2→3→4 */
#chatbot-quick-actions .chatbot-cta-btn{
  will-change: transform;
  animation: ctaSeqJitter 8s ease-in-out infinite both;
}

/* orden secuencial: ajusta si cambias cantidad/orden */
#chatbot-quick-actions .chatbot-cta-btn:nth-child(1){ animation-delay: 0s; }
#chatbot-quick-actions .chatbot-cta-btn:nth-child(2){ animation-delay: 2s; }
#chatbot-quick-actions .chatbot-cta-btn:nth-child(3){ animation-delay: 4s; }
#chatbot-quick-actions .chatbot-cta-btn:nth-child(4){ animation-delay: 6s; }

/* Keyframes de la secuencia */
@keyframes ctaSeqJitter{
  0%   { transform: translate(0,0) rotate(0); }
  65%  { transform: translate(0,0) rotate(0); }                 /* pausa larga */
  70%  { transform: translate(1.6px,-1.6px) rotate(.7deg); }
  75%  { transform: translate(-1.8px,1.2px) rotate(-.6deg); }
  80%  { transform: translate(1.2px,1.8px) rotate(.5deg); }
  85%  { transform: translate(-1.4px,-1.0px) rotate(-.5deg); }  /* fin del burst */
  100% { transform: translate(0,0) rotate(0); }
}

/* ===== Animación con PAUSAS para RETENCIÓN (Hoy / Semana / Mes) ===== */
#chatbot-retain-actions .chatbot-cta-btn{
  will-change: transform;
  animation: ctaPulseJitter 6.5s ease-in-out infinite both;
}

/* Stagger para que no vibren a la vez (3 botones) */
#chatbot-retain-actions .chatbot-cta-btn:nth-child(1){ animation-delay: 0s; }
#chatbot-retain-actions .chatbot-cta-btn:nth-child(2){ animation-delay: 2s; }
#chatbot-retain-actions .chatbot-cta-btn:nth-child(3){ animation-delay: 4s; }

/* Keyframes con pausa + ráfaga */
@keyframes ctaPulseJitter{
  0%   { transform: translate(0,0) rotate(0); }
  60%  { transform: translate(0,0) rotate(0); } /* pausa */
  65%  { transform: translate(1.6px,-1.6px) rotate(.6deg); }
  72%  { transform: translate(-1.8px,1.2px) rotate(-.6deg); }
  80%  { transform: translate(1.2px,1.8px) rotate(.5deg); }
  90%  { transform: translate(-1.4px,-1.0px) rotate(-.5deg); }
  100% { transform: translate(0,0) rotate(0); }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce){
  #chatbot-quick-actions .chatbot-cta-btn,
  #chatbot-retain-actions .chatbot-cta-btn{
    animation:none !important;
  }
}


/********************/
/* ===== Cards modernos (sin tocar JS) ===== */
.chatbot-card{
  position: relative !important;        /* para el stretched-link */
  border: 1px solid #e6eaf2 !important;
  border-radius: 14px !important;
  padding: 12px !important;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%) !important;
  box-shadow: 0 1px 2px rgba(2,6,23,.06), 0 8px 18px rgba(2,6,23,.06) !important;
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease !important;
  cursor: pointer !important;
}
.chatbot-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(2,6,23,.12), 0 14px 28px rgba(2,6,23,.10) !important;
  border-color: #dbe4f1 !important;
}
.chatbot-card:focus-within{
  outline: none;
  box-shadow:
    0 0 0 3px rgba(43,111,255,.22),
    0 10px 28px rgba(2,6,23,.10) !important;
  border-color: #2b6fff !important;
}

/* Estira el link para cubrir TODO el card (stretched-link) */
.chatbot-card a{
  position: static;           /* clave para que el ::after se posicione al card */
  color: inherit;
  text-decoration: none;
  z-index: 2;                 /* por encima de imagen/texto */
}
.chatbot-card a::after{
  content: "";
  position: absolute;
  inset: 0;                   /* cubre todo el card */
  z-index: 3;
  background: transparent;
}

/* Hint visual de enlace al pasar el mouse (sin subrayar todo el bloque) */
.chatbot-card:hover a{
  text-decoration: underline;
}

/* Imagen responsiva, recorte elegante */
.chatbot-card img{
  display: block;
  width: 100% !important;
  height: 164px;              /* alto uniforme */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px !important;
  margin-bottom: 10px !important;
}

/* Tipografía y cortes finos */
.chatbot-card strong{
  display: block;
  font-weight: 700;
  font-size: 15px !important;
  line-height: 1.25;
  color: #000000;
  margin-bottom: 6px;
}
.chatbot-card p{
  margin: 0 0 8px 0 !important;
  font-size: 13.5px !important;
  line-height: 1.35;
  color: #000000;
}

/* Botón "Leer más" como enlace discreto (ya que todo el card es clickeable) */
.chatbot-card a{
  font-size: 13px !important;
  font-weight: 600;
}

/* Modo oscuro opcional */
@media (prefers-color-scheme: dark){
  .chatbot-card{
    background: linear-gradient(180deg, #ffffff 0%, #ffffff 100%) !important;
    border-color: #ffffff !important;
    box-shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 24px rgba(0,0,0,.25) !important;
  }
  .chatbot-card strong{ color:#000000; }
  .chatbot-card p{ color:#000000; }
  .chatbot-card:hover{ border-color:#ffffff !important; }
  .chatbot-card:focus-within{
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28), 0 10px 28px rgba(0,0,0,.35) !important;
    border-color:#6aa2ff !important;
  }
}


.chatbot-prebeta {
  position: absolute;
  top: 12px;
  left: -20px;
  background: #ff3b30;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 10px 25px;
  transform: rotate(-45deg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}


.chatbot-cta-inline { margin-top: 6px; }
.chatbot-cta-btn {
  transition: transform .08s ease, box-shadow .08s ease;
}
.chatbot-cta-btn:is(:hover,:focus) {
  transform: translateY(-1px);
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  outline: none;
}



/* ===== Cards: variante imagen-izquierda ===== */
.chatbot-cards.media-left{
  display: grid;
  gap: 10px;
}

.chatbot-cards.media-left .chatbot-card{
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  padding: 12px !important;              /* ya lo tienes, refuerzo */
  position: relative !important;         /* para stretched-link */
}

.chatbot-cards.media-left .chatbot-card img{
  flex: 0 0 120px;
  width: 120px !important;
  height: 80px !important;
  object-fit: cover;
  border-radius: 10px !important;
  margin: 0 !important;                  /* quitamos el margin-bottom del layout vertical */
}

.chatbot-cards.media-left .chatbot-card .body{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;                          /* permite ellipsis/clamp */
  flex: 1 1 auto;
}

/* Título (2 líneas máx) */
.chatbot-cards.media-left .chatbot-card .title{
  font-weight: 700;
  font-size: 15px !important;
  line-height: 1.25;
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Fecha/meta */
.chatbot-cards.media-left .chatbot-card .meta{
  font-size: 12px !important;
  color: #000;
  opacity: .7;
  margin: 0;
}

/* Resumen (3 líneas máx) */
.chatbot-cards.media-left .chatbot-card .excerpt{
  font-size: 13.5px !important;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mantener el stretched link que ya definiste */
.chatbot-cards.media-left .chatbot-card a{
  position: static;
  color: inherit;
  text-decoration: none;
  z-index: 2;
}
.chatbot-cards.media-left .chatbot-card a::after{
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: transparent;
}
.chatbot-cards.media-left .chatbot-card:hover a{
  text-decoration: underline;
}

/* Responsive: en móvil apila (se ve mejor) */
@media (max-width: 480px){
  .chatbot-cards.media-left .chatbot-card{
    flex-direction: column;
  }
  .chatbot-cards.media-left .chatbot-card img{
    width: 100% !important;
    height: 164px !important;
  }
}





@keyframes chatbotLabelBounce {
    0%, 60%, 100% {
      transform: translateY(0);
    }
    70% {
      transform: translateY(-4px);
    }
    80% {
      transform: translateY(0);
    }
    90% {
      transform: translateY(-2px);
    }
  }
  
  /* Respeto a usuarios con menos movimiento */
  @media (prefers-reduced-motion: reduce) {
    #chatbot-label {
      animation: none !important;
    }
  }
  



  /* Quick actions en una sola columna, full width */
#chatbot-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--chatbot-color-borde-input);
    background-color: var(--chatbot-color-secundario);
  }
  
  #chatbot-quick-actions .chatbot-cta-btn {
    width: 100%;
    justify-content: space-between;
  }
  


#chatbot-header {
  background: linear-gradient(135deg, var(--chatbot-color-primario), var(--chatbot-color-primario-hover));
  color: var(--chatbot-color-texto-usuario);
  padding: 14px 40px 14px 16px; /* más espacio a la derecha para el botón */
  font-weight: 600;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  border-radius: 1.5rem 1.5rem 0 0;
  letter-spacing: 0.5px;
  text-align: center;       /* texto centrado */
  position: relative;       /* para posicionar el botón dentro */
}

/* El span es solo por semántica, no usamos flex aquí */
.chatbot-header-title {
  display: inline-block;
}

/* Botón de cerrar en la ESQUINA DERECHA */
#chatbot-close {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--chatbot-color-texto-usuario);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 999px;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

#chatbot-close:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-50%) scale(1.05);
}

#chatbot-close:active {
  transform: translateY(-50%) scale(0.95);
  opacity: 0.8;
}



.fade-in {
  animation: chatbot-fade-in 0.3s ease-out forwards;
}

@keyframes chatbot-fade-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.fade-out {
  animation: chatbot-fade-out 0.3s ease-in forwards;
}

@keyframes chatbot-fade-out {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(10px); }
}


/* =========================
   AJUSTES RESPONSIVE MÓVIL
   ========================= */
@media (max-width: 480px) {

  /* Botón flotante + etiqueta más compactos */
  #chatbot-toggle-wrapper {
    bottom: 14px;
    right: 14px;
  }

  #chatbot-toggle {
    width: 44px;
    height: 44px;
  }

  #chatbot-label {
    max-width: 55vw;
    font-size: 12px;
    padding: 4px 10px;
    min-height: 26px;
  }

  /* El contenedor ocupa casi toda la pantalla en móvil */
  #chatbot-container {
    width: 100%;
    right: 0;
    left: 0;
    bottom: 0;
    max-height: 100vh;
    border-radius: 1.2rem 1.2rem 0 0;
  }

  /* Más altura para el área de mensajes en pantallas chicas */
  #chatbot-messages {
    max-height: calc(100vh - 190px); /* header + input + quick actions aprox */
  }

  /* Que los mensajes NO se corten horizontalmente */
  .chatbot-message {
    max-width: 100%;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  /* Y que las preguntas largas de quick actions también puedan hacer salto de línea */
  #chatbot-quick-actions .chatbot-cta-btn {
    white-space: normal;
    height: auto;
  }
}
