/* Widget vocal maison — SolAppli.
   Feuille autonome : ne dépend pas de style.css, réutilisable sur un site Ardoise ou sur solappli.com.
   Les couleurs de marque sont posées par assistant-widget.js sur #assistant-solappli
   (--as-primaire, --as-primaire-rgb, --as-accent, --as-accent-texte). */

#assistant-solappli {
  --as-primaire: #0b6e8f;
  --as-primaire-rgb: 11, 110, 143;
  --as-accent: #e2792d;
  --as-accent-texte: #0f2230;
  --as-ambre: #c9a227;
  --as-ambre-sombre: #6f5508;
  --as-rouge: #e11d48;
  --as-texte: #1c2a35;
  --as-doux: #55656f;
  --as-fond: #ffffff;
  --as-bord: #e3e9ee;
  --as-erreur: #9b2c2c;
  --as-erreur-fond: #fdecec;
  --as-ok: #1d6b3a;
  --as-ombre: 0 10px 34px rgba(15, 34, 48, 0.2), 0 2px 6px rgba(15, 34, 48, 0.08);
  --as-police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --as-marge: 8px;
  --as-bas: calc(var(--hauteur-barre, 60px) + env(safe-area-inset-bottom, 0px) + 10px);
  --as-z: 40;

  font-family: var(--as-police);
  font-size: 16px;
  line-height: 1.4;
  color: var(--as-texte);
  -webkit-text-size-adjust: 100%;
}

#assistant-solappli *,
#assistant-solappli *::before,
#assistant-solappli *::after { box-sizing: border-box; }

#assistant-solappli [hidden] { display: none !important; }

#assistant-solappli button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#assistant-solappli button:focus-visible {
  outline: 3px solid var(--as-primaire);
  outline-offset: 3px;
}

#assistant-solappli svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ----- Bulle flottante ----- */
.as-bulle {
  position: fixed;
  right: 16px;
  bottom: var(--as-bas);
  z-index: var(--as-z);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 0;
  padding: 0;
  background: var(--as-accent);
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(15, 34, 48, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}
.as-bulle:hover { transform: translateY(-1px) scale(1.03); }
.as-bulle:active { transform: scale(0.97); }
.as-bulle svg { width: 28px; height: 28px; }
.as-bulle::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--as-accent);
  opacity: 0;
  pointer-events: none;
}
.as-bulle.est-en-appel::before { animation: as-onde 1.6s ease-out infinite; }

/* ----- Panneau ----- */
.as-panneau {
  position: fixed;
  left: var(--as-marge);
  right: var(--as-marge);
  bottom: var(--as-bas);
  z-index: calc(var(--as-z) + 1);
  max-height: calc(100vh - var(--as-bas) - 12px);
  max-height: calc(100dvh - var(--as-bas) - 12px);
  display: flex;
  flex-direction: column;
  background: var(--as-fond);
  border-radius: 20px;
  box-shadow: var(--as-ombre);
  overflow: hidden;
  animation: as-apparition 0.18s ease-out;
}

.as-entete {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 6px 0 12px;
  background: var(--as-primaire);
  color: #ffffff;
}
.as-entete-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}
.as-titre {
  flex: 1 1 auto;
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.01em;
}
.as-replier {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.as-replier:hover { background: rgba(255, 255, 255, 0.14); }
.as-replier:focus-visible { outline-color: #ffffff; }
.as-replier svg { width: 26px; height: 26px; }

.as-corps {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 16px 4px;
}

/* Grand avatar et halo */
.as-scene {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 6px 0 16px;
  flex-shrink: 0;
}
.as-halo {
  position: absolute;
  inset: -22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--as-primaire-rgb), 0.38) 0%, rgba(var(--as-primaire-rgb), 0.14) 45%, rgba(var(--as-primaire-rgb), 0) 72%);
  opacity: 0.55;
  transform: scale(1);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.as-avatar {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #ffffff;
  box-shadow: 0 6px 18px rgba(15, 34, 48, 0.18);
  background: var(--as-bord);
}
#assistant-solappli[data-etat="parole"] .as-halo { animation: as-pulse 1.3s ease-in-out infinite; opacity: 0.95; }
#assistant-solappli[data-etat="ecoute"] .as-halo { opacity: 0.7; }
#assistant-solappli[data-etat="connexion"] .as-halo { opacity: 0.45; }
#assistant-solappli[data-etat="muet"] .as-halo { opacity: 0.35; }
#assistant-solappli[data-etat="termine"] .as-halo,
#assistant-solappli[data-etat="erreur"] .as-halo { opacity: 0.25; }

