/* =============================================
   Asistente SynergIA – Widget flotante Afanion
   Synergy Internet S.L. — synergyweb.es
   ============================================= */

/* ── Botón flotante ─────────────────────────── */
#afanion-widget-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #223A90;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(34,58,144,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  padding: 0;
  outline: none;
}
#afanion-widget-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(34,58,144,.45);
  background: #1a2d72;
}
#afanion-widget-btn:active { transform: scale(.97); }
#afanion-widget-btn-logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  transition: opacity .15s;
}
#afanion-widget-btn-close {
  display: none;
  color: #fff;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
}

/* Estado abierto: mostrar X, ocultar logo */
#afanion-widget-wrap.is-open #afanion-widget-btn-logo  { display: none; }
#afanion-widget-wrap.is-open #afanion-widget-btn-close { display: block; }
#afanion-widget-wrap.is-open #afanion-widget-btn {
  background: #D92A89;
  box-shadow: 0 4px 20px rgba(217,42,137,.35);
}

/* Badge de notificación */
#afanion-widget-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #D92A89;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Panel del chat ─────────────────────────── */
#afanion-widget-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 580px;
  max-height: calc(100dvh - 120px);
  z-index: 99998;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  background: #ffffff;

  /* Animación de entrada */
  transform: scale(.92) translateY(16px);
  opacity: 0;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
  pointer-events: none;
}
#afanion-widget-panel:not([hidden]) {
  pointer-events: auto;
}
#afanion-widget-wrap.is-open #afanion-widget-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* El contenedor del bot ocupa todo el panel — altura fija del CSS del bot sobreescrita */
#afanion-widget-panel #afanion-bot,
#afanion-widget-panel .afanion-bot-wrapper,
#afanion-widget-panel .afanion-bot-container {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: 18px !important;
  overflow: hidden !important;
  box-shadow: none !important;
  background: #ffffff !important;
  display: flex !important;
  flex-direction: column !important;
}

/* FIX zona de mensajes — crece para ocupar espacio disponible */
#afanion-widget-panel #chat-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}

/* FIX zona de opciones — altura limitada, nunca aplasta los mensajes */
#afanion-widget-panel #options-container {
  flex-shrink: 0 !important;
  max-height: 185px !important;
  overflow-y: auto !important;
}

/* FIX logo del header — el JS usa ruta relativa que falla en WP.
   Ocultamos el <img> roto y mostramos el logo vía background. */
#afanion-widget-panel .bot-header-avatar img {
  opacity: 0 !important;
  position: absolute !important;
}
#afanion-widget-panel .bot-header-avatar {
  background-image: url('https://afanion.es/asistente/afanion-logo-icon.png') !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}

/* ── Responsive móvil ───────────────────────── */
@media (max-width: 480px) {
  #afanion-widget-btn { bottom: 16px; right: 16px; }
  #afanion-widget-panel {
    bottom: 88px;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    height: calc(100dvh - 88px);
    max-height: calc(100dvh - 88px);
  }
}
