/* EnerIA — widget de chat para Webflow
   Todas las clases usan el prefijo .eneria- para no chocar con los estilos del sitio. */

.eneria-widget {
  --eneria-blue: #0a84ff;
  --eneria-blue-dark: #0560c9;
  --eneria-blue-soft: #e8f3ff;
  --eneria-green: #3cb043;
  --eneria-green-dark: #2a9a37;
  --eneria-green-soft: #eaf7eb;
  --eneria-teal: #14a37f;
  --eneria-white: #ffffff;
  --eneria-bg: #f3f7fb;
  --eneria-text: #1b2a3a;
  --eneria-muted: #6b7a8c;
  --eneria-border: #e3eaf2;
  --eneria-error: #d93a3a;
  --eneria-radius: 24px;
  --eneria-shadow: 0 24px 60px rgba(10, 50, 110, 0.22), 0 6px 18px rgba(10, 50, 110, 0.1);

  position: fixed;
  right: 24px;
  /* Encima de la robot flotante del sitio (84 px de alto, a 20 px del borde). */
  bottom: 116px;
  /* Por encima de los botones flotantes del sitio (robot, LinkedIn), sobre todo en celular. */
  z-index: 2147483600;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--eneria-white);
  border-radius: var(--eneria-radius);
  box-shadow: var(--eneria-shadow);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--eneria-text);
  box-sizing: border-box;

  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2), visibility 0s linear 0.3s;
}

.eneria-widget *,
.eneria-widget *::before,
.eneria-widget *::after {
  box-sizing: border-box;
}

.eneria-widget.eneria-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2), visibility 0s;
}

/* ---------- Cabecera ---------- */
.eneria-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 18px;
  overflow: hidden;
  color: var(--eneria-white);
  background: linear-gradient(135deg, var(--eneria-blue) 0%, var(--eneria-blue-dark) 55%, var(--eneria-teal) 125%);
}

/* Luces decorativas detrás del contenido de la cabecera. */
.eneria-header::before,
.eneria-header::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.eneria-header::before {
  width: 180px;
  height: 180px;
  top: -110px;
  right: -40px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
}

.eneria-header::after {
  width: 140px;
  height: 140px;
  bottom: -100px;
  left: 30%;
  background: radial-gradient(circle, rgba(125, 234, 132, 0.28), transparent 70%);
}

.eneria-header > * {
  position: relative;
  z-index: 1;
}

.eneria-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--eneria-white);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3), 0 6px 14px rgba(0, 30, 80, 0.25);
  overflow: hidden;
}

.eneria-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eneria-header-text {
  flex: 1;
  min-width: 0;
}

.eneria-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.eneria-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
}

.eneria-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7dea84;
  box-shadow: 0 0 0 2px rgba(125, 234, 132, 0.35);
}

.eneria-close {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: var(--eneria-white);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.18s ease, transform 0.18s ease;
}

.eneria-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* La flecha baja un poco al pasar el mouse, invitando a minimizar. */
.eneria-close svg {
  transition: transform 0.18s ease;
}

.eneria-close:hover svg {
  transform: translateY(2px);
}

.eneria-close:active {
  transform: scale(0.92);
}

/* ---------- Mensajes ---------- */
.eneria-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--eneria-bg);
  /* Textura sutil de puntos. */
  background-image: radial-gradient(rgba(10, 132, 255, 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #c9d6e4 transparent;
}

.eneria-messages::-webkit-scrollbar {
  width: 6px;
}

.eneria-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #c9d6e4;
}

/* Tarjeta de bienvenida (primer mensaje). */
.eneria-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 2px 4px 6px;
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: linear-gradient(160deg, #ffffff 0%, #f0f8ff 60%, #ecf9ef 100%);
  box-shadow: 0 1px 2px rgba(10, 60, 120, 0.06), 0 8px 20px rgba(10, 60, 120, 0.07);
  text-align: center;
  animation: eneria-pop 0.25s ease-out;
}

.eneria-welcome-avatar {
  width: 64px;
  height: 64px;
  margin-bottom: 2px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(20, 163, 127, 0.25);
}

