/* ZIC Landing — Bouton flottant de messagerie (FAB).
 *
 * Bouton rond fixe en bas a droite qui ouvre le popup chat existant
 * (window.LandingChat.open()). Affiche un badge de non-lus et s'anime a
 * l'arrivee d'un nouveau message (classe .is-attention posee par
 * landing-chat-fab.js). Cache pendant que l'overlay chat est ouvert.
 *
 * z-index : 100 (au-dessus du sticky CTA mobile a 90, sous l'overlay chat a 1200).
 */

.zic-chat-fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 100;
  width: 58px;
  height: 58px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 55%, #5b21b6 100%);
  box-shadow:
    0 10px 28px rgba(91, 33, 182, 0.45),
    0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.zic-chat-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 14px 34px rgba(91, 33, 182, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.22);
}

.zic-chat-fab:active {
  transform: translateY(0) scale(0.96);
}

.zic-chat-fab:focus-visible {
  outline: 3px solid rgba(167, 139, 250, 0.9);
  outline-offset: 3px;
}

/* Icone */
.zic-chat-fab-icon {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zic-chat-fab-icon svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* Anneau de pulsation — visible seulement quand il y a des non-lus. */
.zic-chat-fab-ring {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.zic-chat-fab.has-unread .zic-chat-fab-ring {
  opacity: 1;
  box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.55);
  animation: zic-chat-fab-pulse 2s ease-out infinite;
}

/* Badge compteur de non-lus. */
.zic-chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  z-index: 3;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 700;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(15, 7, 34, 0.65);
  transform-origin: center;
  animation: zic-chat-fab-badge-pop 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.zic-chat-fab-badge[hidden] {
  display: none;
}

/* Animation "attention" one-shot a l'arrivee d'un nouveau message. */
.zic-chat-fab.is-attention {
  animation: zic-chat-fab-attention 0.85s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Masquer le bouton tant que l'overlay chat plein ecran est ouvert. */
body.zh-chat-overlay-open .zic-chat-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Mobile : remonter le bouton au-dessus du sticky CTA home quand il est visible. */
@media (max-width: 768px) {
  .zic-chat-fab {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 54px;
    height: 54px;
  }
  .zic-chat-fab-icon svg {
    width: 26px;
    height: 26px;
  }
}

@supports selector(:has(*)) {
  @media (max-width: 768px) {
    body:has(.zh-sticky-cta.is-visible) .zic-chat-fab {
      bottom: calc(92px + env(safe-area-inset-bottom));
    }
  }
}

@keyframes zic-chat-fab-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.5);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(124, 58, 237, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
  }
}

@keyframes zic-chat-fab-badge-pop {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes zic-chat-fab-attention {
  0%,
  100% {
    transform: rotate(0) scale(1);
  }
  15% {
    transform: rotate(-12deg) scale(1.08);
  }
  30% {
    transform: rotate(10deg) scale(1.08);
  }
  45% {
    transform: rotate(-8deg) scale(1.05);
  }
  60% {
    transform: rotate(6deg) scale(1.03);
  }
  75% {
    transform: rotate(-3deg) scale(1.01);
  }
}

@media (prefers-reduced-motion: reduce) {
  .zic-chat-fab,
  .zic-chat-fab:hover,
  .zic-chat-fab:active {
    transition: none;
    transform: none;
  }
  .zic-chat-fab.has-unread .zic-chat-fab-ring,
  .zic-chat-fab.is-attention,
  .zic-chat-fab-badge {
    animation: none;
  }
}
