/* ============================================================
   Widget de chat (asistente virtual) - flotante en todas las páginas
   ============================================================ */

#chatbot-boton {
  position: fixed;
  bottom: 26px;
  right: 26px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 3px solid var(--accent-color-alt, #b3812f);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: transform 0.2s;
}
#chatbot-boton:hover {
  transform: scale(1.06);
}
#chatbot-boton img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}
#chatbot-boton .cerrar-icono {
  display: none;
  font-size: 28px;
  color: var(--accent-color);
}
#chatbot-boton.abierto img,
#chatbot-boton.abierto .chatbot-badge-ia {
  display: none;
}
#chatbot-boton.abierto .cerrar-icono {
  display: block;
}
#chatbot-boton .punto-en-linea {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2ecc71;
  border: 2px solid #fff;
}
#chatbot-boton .chatbot-badge-ia {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: var(--accent-color);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chatbot-boton .chatbot-badge-ia svg {
  width: 15px;
  height: 15px;
}
#chatbot-boton::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid var(--accent-color-alt, #b3812f);
  opacity: 0.6;
  animation: chatbot-anillo 2.4s ease-out infinite;
}
@keyframes chatbot-anillo {
  0% { transform: scale(0.92); opacity: 0.6; }
  70% { transform: scale(1.2); opacity: 0; }
  100% { transform: scale(1.2); opacity: 0; }
}

#chatbot-etiqueta {
  position: fixed;
  bottom: 116px;
  right: 26px;
  background: var(--accent-color);
  color: #fff;
  padding: 9px 18px;
  border-radius: 50px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 9997;
  white-space: nowrap;
  animation: chatbot-etiqueta-flotar 2.6s ease-in-out infinite;
}
@keyframes chatbot-etiqueta-flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
#chatbot-etiqueta.oculta {
  display: none;
}

#chatbot-ventana {
  position: fixed;
  bottom: 120px;
  right: 26px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 510px;
  max-height: calc(100vh - 150px);
  background: var(--surface-color, #fff);
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--default-font, inherit);
}
#chatbot-ventana.abierta {
  display: flex;
}

#chatbot-header {
  background: var(--accent-color);
  color: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
#chatbot-header .chatbot-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent-color);
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
#chatbot-header .chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#chatbot-header .chatbot-avatar .punto-en-linea {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #2ecc71;
  border: 2px solid var(--accent-color);
}
#chatbot-header .chatbot-info {
  flex: 1;
  min-width: 0;
}
#chatbot-header .chatbot-titulo {
  font-weight: 700;
  font-size: 15.5px;
  line-height: 1.2;
}
#chatbot-header .chatbot-subtitulo {
  font-size: 11.5px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}
#chatbot-header .chatbot-subtitulo svg {
  width: 12px;
  height: 12px;
}
#chatbot-header .chatbot-cerrar {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.85;
  padding: 4px;
  flex-shrink: 0;
}
#chatbot-header .chatbot-cerrar:hover {
  opacity: 1;
}

#chatbot-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: color-mix(in srgb, var(--default-color), transparent 97%);
}

.chatbot-fila {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chatbot-fila.usuario {
  flex-direction: row-reverse;
}
.chatbot-fila .chatbot-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-color);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.chatbot-fila .chatbot-avatar-mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.chatbot-fila.usuario .chatbot-avatar-mini {
  background: color-mix(in srgb, var(--default-color), transparent 80%);
  color: var(--default-color);
  font-size: 13px;
}

.chatbot-burbuja-wrap {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}
.chatbot-fila.usuario .chatbot-burbuja-wrap {
  align-items: flex-end;
}

.chatbot-msg {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}
.chatbot-msg.bot {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 90%);
  color: var(--default-color, #222);
  border-bottom-left-radius: 4px;
}
.chatbot-msg.usuario {
  background: var(--accent-color);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chatbot-msg a {
  color: var(--accent-color);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chatbot-msg a:hover {
  text-decoration: underline;
}
.chatbot-msg.usuario a {
  color: #fff;
  text-decoration: underline;
}

/* Hora separada visualmente de la burbuja (no pegada) */
.chatbot-hora {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 8px;
  padding: 0 6px;
}

.chatbot-escribiendo {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 15px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 90%);
  font-size: 12.5px;
  color: color-mix(in srgb, var(--default-color), transparent 30%);
}
.chatbot-escribiendo svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.chatbot-puntos {
  display: flex;
  gap: 3px;
}
.chatbot-puntos span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--default-color), transparent 40%);
  animation: chatbot-rebote 1.2s infinite ease-in-out;
}
.chatbot-puntos span:nth-child(2) { animation-delay: 0.15s; }
.chatbot-puntos span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatbot-rebote {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-3px); opacity: 1; }
}

#chatbot-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid color-mix(in srgb, var(--default-color), transparent 90%);
  flex-shrink: 0;
  background: #fff;
}
#chatbot-input {
  flex: 1;
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 85%);
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}
#chatbot-input:focus {
  border-color: var(--accent-color);
}
#chatbot-enviar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent-color);
  color: #fff;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
#chatbot-enviar:disabled {
  opacity: 0.5;
  cursor: default;
}

#chatbot-pie {
  text-align: center;
  font-size: 10.5px;
  opacity: 0.55;
  padding: 6px 10px 10px;
  background: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#chatbot-pie svg {
  width: 11px;
  height: 11px;
}

/* Celulares: botón más chico, etiqueta compacta (antes ocupaba todo el ancho
   y tapaba el contenido) y ventana casi a pantalla completa. */
@media (max-width: 575.98px) {
  #chatbot-boton {
    width: 64px;
    height: 64px;
    right: 16px;
    bottom: 16px;
    padding: 6px;
  }
  #chatbot-boton .punto-en-linea {
    width: 13px;
    height: 13px;
    top: 2px;
    right: 2px;
  }
  #chatbot-boton .chatbot-badge-ia {
    width: 24px;
    height: 24px;
    bottom: -5px;
    right: -5px;
  }
  #chatbot-boton .chatbot-badge-ia svg {
    width: 12px;
    height: 12px;
  }
  #chatbot-etiqueta {
    left: auto;
    right: 16px;
    width: auto;
    bottom: 90px;
    padding: 7px 14px;
    font-size: 12.5px;
  }
  #chatbot-ventana {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: 92px;
    max-height: calc(100vh - 110px);
    max-height: calc(100dvh - 110px);
  }
}
