/* ──────────────── Agente flotante (sustituye topbar) ──────────────── */
:root {
  --topbar-h: 0px;
  --fa-z: 80;
  --fa-accent: #cfff65;
  --fa-purple: #6d16df;
}

body {
  padding-top: 0 !important;
}

.fa-widget {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  /* Lifted off the bottom edge so the trigger button doesn't sit on top
     of the footer's legal row (Cookies / Condiciones / Canal de
     denuncias …) when the user scrolls all the way down. */
  bottom: max(4rem, env(safe-area-inset-bottom));
  z-index: var(--fa-z);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .75rem;
  pointer-events: none;
}

.fa-widget > * {
  pointer-events: auto;
}

/* Panel */
.fa-panel {
  width: min(320px, calc(100vw - 2rem));
  padding: 1rem 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(109, 22, 223, 0.12);
  box-shadow:
    0 18px 48px -24px rgba(46, 16, 101, 0.45),
    0 8px 24px -12px rgba(10, 10, 15, 0.18);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  transform-origin: bottom right;
  animation: fa-panel-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.fa-panel[hidden] {
  display: none;
}

@keyframes fa-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.fa-close {
  position: absolute;
  top: .65rem;
  right: .65rem;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 10, 15, 0.05);
  color: #666;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.fa-close:hover {
  background: rgba(10, 10, 15, 0.1);
  color: #111;
}

.fa-close svg {
  width: 14px;
  height: 14px;
}

.fa-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
  padding-right: 1.5rem;
}

.fa-avatar {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px -8px rgba(109, 22, 223, 0.55);
}

.fa-avatar svg {
  width: 22px;
  height: 22px;
}

.fa-avatar img,
.fa-trigger-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.fa-online {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #16a34a;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.fa-name {
  display: block;
  font-size: .88rem;
  font-weight: 700;
  color: #0a0a0f;
  line-height: 1.2;
}

.fa-status {
  display: block;
  font-size: .72rem;
  font-weight: 500;
  color: #16a34a;
  margin-top: .1rem;
}

/* Offline state: gray dot + muted status text */
.fa-widget.is-offline .fa-online{
  background: #9ca3af;
  box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.2);
}
.fa-widget.is-offline .fa-status{
  color: #6b7280;
}

.fa-msg {
  margin: 0 0 .9rem;
  font-size: .84rem;
  line-height: 1.45;
  color: #444;
}

.fa-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.fa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  width: 100%;
  min-height: 42px;
  padding: .55rem .85rem;
  border-radius: 12px;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.fa-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.fa-btn-wa {
  background: #25d366;
  color: #fff;
  border: 0;
  box-shadow: 0 8px 20px -10px rgba(37, 211, 102, 0.65);
}

.fa-btn-wa:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px rgba(37, 211, 102, 0.75);
  color: #fff;
}

.fa-btn-call {
  background: var(--fa-purple);
  color: #fff;
  border: 0;
  box-shadow: 0 8px 20px -10px rgba(109, 22, 223, 0.55);
}

.fa-btn-call:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px rgba(109, 22, 223, 0.65);
  color: #fff;
}

/* Trigger */
.fa-trigger {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  padding: .45rem .55rem .45rem .45rem;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 14px 36px -18px rgba(46, 16, 101, 0.45),
    0 4px 14px -8px rgba(10, 10, 15, 0.2);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}

.fa-trigger:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 42px -16px rgba(46, 16, 101, 0.5),
    0 6px 18px -8px rgba(10, 10, 15, 0.22);
}

.fa-trigger-avatar {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: transparent;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.fa-trigger-avatar::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(207, 255, 101, 0.45);
  animation: fa-pulse 2.4s ease-in-out infinite;
}

.fa-trigger-avatar svg {
  width: 22px;
  height: 22px;
}

@keyframes fa-pulse {
  0%, 100% {
    opacity: 0.35;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

.fa-trigger-label {
  font-size: .8rem;
  font-weight: 650;
  color: #1a1a1f;
  padding-right: .55rem;
  max-width: 11rem;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
}

/* Con el panel abierto, ocultamos el botón (el mensaje ya está en la tarjeta) */
.fa-widget.is-open .fa-trigger {
  display: none;
}

@media (max-width: 480px) {
  .fa-trigger-label {
    font-size: .74rem;
    max-width: 9.5rem;
    padding-right: .45rem;
  }

  .fa-panel {
    width: min(300px, calc(100vw - 1.5rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .fa-panel {
    animation: none;
  }

  .fa-trigger-avatar::after {
    animation: none;
    opacity: 0.5;
  }
}
