/* Widget vocal Bookivox aux couleurs du site. */

#bookivox-widget-root {
  --vw-gradient: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  --vw-shadow-float: 0 10px 30px rgba(15, 111, 255, .16), 0 2px 6px rgba(16, 24, 40, .08);
  --vw-gutter: 24px;
  font-family: var(--font-sans);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

#bookivox-widget-root.bottom-right { right: var(--vw-gutter); bottom: var(--vw-gutter); }
#bookivox-widget-root.bottom-left  { left:  var(--vw-gutter); bottom: var(--vw-gutter); }

#bookivox-widget-root button { font-family: inherit; }

#bookivox-widget-root button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Bouton flottant. */
#bookivox-widget-root .bookivox-widget-cta {
  gap: 12px;
  padding: 6px 22px 6px 6px;
  background: var(--color-card) !important; /* style en ligne */
  color: var(--color-text);
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.005em;
  box-shadow: var(--vw-shadow-float);
  opacity: 1;
  animation: hvr-voice-in var(--dur-slow) var(--ease-out) both;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

#bookivox-widget-root .bookivox-widget-cta:hover {
  filter: none;
  transform: translateY(-2px);
  border-color: rgba(15, 111, 255, .35);
  box-shadow: 0 14px 36px rgba(15, 111, 255, .22), 0 2px 6px rgba(16, 24, 40, .08);
}

#bookivox-widget-root .bookivox-widget-cta:active { transform: translateY(0) scale(.98); }

#bookivox-widget-root .hvr-voice-disc {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--vw-gradient);
  color: #fff;
  font-style: normal;
  transition: background var(--dur) var(--ease-out);
}

#bookivox-widget-root .hvr-voice-disc::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(15, 111, 255, .45);
  animation: hvr-voice-halo 2.4s var(--ease-out) 1.2s 2;
}

#bookivox-widget-root .hvr-voice-mic { width: 22px; height: 22px; }

#bookivox-widget-root .hvr-voice-bars {
  display: none;
  align-items: center;
  gap: 3px;
  height: 18px;
}

#bookivox-widget-root .hvr-voice-bars i {
  width: 3px;
  height: 100%;
  border-radius: 2px;
  background: currentColor;
  transform-origin: center;
  animation: hvr-voice-eq 1s ease-in-out infinite;
}
#bookivox-widget-root .hvr-voice-bars i:nth-child(2) { animation-delay: -.6s; }
#bookivox-widget-root .hvr-voice-bars i:nth-child(3) { animation-delay: -.3s; }
#bookivox-widget-root .hvr-voice-bars i:nth-child(4) { animation-delay: -.8s; }

#bookivox-widget-root .bookivox-widget-cta.bookivox-state-connecting { animation: none; }
#bookivox-widget-root .bookivox-state-connecting .hvr-voice-disc {
  animation: hvr-voice-pulse 1.4s ease-in-out infinite;
}

#bookivox-widget-root .bookivox-state-connected .hvr-voice-disc { background: var(--color-accent-600); }
#bookivox-widget-root .bookivox-state-connected .hvr-voice-mic  { display: none; }
#bookivox-widget-root .bookivox-state-connected .hvr-voice-bars { display: flex; }
#bookivox-widget-root .bookivox-widget-cta.bookivox-state-connected {
  border-color: rgba(25, 210, 124, .45);
}

#bookivox-widget-root .bookivox-state-failed .hvr-voice-disc { background: var(--color-error); }
#bookivox-widget-root .bookivox-widget-cta.bookivox-state-failed {
  opacity: 1;
  border-color: rgba(229, 72, 77, .4);
}

/* Panneau de conversation. */
#bookivox-widget-root .bookivox-panel {
  width: 384px;
  height: 580px;
  max-height: calc(100vh - 2 * var(--vw-gutter));
  max-height: calc(100dvh - 2 * var(--vw-gutter));
  background: var(--color-card);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px rgba(16, 24, 40, .16), 0 4px 12px rgba(16, 24, 40, .06);
  transform-origin: bottom right;
  animation: hvr-voice-open var(--dur) var(--ease-out);
}

#bookivox-widget-root.bottom-left .bookivox-panel { transform-origin: bottom left; }

#bookivox-widget-root .bookivox-panel-header {
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--color-card);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

#bookivox-widget-root .bookivox-panel-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: url("../img/favicon.b1d3d6b0ca3a.svg") center / cover no-repeat !important;
  box-shadow: none;
}
#bookivox-widget-root .bookivox-panel-avatar svg { display: none; }

#bookivox-widget-root .bookivox-panel-title {
  color: var(--color-text);
  font-size: 1rem;
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
}

#bookivox-widget-root .bookivox-panel-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--color-text-subtle);
}
#bookivox-widget-root .bookivox-panel-close:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

/* Libellé traduit via data-fr. */
#bookivox-widget-root .bookivox-panel-status {
  gap: 8px;
  padding: 9px 16px;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

#bookivox-widget-root .bookivox-panel-status-label { font-size: 0; }
#bookivox-widget-root .bookivox-panel-status-label::after {
  content: attr(data-fr);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
}

#bookivox-widget-root .bookivox-panel-status-dot { background: var(--color-text-subtle); }
#bookivox-widget-root .bookivox-status-connecting .bookivox-panel-status-dot { background: var(--color-warning); }
#bookivox-widget-root .bookivox-status-connected .bookivox-panel-status-dot {
  background: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(25, 210, 124, .2);
}
#bookivox-widget-root .bookivox-panel-status.bookivox-status-failed {
  background: #FDF0F0;
  color: var(--color-error);
}
#bookivox-widget-root .bookivox-status-failed .bookivox-panel-status-dot { background: var(--color-error); }

