/* Ventana de chat. Hereda los colores del tema y cae en valores propios
   si el plugin se usara con otro tema. */

.hei-chat {
  --chat-azul: var(--hei-azul, #223386);
  --chat-rojo: var(--hei-rojo, #e3150f);
  --chat-borde: var(--hei-borde, #dde1e8);
  --chat-acero: var(--hei-acero, #f4f5f7);
  --chat-tinta: var(--hei-tinta, #14171f);
  --chat-gris: var(--hei-gris, #667085);

  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9000;
  font-family: var(--hei-fuente-texto, system-ui, sans-serif);
}

/* ---------- Botón ---------------------------------------------- */

.hei-chat__boton {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--chat-azul);
  color: #fff;
  border: 0;
  padding: 0.85rem 1.2rem;
  font-family: var(--hei-fuente-titulo, inherit);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(20, 23, 31, 0.22);
  /* El mismo chaflán de las fichas de producto. */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.hei-chat__boton:hover {
  background: var(--chat-rojo);
}

.hei-chat[data-abierto="si"] .hei-chat__boton {
  display: none;
}

.hei-chat__boton-icono {
  width: 1.1rem;
  height: 1.1rem;
  background: currentColor;
  /* Bocadillo de conversación, sin iconos externos. */
  clip-path: polygon(0 0, 100% 0, 100% 72%, 42% 72%, 20% 100%, 20% 72%, 0 72%);
  flex: none;
}

/* ---------- Panel ---------------------------------------------- */

.hei-chat__panel {
  width: min(360px, calc(100vw - 2.5rem));
  background: #fff;
  border: 1px solid var(--chat-borde);
  box-shadow: 0 14px 44px rgba(20, 23, 31, 0.26);
  display: flex;
  flex-direction: column;
  max-height: min(560px, calc(100vh - 3rem));
}

.hei-chat__cabecera {
  background: var(--chat-azul);
  color: #fff;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hei-chat__cabecera strong {
  display: block;
  font-family: var(--hei-fuente-titulo, inherit);
  font-size: 1rem;
}

.hei-chat__estado {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 0.15rem;
}

.hei-chat__estado--activo::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.4rem;
  background: #4ade80;
  transform: rotate(45deg); /* rombo, como el semáforo de existencias */
}

.hei-chat__cerrar {
  background: none;
  border: 0;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
}

.hei-chat__cerrar:hover {
  color: var(--chat-rojo);
}

/* ---------- Mensajes -------------------------------------------- */

.hei-chat__mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--chat-acero);
  min-height: 120px;
}

.hei-chat__mensaje {
  max-width: 85%;
  padding: 0.6rem 0.8rem;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hei-chat__mensaje--asistente {
  background: #fff;
  border: 1px solid var(--chat-borde);
  color: var(--chat-tinta);
  align-self: flex-start;
}

.hei-chat__mensaje--visitante {
  background: var(--chat-azul);
  color: #fff;
  align-self: flex-end;
}

/* ---------- Pie -------------------------------------------------- */

.hei-chat__pie {
  border-top: 1px solid var(--chat-borde);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #fff;
}

.hei-chat__whatsapp {
  display: block;
  text-align: center;
  background: #25d366; /* verde de WhatsApp: el usuario lo reconoce */
  color: #0b3d24;
  padding: 0.7rem 1rem;
  font-family: var(--hei-fuente-titulo, inherit);
  font-weight: 700;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-decoration: none;
}

.hei-chat__whatsapp:hover {
  background: #1eb257;
  color: #fff;
  text-decoration: none;
}

.hei-chat__mensajes .hei-chat__whatsapp {
  align-self: flex-start;
  max-width: 85%;
}

.hei-chat__form {
  display: flex;
  gap: 0.5rem;
}

.hei-chat__campo {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--chat-borde);
  padding: 0.6rem 0.7rem;
  font-family: inherit;
  font-size: 0.92rem;
}

.hei-chat__campo:focus {
  border-color: var(--chat-azul);
  outline: 2px solid var(--chat-azul);
  outline-offset: -2px;
}

.hei-chat__enviar {
  border: 0;
  background: var(--chat-rojo);
  color: #fff;
  padding: 0 1rem;
  font-family: var(--hei-fuente-titulo, inherit);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
}

.hei-chat__enviar:hover:not(:disabled) {
  background: var(--chat-azul);
}

.hei-chat__enviar:disabled {
  opacity: 0.55;
  cursor: default;
}

.hei-chat :focus-visible {
  outline: 3px solid var(--chat-rojo);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .hei-chat {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  .hei-chat__boton-texto {
    display: none; /* solo el icono: no tapar el catálogo */
  }

  .hei-chat__boton {
    padding: 0.9rem;
  }
}