.eneria-welcome-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eneria-welcome-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.eneria-welcome-text {
  margin: 0;
  color: var(--eneria-muted);
  font-size: 14px;
}

.eneria-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: eneria-pop 0.2s ease-out;
}

.eneria-msg-bot {
  align-self: flex-start;
  background: var(--eneria-white);
  border: 1px solid rgba(227, 234, 242, 0.8);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(10, 60, 120, 0.05), 0 4px 14px rgba(10, 60, 120, 0.06);
}

.eneria-msg-user {
  align-self: flex-end;
  color: var(--eneria-white);
  background: linear-gradient(135deg, var(--eneria-blue), var(--eneria-blue-dark));
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 16px rgba(10, 132, 255, 0.28);
}

.eneria-msg-error {
  align-self: flex-start;
  color: var(--eneria-error);
  background: #fff3f3;
  border: 1px solid #f6cfcf;
  border-bottom-left-radius: 6px;
}

.eneria-msg strong {
  font-weight: 650;
}

.eneria-msg a {
  color: inherit;
  text-decoration: underline;
}

.eneria-msg-bot a {
  color: var(--eneria-blue-dark);
  font-weight: 500;
}

/* Indicador "pensando..." */
.eneria-typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 16px;
}

.eneria-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--eneria-green);
  animation: eneria-bounce 1.2s infinite ease-in-out;
}

.eneria-typing span:nth-child(2) { animation-delay: 0.15s; background: var(--eneria-blue); }
.eneria-typing span:nth-child(3) { animation-delay: 0.3s; }

/* ---------- Campo para escribir ---------- */
.eneria-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 8px;
  background: var(--eneria-white);
}

.eneria-input {
  flex: 1;
  min-height: 46px;
  max-height: 120px;
  padding: 12px 16px;
  resize: none;
  border: 1.5px solid transparent;
  border-radius: 23px;
  background: #f0f5fa;
  color: var(--eneria-text);
  font: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.eneria-input::placeholder {
  color: #8a99aa;
}

.eneria-input:focus,
.eneria-widget .eneria-input:focus-visible {
  border-color: var(--eneria-blue);
  background: var(--eneria-white);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.12);
  outline: none;
}

.eneria-send {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  color: var(--eneria-white);
  background: linear-gradient(135deg, var(--eneria-green), var(--eneria-teal));
  box-shadow: 0 6px 14px rgba(42, 154, 55, 0.32);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.eneria-plane {
  width: 22px;
  height: 22px;
  transition: transform 0.2s ease;
}

/* ---------- Íconos centrados en los botones redondos ---------- */
/* El sitio (Webflow) puede dar relleno, alto de línea o tamaños a botones e íconos:
   aquí se anulan para que el ícono quede siempre en el centro exacto. */
.eneria-widget .eneria-close,
.eneria-widget .eneria-send {
  position: relative;
  margin: 0;
  padding: 0;
  min-width: 0;
  min-height: 0;
  font-size: 0;
  line-height: 0;
  text-indent: 0;
  -webkit-appearance: none;
  appearance: none;
}

.eneria-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.eneria-widget .eneria-icon svg {
  display: block;
  flex: none;
  margin: 0;
  max-width: none;
  max-height: none;
}

.eneria-close .eneria-icon svg {
  width: 20px;
  height: 20px;
}

.eneria-send:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 8px 18px rgba(42, 154, 55, 0.4);
}

/* Al pasar el mouse el avión se inclina, listo para despegar. */
.eneria-send:hover:not(:disabled) .eneria-plane {
  transform: translate(1px, -1px) rotate(-10deg);
}

.eneria-send:active:not(:disabled) {
  transform: scale(0.94);
}

/* Al enviar, el avión sale volando y regresa. */
.eneria-send.eneria-sending .eneria-plane {
  animation: eneria-fly 0.6s ease-in-out;
}

@keyframes eneria-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  45% { transform: translate(18px, -18px) scale(0.6); opacity: 0; }
  55% { transform: translate(-16px, 16px) scale(0.6); opacity: 0; }
  100% { transform: translate(0, 0) scale(1); opacity: 1; }
}