#bookivox-widget-root .bookivox-panel-status-action {
  color: var(--color-primary);
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 999px;
}
#bookivox-widget-root .bookivox-panel-status-action:hover { background: var(--color-primary-050); }

#bookivox-widget-root .bookivox-mode-switch {
  margin: 12px 16px 0;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}
#bookivox-widget-root .bookivox-mode-tab {
  font-size: 13.5px;
  font-weight: var(--fw-semibold);
  color: var(--color-text-subtle);
  border-radius: 9px;
}
#bookivox-widget-root .bookivox-mode-tab:hover { color: var(--color-text); }
#bookivox-widget-root .bookivox-mode-tab[aria-pressed="true"] {
  background: var(--color-card);
  color: var(--color-primary);
  box-shadow: var(--shadow-xs), 0 0 0 1px var(--color-border);
}

/* Scène d'appel. */
#bookivox-widget-root .bookivox-call-stage {
  gap: 22px;
  background:
    radial-gradient(260px 200px at 50% 38%, var(--color-primary-050), transparent 70%),
    var(--color-card) !important; /* style en ligne */
}

#bookivox-widget-root .bookivox-orb {
  position: relative;
  width: 148px;
  height: 148px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 55%),
    var(--vw-gradient) !important; /* style en ligne */
  box-shadow: 0 20px 44px rgba(15, 111, 255, .22), 0 4px 12px rgba(16, 24, 40, .08);
}

#bookivox-widget-root .bookivox-call-stage-compact .bookivox-orb { width: 112px; height: 112px; }

#bookivox-widget-root .bookivox-orb::before,
#bookivox-widget-root .bookivox-orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
  opacity: 0;
  pointer-events: none;
}

#bookivox-widget-root .bookivox-stage-connected .bookivox-orb {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 55%),
    var(--color-accent-600) !important;
  box-shadow: 0 20px 44px rgba(19, 168, 99, .28), 0 4px 12px rgba(16, 24, 40, .08);
}
#bookivox-widget-root .bookivox-stage-connected .bookivox-orb::before { animation: hvr-voice-wave 2.4s var(--ease-out) infinite; }
#bookivox-widget-root .bookivox-stage-connected .bookivox-orb::after  { animation: hvr-voice-wave 2.4s var(--ease-out) 1.2s infinite; }

#bookivox-widget-root .bookivox-stage-connecting .bookivox-orb { animation: hvr-voice-pulse 1.4s ease-in-out infinite; }

#bookivox-widget-root .bookivox-orb-btn {
  width: 64px;
  height: 64px;
  background: var(--color-card);
  color: var(--color-primary);
  box-shadow: 0 10px 24px rgba(16, 24, 40, .16);
}
#bookivox-widget-root .bookivox-stage-call,
#bookivox-widget-root #bookivox-stage-call { --bookivox-orb-color: var(--color-primary); }
#bookivox-widget-root .bookivox-stage-connected #bookivox-stage-call { color: var(--color-error); }

#bookivox-widget-root .bookivox-stage-caption {
  max-width: 26ch;
  font-size: var(--fs-small);
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
}

/* Fil de discussion et saisie. */
#bookivox-widget-root .bookivox-panel-log {
  gap: 8px;
  padding: 18px 16px;
  background: var(--color-card);
  scrollbar-width: thin;
}

#bookivox-widget-root .bookivox-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
}
#bookivox-widget-root .bookivox-bubble-user {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 6px;
}
#bookivox-widget-root .bookivox-bubble-agent {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 6px;
}
#bookivox-widget-root .bookivox-bubble-agent.bookivox-bubble-error {
  background: #FDF0F0;
  color: var(--color-error);
}

#bookivox-widget-root .bookivox-typing { background: var(--color-bg-alt); }
#bookivox-widget-root .bookivox-typing-dot { background: var(--color-primary); }

#bookivox-widget-root .bookivox-panel-composer {
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
}

#bookivox-widget-root .bookivox-panel-input {
  padding: 11px 16px;
  font-family: inherit;
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-strong);
}
#bookivox-widget-root .bookivox-panel-input::placeholder { color: var(--color-text-subtle); }
#bookivox-widget-root .bookivox-panel-input:focus {
  outline: none;
  background: var(--color-card);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 111, 255, .15);
}

#bookivox-widget-root .bookivox-panel-send {
  width: 42px;
  height: 42px;
  background: var(--color-primary);
}
#bookivox-widget-root .bookivox-panel-send:hover { background: var(--color-primary-600); opacity: 1; }

/* Mobile. */
@media (max-width: 520px) {
  #bookivox-widget-root { --vw-gutter: 16px; }

  #bookivox-widget-root .bookivox-panel {
    width: calc(100vw - 2 * var(--vw-gutter));
    max-width: none;
    height: 600px;
  }

  #bookivox-widget-root .bookivox-widget-cta { padding-right: 18px; }
}

/* Animations. */
@keyframes hvr-voice-in {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hvr-voice-open {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hvr-voice-halo {
  0%   { box-shadow: 0 0 0 0 rgba(15, 111, 255, .45); }
  100% { box-shadow: 0 0 0 14px rgba(15, 111, 255, 0); }
}

@keyframes hvr-voice-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(.94); opacity: .75; }
}

@keyframes hvr-voice-eq {
  0%, 100% { transform: scaleY(.35); }
  50%      { transform: scaleY(1); }
}

@keyframes hvr-voice-wave {
  0%   { transform: scale(1); opacity: .7; }
  100% { transform: scale(1.55); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #bookivox-widget-root *,
  #bookivox-widget-root *::before,
  #bookivox-widget-root *::after {
    animation: none !important;
    transition: none !important;
  }
  #bookivox-widget-root .hvr-voice-bars i { transform: scaleY(.6); }
}
