/* Huella Asistente: widget de chat */
#ha-asst {
  --ha-teal: #087b91;
  --ha-blue: #0d507d;
  --ha-yellow: #f4bf34;
  --ha-ivory: #f8f5f2;
  --ha-ink: #1f2933;
  --ha-muted: #58636d;
  --ha-line: #e3e8eb;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100001;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ha-ink);
}
#ha-asst *, #ha-asst *::before, #ha-asst *::after { box-sizing: border-box; }
#ha-asst svg { width: 100%; height: 100%; display: block; }
#ha-asst button { font-family: inherit; }

/* Lanzador */
#ha-asst .ha-asst-launcher {
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ha-teal); color: #fff; padding: 16px;
  box-shadow: 0 10px 28px rgba(13, 80, 125, .32);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, background-color .2s ease;
}
#ha-asst .ha-asst-launcher:hover { transform: translateY(-2px); background: var(--ha-blue); }
#ha-asst .ha-asst-launcher:focus-visible { outline: 3px solid var(--ha-yellow); outline-offset: 3px; }
#ha-asst .ha-asst-ico-close { display: none; width: 22px; height: 22px; }
#ha-asst .ha-asst-ico-open { width: 28px; height: 28px; }
#ha-asst.is-open .ha-asst-ico-open { display: none; }
#ha-asst.is-open .ha-asst-ico-close { display: block; }

/* Aviso inicial */
#ha-asst .ha-asst-tip {
  position: absolute; right: 0; bottom: 74px; width: max-content; max-width: 240px;
  background: #fff; color: var(--ha-ink); border-radius: 14px; padding: 10px 34px 10px 14px;
  box-shadow: 0 10px 30px rgba(31, 41, 51, .16); font-weight: 600; cursor: pointer;
  opacity: 0; transform: translateY(6px); pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
#ha-asst .ha-asst-tip::after {
  content: ""; position: absolute; right: 22px; bottom: -6px; width: 12px; height: 12px;
  background: #fff; transform: rotate(45deg);
}
#ha-asst .ha-asst-tip.is-visible { opacity: 1; transform: none; pointer-events: auto; }
#ha-asst .ha-asst-tip-x {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; padding: 3px;
  border: 0; background: transparent; color: var(--ha-muted); cursor: pointer; border-radius: 50%;
}

/* Panel */
#ha-asst .ha-asst-panel {
  position: absolute; right: 0; bottom: 76px; width: 380px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 200px);
  background: #fff; border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(13, 80, 125, .28);
  display: flex; flex-direction: column;
  animation: ha-asst-in .22s ease;
}
#ha-asst .ha-asst-panel[hidden] { display: none; }
@keyframes ha-asst-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

#ha-asst .ha-asst-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px;
  background: linear-gradient(135deg, var(--ha-blue), var(--ha-teal)); color: #fff;
}
#ha-asst .ha-asst-avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%; padding: 9px;
  background: var(--ha-yellow); color: var(--ha-blue);
}
#ha-asst .ha-asst-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
#ha-asst .ha-asst-title strong { font-size: 16px; line-height: 1.2; }
#ha-asst .ha-asst-title small { font-size: 12.5px; opacity: .85; line-height: 1.3; }
#ha-asst .ha-asst-close {
  width: 34px; height: 34px; padding: 8px; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff;
}
#ha-asst .ha-asst-close:hover { background: rgba(255, 255, 255, .26); }

#ha-asst .ha-asst-log {
  flex: 1; overflow-y: auto; padding: 16px; background: var(--ha-ivory);
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
#ha-asst .ha-asst-msg { display: flex; flex-direction: column; max-width: 88%; }
#ha-asst .ha-asst-user { align-self: flex-end; align-items: flex-end; }
#ha-asst .ha-asst-bot { align-self: flex-start; }
#ha-asst .ha-asst-bubble {
  padding: 10px 14px; border-radius: 16px; word-wrap: break-word;
}
#ha-asst .ha-asst-bot .ha-asst-bubble {
  background: #fff; border: 1px solid var(--ha-line); border-bottom-left-radius: 6px;
}
#ha-asst .ha-asst-user .ha-asst-bubble {
  background: var(--ha-teal); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap;
}
#ha-asst .ha-asst-bubble p { margin: 0 0 6px; }
#ha-asst .ha-asst-bubble p:last-child { margin-bottom: 0; }
#ha-asst .ha-asst-bubble ul { margin: 4px 0 6px; padding-left: 18px; }
#ha-asst .ha-asst-bubble li { margin: 2px 0; }