/* Sin texto: gris, para que se note que todavía no se puede enviar. */
.eneria-send:disabled {
  color: #9aabbd;
  background: #e4ebf2;
  box-shadow: none;
  cursor: not-allowed;
}

/* Mientras el avión vuela, el botón sigue verde aunque ya esté desactivado. */
.eneria-send.eneria-sending:disabled {
  color: var(--eneria-white);
  background: linear-gradient(135deg, var(--eneria-green), var(--eneria-teal));
}

.eneria-footer {
  padding: 0 12px 10px;
  background: var(--eneria-white);
  color: #97a4b3;
  font-size: 10.5px;
  text-align: center;
}

.eneria-widget :focus-visible {
  outline: 2px solid var(--eneria-green);
  outline-offset: 2px;
}

/* ---------- Botón "Quiero que me llamen" ---------- */
.eneria-callback-bar {
  display: flex;
  justify-content: center;
  padding: 8px 12px 0;
  background: var(--eneria-white);
  border-top: 1px solid var(--eneria-border);
}

.eneria-callback {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--eneria-green);
  border-radius: 999px;
  background: var(--eneria-green-soft);
  color: #2b7d31;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.eneria-callback:hover {
  background: #d9f1db;
}

/* La barra ya separa el área de mensajes del campo de texto. */
.eneria-callback-bar + .eneria-form {
  border-top: 0;
}

/* ---------- Formulario de contacto (dentro del chat) ---------- */
.eneria-contact {
  width: 100%;
  max-width: 100%;
  white-space: normal;
  border-color: var(--eneria-blue-soft);
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.1);
}

.eneria-contact-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.eneria-contact-title {
  margin: 0 0 2px;
  font-weight: 700;
}

.eneria-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.eneria-field-label {
  font-size: 12.5px;
  color: var(--eneria-muted);
}

.eneria-field-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--eneria-border);
  border-radius: 10px;
  background: var(--eneria-bg);
  color: var(--eneria-text);
  font: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
}

.eneria-field-input:focus {
  border-color: var(--eneria-blue);
  background: var(--eneria-white);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}

/* Campo trampa para bots: fuera de la vista pero presente en el formulario. */
.eneria-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.eneria-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--eneria-muted);
  line-height: 1.4;
}

.eneria-consent input {
  flex: none;
  margin-top: 2px;
  accent-color: var(--eneria-green);
}

.eneria-contact-error {
  margin: 0;
  min-height: 0;
  font-size: 12.5px;
  color: var(--eneria-error);
}

.eneria-contact-error:empty {
  display: none;
}

.eneria-lead-note-text {
  margin: 0 0 10px;
}

.eneria-lead-again {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: #eff6ff;
  color: #1d4ed8;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.eneria-lead-again:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.eneria-turnstile:not(:empty) {
  margin: 4px 0 10px;
  min-height: 65px;
}

.eneria-contact-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.eneria-contact-submit,
.eneria-contact-dismiss {
  padding: 9px 14px;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.eneria-contact-submit {
  flex: 1;
  border: 0;
  color: var(--eneria-white);
  background: linear-gradient(135deg, var(--eneria-green), #2e9a36);
  box-shadow: 0 4px 12px rgba(60, 176, 67, 0.3);
}

.eneria-contact-submit:disabled {
  opacity: 0.6;
  cursor: wait;
}

.eneria-contact-dismiss {
  border: 1px solid var(--eneria-border);
  background: var(--eneria-white);
  color: var(--eneria-muted);
}

/* ---------- Mascota junto a los mensajes de EnerIA ---------- */
.eneria-row-bot {
  align-self: flex-start;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}

.eneria-row-bot .eneria-msg {
  max-width: none;
  min-width: 0;
}

.eneria-msg-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--eneria-white);
  box-shadow: 0 2px 6px rgba(10, 60, 120, 0.12);
}

.eneria-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eneria-avatar svg,
.eneria-msg-avatar svg {
  display: block;
}

/* ---------- Reacciones de la mascota ---------- */
/* Pensando: la mascota de la cabecera se balancea, parpadea y el estado cambia de color. */
.eneria-thinking .eneria-avatar,
.eneria-thinking .eneria-row-bot:last-child .eneria-msg-avatar {
  animation: eneria-think 1.4s ease-in-out infinite;
}

