/**
 * Chatbot à questions préfaites — L'Esprit du Combattant.
 *
 * Tout est préfixé « edc-bot » et porté par des variables posées sur le
 * conteneur : le plugin ne dépend d'aucun thème et n'écrase aucune de ses
 * règles.
 */

.edc-bot,
.edc-bot *,
.edc-bot *::before,
.edc-bot *::after {
  box-sizing: border-box;
}

.edc-bot {
  --edc-bot-gold: #d8a83e;
  --edc-bot-gold-light: #f0c55a;
  --edc-bot-gold-dark: #7c5e22;
  --edc-bot-panel: #121417;
  --edc-bot-bubble: #1a1d21;
  --edc-bot-text: #f5f5f2;
  --edc-bot-muted: #9a9a93;
  --edc-bot-line: #26292d;
  --edc-bot-width: 382px;
  --edc-bot-launch: 60px;

  position: fixed;
  bottom: 20px;
  /* Encoche et barre système des téléphones. */
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 99990;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--edc-bot-font-body, inherit);
  font-weight: 400;
  line-height: 1.5;
  color: var(--edc-bot-text);
}

/* ---------- zone renforcee, ne pas retirer ----------
   Sans cette remise a zero, le style « button » du theme traverse et repeint
   les commandes du composant : la croix de fermeture devient bleue, les
   pastilles prennent un fond clair. Elle pese une classe et un element, donc
   moins que les regles du composant, qui en portent deux. */
.edc-bot button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
}

.edc-bot table {
  border-collapse: collapse;
  border-spacing: 0;
  background: none;
  margin: 0;
}

.edc-bot ul,
.edc-bot ol {
  margin: 0;
  padding: 0;
  list-style: none;
}


.edc-bot.edc-bot--right{ right: 20px; align-items: flex-end; }
.edc-bot.edc-bot--left{ left: 20px; align-items: flex-start; }

.edc-bot .edc-bot__sr{
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Bouton flottant ---------- */

.edc-bot .edc-bot__launch{
  position: relative;
  width: var(--edc-bot-launch);
  height: var(--edc-bot-launch);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--edc-bot-gold-light), var(--edc-bot-gold));
  color: #0a0a0a;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
  transition: transform .2s;
}

.edc-bot .edc-bot__launch:hover{ transform: scale(1.06); }
.edc-bot .edc-bot__launch:focus-visible{ outline: 3px solid var(--edc-bot-gold-light); outline-offset: 3px; }

.edc-bot .edc-bot__launch svg{
  display: block;
  width: 45%;
  height: 45%;
}

.edc-bot .edc-bot__badge{
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 2px solid var(--edc-bot-panel);
  background: #d71920;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.edc-bot .edc-bot__badge[hidden]{ display: none !important; }

/* ---------- Panneau ---------- */

.edc-bot .edc-bot__panel{
  width: min(var(--edc-bot-width), calc(100vw - 32px));
  max-height: min(600px, calc(100vh - 140px));
  display: flex;
  flex-direction: column;
  background: var(--edc-bot-panel);
  border: 1px solid var(--edc-bot-gold-dark);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}

/* « display: flex » l'emporte sur la règle navigateur [hidden]{display:none}. */
.edc-bot .edc-bot__panel[hidden]{ display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .edc-bot .edc-bot__panel{ animation: edcBotIn .22s cubic-bezier(.2, .8, .2, 1); }
  @keyframes edcBotIn {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to { opacity: 1; transform: none; }
  }
}

/* ---------- En-tête ---------- */

.edc-bot .edc-bot__head{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, .03);
  border-bottom: 1px solid var(--edc-bot-line);
}

.edc-bot .edc-bot__avatar{
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--edc-bot-gold-dark);
  background: rgba(0, 0, 0, .35);
  color: var(--edc-bot-gold);
  font-family: var(--edc-bot-font-title, inherit);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
}

.edc-bot .edc-bot__id{ flex: 1; min-width: 0; }

.edc-bot .edc-bot__name{
  display: block;
  font-family: var(--edc-bot-font-title, inherit);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  line-height: 1.15;
}

.edc-bot .edc-bot__status{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--edc-bot-muted);
}

.edc-bot .edc-bot__dot{
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #5fbf5b;
}

.edc-bot .edc-bot__close{
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--edc-bot-muted);
  cursor: pointer;
}

.edc-bot .edc-bot__close:hover{ color: var(--edc-bot-text); border-color: var(--edc-bot-line); }
.edc-bot .edc-bot__close:focus-visible{ outline: 2px solid var(--edc-bot-gold); outline-offset: 1px; }
.edc-bot .edc-bot__close svg{ display: block; width: 15px; height: 15px; }

/* ---------- Fil de la conversation ---------- */

.edc-bot .edc-bot__log{
  flex: 1 1 auto;
  min-height: 90px;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--edc-bot-gold-dark) transparent;
}

.edc-bot .edc-bot__log::-webkit-scrollbar{ width: 6px; }
.edc-bot .edc-bot__log::-webkit-scrollbar-thumb{ background: var(--edc-bot-gold-dark); border-radius: 3px; }

.edc-bot .edc-bot__msg{
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 3px;
  font-size: 13.5px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .edc-bot .edc-bot__msg{ animation: edcMsgIn .2s ease-out; }
  @keyframes edcMsgIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
  }
}