#ha-asst .ha-asst-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#ha-asst .ha-asst-link {
  display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--ha-teal); color: var(--ha-teal); background: #fff;
  font-size: 13.5px; font-weight: 600; text-decoration: none; transition: background-color .15s ease, color .15s ease;
}
#ha-asst .ha-asst-link:hover { background: var(--ha-teal); color: #fff; }
#ha-asst .ha-asst-link.is-primary { background: var(--ha-yellow); border-color: var(--ha-yellow); color: var(--ha-blue); }
#ha-asst .ha-asst-link.is-primary:hover { background: #e7ad19; border-color: #e7ad19; }

#ha-asst .ha-asst-fb { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 12.5px; color: var(--ha-muted); }
#ha-asst .ha-asst-vote {
  width: 26px; height: 26px; padding: 6px; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--ha-muted);
}
#ha-asst .ha-asst-vote:hover { background: #fff; color: var(--ha-teal); }

#ha-asst .ha-asst-typing { display: inline-flex; gap: 4px; padding: 14px; }
#ha-asst .ha-asst-typing i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ha-teal); opacity: .35;
  animation: ha-asst-dot 1s infinite ease-in-out;
}
#ha-asst .ha-asst-typing i:nth-child(2) { animation-delay: .15s; }
#ha-asst .ha-asst-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ha-asst-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

#ha-asst .ha-asst-chips {
  display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto; background: var(--ha-ivory);
  border-top: 1px solid var(--ha-line); scrollbar-width: thin;
}
#ha-asst .ha-asst-chips[hidden] { display: none; }
#ha-asst .ha-asst-chip {
  flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--ha-line);
  background: #fff; color: var(--ha-blue); font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#ha-asst .ha-asst-chip:hover { border-color: var(--ha-teal); color: var(--ha-teal); }

#ha-asst .ha-asst-form {
  display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px 8px; border-top: 1px solid var(--ha-line); background: #fff;
}
#ha-asst .ha-asst-input {
  flex: 1; resize: none; border: 1px solid var(--ha-line); border-radius: 14px; padding: 10px 12px;
  font: inherit; color: var(--ha-ink); background: var(--ha-ivory); min-height: 44px; max-height: 120px; line-height: 1.4;
}
#ha-asst .ha-asst-input:focus { outline: 0; border-color: var(--ha-teal); background: #fff; box-shadow: 0 0 0 3px rgba(8, 123, 145, .15); }
#ha-asst .ha-asst-send {
  width: 44px; height: 44px; flex: 0 0 44px; border: 0; border-radius: 50%; padding: 11px; cursor: pointer;
  background: var(--ha-yellow); color: var(--ha-blue); transition: transform .15s ease, opacity .15s ease;
}
#ha-asst .ha-asst-send:hover { transform: scale(1.05); }
#ha-asst .ha-asst-send:disabled { opacity: .5; cursor: progress; transform: none; }
#ha-asst .ha-asst-foot { margin: 0; padding: 0 14px 10px; background: #fff; font-size: 11.5px; color: var(--ha-muted); line-height: 1.4; }
#ha-asst .ha-asst-foot a { color: var(--ha-teal); font-weight: 600; }
#ha-asst .ha-asst-test { color: #b42318; }

/* Boton "volver arriba" de Avada: lo corremos para que no choque con el lanzador */
.fusion-top-top-link, #toTop { right: 96px !important; }

@media (max-width: 600px) {
  #ha-asst { right: 16px; bottom: 16px; }
  #ha-asst .ha-asst-panel {
    position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0;
  }
  #ha-asst.is-open .ha-asst-launcher { display: none; }
  #ha-asst .ha-asst-tip { bottom: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  #ha-asst * { animation: none !important; transition: none !important; }
}