/* Mientras piensa, sus ojos miran de un lado a otro. */
.eneria-thinking .eneria-eyes,
.eneria-thinking .eneria-avatar .eneria-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: eneria-look 1.6s ease-in-out infinite;
}

/* Vida en reposo (solo la mascota de la cabecera): la hojita se mece, parpadea y el rayo destella. */
.eneria-avatar .eneria-leaf {
  transform-box: fill-box;
  transform-origin: 42% 100%;
  animation: eneria-sway 3.2s ease-in-out infinite;
}

.eneria-avatar .eneria-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: eneria-blink-idle 4.6s ease-in-out infinite;
}

.eneria-avatar .eneria-bolt {
  transform-box: fill-box;
  transform-origin: center;
  animation: eneria-twinkle 2.8s ease-in-out infinite;
}

.eneria-avatar.eneria-celebrate .eneria-bolt {
  animation: eneria-spin 0.9s ease-in-out 2;
}

.eneria-avatar.eneria-celebrate .eneria-leaf {
  animation: eneria-sway 0.45s ease-in-out 3;
}

/* En los mensajes la mascota es pequeña: sin el rayo para que se vea limpia. */
.eneria-msg-avatar .eneria-bolt {
  display: none;
}

@keyframes eneria-sway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

@keyframes eneria-blink-idle {
  0%, 90%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(0.1); }
  96% { transform: scaleY(1); }
}

@keyframes eneria-look {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-1.6px); }
  75% { transform: translateX(1.6px); }
}

@keyframes eneria-twinkle {
  0%, 70%, 100% { transform: scale(1); filter: none; }
  80% { transform: scale(1.15); filter: drop-shadow(0 0 2px #ffd25a); }
}

@keyframes eneria-spin {
  from { transform: rotate(0deg) scale(1.1); }
  to { transform: rotate(360deg) scale(1.1); }
}

.eneria-thinking .eneria-status::before {
  background: #ffc83d;
  box-shadow: 0 0 0 2px rgba(255, 200, 61, 0.35);
  animation: eneria-pulse 1s ease-in-out infinite;
}

/* Saludo al abrir el chat. */
.eneria-avatar.eneria-wave {
  animation: eneria-wave 1.2s ease-in-out;
}

/* Festejo al recibir los datos del formulario. */
.eneria-avatar.eneria-celebrate {
  animation: eneria-jump 1.4s ease-in-out;
}

.eneria-confetti {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.eneria-confetti span {
  position: absolute;
  top: -12px;
  width: 7px;
  height: 11px;
  border-radius: 2px;
  animation: eneria-fall 1.5s ease-in forwards;
}

@keyframes eneria-think {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-8deg) translateY(-1px); }
  75% { transform: rotate(8deg) translateY(-1px); }
}


@keyframes eneria-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes eneria-wave {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-14deg); }
  30% { transform: rotate(12deg); }
  45% { transform: rotate(-10deg); }
  60% { transform: rotate(8deg); }
  75% { transform: rotate(-4deg); }
}

@keyframes eneria-jump {
  0%, 100% { transform: translateY(0) scale(1); }
  20% { transform: translateY(-8px) scale(1.12); }
  40% { transform: translateY(0) scale(0.95); }
  60% { transform: translateY(-5px) scale(1.06); }
  80% { transform: translateY(0) scale(1); }
}

@keyframes eneria-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--eneria-drift, 0px), 560px) rotate(600deg); opacity: 0; }
}

/* ---------- Animaciones ---------- */
@keyframes eneria-pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes eneria-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40% { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .eneria-widget,
  .eneria-msg,
  .eneria-typing span,
  .eneria-avatar,
  .eneria-msg-avatar,
  .eneria-eyes,
  .eneria-leaf,
  .eneria-bolt,
  .eneria-plane,
  .eneria-status::before {
    transition: none;
    animation: none !important;
  }

  .eneria-confetti {
    display: none;
  }
}

/* ---------- Móvil: pantalla completa ---------- */
@media (max-width: 480px) {
  .eneria-widget {
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
  }
}