.edc-bot .edc-bot__msg--bot{
  align-self: flex-start;
  background: var(--edc-bot-bubble);
  border: 1px solid var(--edc-bot-line);
  border-left: 2px solid var(--edc-bot-gold-dark);
}

.edc-bot .edc-bot__msg--me{
  align-self: flex-end;
  background: linear-gradient(180deg, var(--edc-bot-gold-light), var(--edc-bot-gold));
  color: #0a0a0a;
}

.edc-bot .edc-bot__msg p{ margin: 0; }
.edc-bot .edc-bot__msg p + p{ margin-top: 9px; }
.edc-bot .edc-bot__msg strong{ font-weight: 600; }
.edc-bot .edc-bot__msg a{ color: var(--edc-bot-gold); text-decoration: underline; }
.edc-bot .edc-bot__msg--me a{ color: #0a0a0a; }
.edc-bot .edc-bot__msg ul,
.edc-bot .edc-bot__msg ol{ margin: 9px 0 0; padding-left: 19px; }
.edc-bot .edc-bot__msg li + li{ margin-top: 4px; }

/* Indicateur de frappe */
.edc-bot .edc-bot__typing{
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 13px;
  border: 1px solid var(--edc-bot-line);
  border-radius: 3px;
  background: var(--edc-bot-bubble);
}

.edc-bot .edc-bot__typing span{
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--edc-bot-muted);
}

@media (prefers-reduced-motion: no-preference) {
  .edc-bot .edc-bot__typing span{ animation: edcBlink 1.1s infinite; }
  .edc-bot .edc-bot__typing span:nth-child(2){ animation-delay: .18s; }
  .edc-bot .edc-bot__typing span:nth-child(3){ animation-delay: .36s; }
  @keyframes edcBlink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
}

/* ---------- Pied : les questions proposées ---------- */

.edc-bot .edc-bot__foot{
  flex: 0 0 auto;
  padding: 11px 12px 12px;
  border-top: 1px solid var(--edc-bot-line);
  background: rgba(0, 0, 0, .25);
}

.edc-bot .edc-bot__search{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 10px;
  border: 1px solid var(--edc-bot-line);
  border-radius: 3px;
  background: var(--edc-bot-panel);
}

.edc-bot .edc-bot__search:focus-within{ border-color: var(--edc-bot-gold-dark); }
.edc-bot .edc-bot__search svg{ flex: 0 0 auto; width: 14px; height: 14px; color: var(--edc-bot-muted); }

.edc-bot .edc-bot__search input{
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--edc-bot-text);
  font: inherit;
  font-size: 13px;
}

.edc-bot .edc-bot__search input::placeholder{ color: var(--edc-bot-muted); opacity: .8; }
.edc-bot .edc-bot__search input:focus{ outline: none; }

.edc-bot .edc-bot__hint{
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--edc-bot-muted);
}

.edc-bot .edc-bot__hint:empty{ display: none; }

.edc-bot .edc-bot__choices{
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 184px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--edc-bot-gold-dark) transparent;
}

.edc-bot .edc-bot__choices::-webkit-scrollbar{ width: 6px; }
.edc-bot .edc-bot__choices::-webkit-scrollbar-thumb{ background: var(--edc-bot-gold-dark); border-radius: 3px; }

.edc-bot .edc-bot__chip{
  /* « all: unset » ci-dessus ramene le bouton a « display: inline ». */
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border: 1px solid #2f3337;
  border-radius: 3px;
  background: var(--edc-bot-panel);
  color: var(--edc-bot-text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}

.edc-bot .edc-bot__chip:hover{ border-color: var(--edc-bot-gold); background: var(--edc-bot-bubble); }
.edc-bot .edc-bot__chip:focus-visible{ outline: 2px solid var(--edc-bot-gold); outline-offset: 1px; }

.edc-bot .edc-bot__chip--back{
  border-style: dashed;
  color: var(--edc-bot-muted);
  font-size: 12px;
}

.edc-bot .edc-bot__chip--back:hover{ color: var(--edc-bot-text); }

.edc-bot .edc-bot__empty{
  margin: 0;
  padding: 6px 2px;
  font-size: 12.5px;
  color: var(--edc-bot-muted);
}

.edc-bot .edc-bot__human{
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--edc-bot-line);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--edc-bot-gold);
  text-decoration: none;
}

.edc-bot .edc-bot__human:hover,
.edc-bot .edc-bot__human:focus-visible{ text-decoration: underline; color: var(--edc-bot-gold); }

/* ---------- Téléphone ---------- */

@media (max-width: 520px) {
  .edc-bot {
    right: 12px;
    left: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    align-items: stretch;
  }

  .edc-bot.edc-bot--right,
  .edc-bot.edc-bot--left{ right: 12px; left: 12px; align-items: stretch; }

  .edc-bot .edc-bot__panel{ width: 100%; max-height: calc(100vh - 150px); }
  .edc-bot .edc-bot__launch{ align-self: flex-end; }
  .edc-bot.edc-bot--left .edc-bot__launch{ align-self: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .edc-bot .edc-bot__launch{ transition: none; }
  .edc-bot .edc-bot__launch:hover{ transform: none; }
  .edc-bot .edc-bot__chip{ transition: none; }
}