.as-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--as-primaire);
  background: rgba(var(--as-primaire-rgb), 0.1);
  padding: 3px 11px;
  border-radius: 999px;
}
.as-nom {
  margin: 8px 0 2px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--as-texte);
  overflow-wrap: anywhere;
}

/* Ligne d'état */
.as-etat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 1.5em;
  margin: 0;
  font-size: 0.95rem;
  color: var(--as-doux);
}
.as-etat:empty { visibility: hidden; }
.as-etat::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
#assistant-solappli[data-etat="repos"] .as-etat::before { display: none; }
#assistant-solappli[data-etat="connexion"] .as-etat::before { background: var(--as-doux); animation: as-clignote 1s ease-in-out infinite; }
#assistant-solappli[data-etat="ecoute"] .as-etat::before { background: var(--as-ok); }
#assistant-solappli[data-etat="parole"] .as-etat::before { background: var(--as-primaire); }
#assistant-solappli[data-etat="muet"] .as-etat::before { background: var(--as-ambre); }
#assistant-solappli[data-etat="erreur"] .as-etat::before { background: var(--as-rouge); }

.as-erreur {
  width: 100%;
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--as-erreur);
  background: var(--as-erreur-fond);
  text-align: left;
}

/* Actions */
.as-actions {
  flex: 0 0 auto;
  width: 100%;
  padding: 10px 16px 6px;
}
.as-demarrer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 0.7rem 1.2rem;
  border: 0;
  border-radius: 999px;
  background: var(--as-accent);
  color: var(--as-accent-texte);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  transition: filter 0.15s ease, transform 0.08s ease;
}
.as-demarrer:hover { filter: brightness(1.06); }
.as-demarrer:active { transform: translateY(1px); }
.as-demarrer svg { width: 22px; height: 22px; }
.as-note {
  margin: 10px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--as-doux);
  text-align: center;
}

.as-commandes {
  display: flex;
  justify-content: center;
  gap: 40px;
}
.as-commande {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 2px 4px 4px;
  border: 0;
  background: transparent;
  color: var(--as-texte);
  border-radius: 12px;
}
.as-rond {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
.as-commande:active .as-rond { transform: scale(0.96); }
.as-rond svg { width: 30px; height: 30px; }
.as-micro .as-rond { border-color: var(--as-ambre); background: #ffffff; color: var(--as-ambre-sombre); }
.as-micro:hover .as-rond { background: #fbf4dc; }
.as-micro[aria-pressed="true"] .as-rond { background: var(--as-ambre); color: #1c2a35; }
.as-raccrocher .as-rond { border-color: var(--as-rouge); background: var(--as-rouge); color: #ffffff; }
.as-raccrocher:hover .as-rond { filter: brightness(1.08); }
.as-libelle { font-size: 0.82rem; font-weight: 600; line-height: 1.2; }

.as-pied {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 16px 12px;
  font-size: 0.75rem;
  color: var(--as-doux);
  text-align: center;
}

/* ----- Ordinateur ----- */
@media (min-width: 900px) {
  #assistant-solappli { --as-bas: 16px; }
  .as-bulle { right: 20px; }
  .as-panneau {
    left: auto;
    right: 20px;
    width: 340px;
    max-height: calc(100vh - 32px);
    border-radius: 18px;
  }
}

/* ----- Animations ----- */
@keyframes as-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.14); opacity: 1; }
}
@keyframes as-onde {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.75); opacity: 0; }
}
@keyframes as-clignote {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
@keyframes as-apparition {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .as-panneau, .as-halo, .as-bulle::before, .as-etat::before { animation: none !important; }
  .as-bulle, .as-demarrer, .as-rond { transition: none; }
  .as-bulle.est-en-appel { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 0 7px var(--as-accent); }
}
