/* apps-core 0.1.55 — module « toast » : petite fenêtre « E-mail envoyé à … » (ou échec), la même dans toutes les apps.
   Consigne (2026-10-26) : « quand un e-mail est envoyé, il faudrait afficher une petite fenêtre qui dit que cela a été envoyé ».
   Balisage : AppsCore\Toast::render() (zone + messages en attente) ou appsCoreToast.show() (toast.js).
   Place : en haut à droite sur ordinateur (sous un en-tête fixe), en bas au-dessus de la barre de navigation sur téléphone ;
   toast.js déplace la pile pour ne jamais couvrir un bouton principal.
   Couleurs (contraste du texte ≥ 4,5:1, contrôlé par tests/toast.php) : clair par défaut ; sombre avec html[data-theme="dark"],
   body[data-theme="dark"], .dark, .theme-dark, ou le réglage du système quand l'app n'impose pas « light ». Une app dont le thème
   tient ailleurs (autre attribut) pose data-theme="light" / "dark" sur la zone .ac-toasts elle-même.
   Variables facultatives (posées par l'app sur :root) : --ac-toast-top (16px), --ac-toast-bottom (12px), --ac-toast-width (380px), --ac-toast-z (2147483000). */
.ac-toasts {
  --ac-t-bg: #ffffff; --ac-t-fg: #1b2430; --ac-t-muted: #4a5566; --ac-t-line: #c9d1dd; --ac-t-shadow: 0 10px 28px rgba(15, 23, 42, .18);
  --ac-t-ok: #17703a; --ac-t-info: #0b5cad; --ac-t-queued: #8a4b00;
  --ac-t-err-bg: #fff1f0; --ac-t-err-fg: #7a1610; --ac-t-err: #b42318; --ac-t-err-line: #f1b7b1;
  --ac-t-focus: #0b5cad;
  position: fixed; z-index: var(--ac-toast-z, 2147483000);
  top: var(--ac-toast-top, 16px); right: 16px; left: auto; bottom: auto;
  width: min(var(--ac-toast-width, 380px), calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; margin: 0; padding: 0;
  font: 400 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: normal; text-transform: none; text-align: left;
}
.ac-toasts__live { display: flex; flex-direction: column; gap: 8px; }
/* zones role=status / role=alert neutres : une app qui habille ses [role=alert] (fond, bordure, marge) ne les change pas */
.ac-toasts .ac-toasts__live { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; min-height: 0; width: auto; }
.ac-toasts__live:empty { display: none; }
.ac-toast {
  pointer-events: auto; box-sizing: border-box; position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0; padding: 10px 8px 10px 12px; min-height: 44px;
  background: var(--ac-t-bg); color: var(--ac-t-fg);
  border: 1px solid var(--ac-t-line); border-left: 4px solid var(--ac-t-ok); border-radius: 8px;
  box-shadow: var(--ac-t-shadow);
  animation: ac-toast-in .18s ease-out;
}
.ac-toast--info { border-left-color: var(--ac-t-info); }
.ac-toast--queued { border-left-color: var(--ac-t-queued); }
.ac-toast--error { background: var(--ac-t-err-bg); color: var(--ac-t-err-fg); border-color: var(--ac-t-err-line); border-left-color: var(--ac-t-err); }
.ac-toast__icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  background: var(--ac-t-ok); color: var(--ac-t-bg); font: 700 13px/1 system-ui, sans-serif;
}
.ac-toast--info .ac-toast__icon { background: var(--ac-t-info); font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.ac-toast--queued .ac-toast__icon { background: var(--ac-t-queued); font-size: 12px; }
.ac-toast--error .ac-toast__icon { background: var(--ac-t-err); color: var(--ac-t-err-bg); }
.ac-toast__body { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.ac-toast__text { margin: 0; padding: 0; font: inherit; color: inherit; overflow-wrap: anywhere; }
.ac-toast__link { display: inline-block; margin-top: 4px; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ac-toast__close {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; margin: -4px 0 -4px 0; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--ac-t-muted);
  font: 400 22px/1 system-ui, sans-serif; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.ac-toast--error .ac-toast__close { color: var(--ac-t-err-fg); }
.ac-toast { cursor: pointer; } /* un clic sur le message le ferme */
.ac-toast__close:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.ac-toast__close:focus-visible, .ac-toast__link:focus-visible { outline: 2px solid var(--ac-t-focus); outline-offset: 2px; }
.ac-toast.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity .16s ease, transform .16s ease; }
@keyframes ac-toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Thème sombre */
html[data-theme="dark"] .ac-toasts, body[data-theme="dark"] .ac-toasts, html.dark .ac-toasts, body.dark .ac-toasts, .theme-dark .ac-toasts, .ac-toasts[data-theme="dark"] {
  --ac-t-bg: #1d2430; --ac-t-fg: #eef2f7; --ac-t-muted: #c3cbd8; --ac-t-line: #3a4556; --ac-t-shadow: 0 12px 30px rgba(0, 0, 0, .55);
  --ac-t-ok: #5fd08f; --ac-t-info: #8cc1ff; --ac-t-queued: #f2b45a;
  --ac-t-err-bg: #3b1714; --ac-t-err-fg: #ffe1dc; --ac-t-err: #ff8a7d; --ac-t-err-line: #6e2a24;
  --ac-t-focus: #8cc1ff;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.light) body:not([data-theme="light"]):not(.light) .ac-toasts:not([data-theme="light"]) {
    --ac-t-bg: #1d2430; --ac-t-fg: #eef2f7; --ac-t-muted: #c3cbd8; --ac-t-line: #3a4556; --ac-t-shadow: 0 12px 30px rgba(0, 0, 0, .55);
    --ac-t-ok: #5fd08f; --ac-t-info: #8cc1ff; --ac-t-queued: #f2b45a;
    --ac-t-err-bg: #3b1714; --ac-t-err-fg: #ffe1dc; --ac-t-err: #ff8a7d; --ac-t-err-line: #6e2a24;
    --ac-t-focus: #8cc1ff;
  }
}
html[data-theme="light"] .ac-toasts, body[data-theme="light"] .ac-toasts, .ac-toasts[data-theme="light"] {
  --ac-t-bg: #ffffff; --ac-t-fg: #1b2430; --ac-t-muted: #4a5566; --ac-t-line: #c9d1dd; --ac-t-shadow: 0 10px 28px rgba(15, 23, 42, .18);
  --ac-t-ok: #17703a; --ac-t-info: #0b5cad; --ac-t-queued: #8a4b00;
  --ac-t-err-bg: #fff1f0; --ac-t-err-fg: #7a1610; --ac-t-err: #b42318; --ac-t-err-line: #f1b7b1;
  --ac-t-focus: #0b5cad;
}

/* Téléphone : en bas, sur toute la largeur moins les marges, au-dessus de la barre de navigation (toast.js mesure sa hauteur) */
@media (max-width: 640px) {
  .ac-toasts {
    top: auto; left: 12px; right: 12px; width: auto;
    bottom: calc(var(--ac-toast-bottom, 12px) + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
  }
  .ac-toasts__live { flex-direction: column-reverse; }
  @keyframes ac-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  .ac-toast { animation: none; }
  .ac-toast.is-leaving { transition: none; }
}
@media (forced-colors: active) {
  .ac-toast { border: 2px solid CanvasText; forced-color-adjust: auto; }
  .ac-toast__icon { forced-color-adjust: none; background: CanvasText; color: Canvas; }
}
@media print { .ac-toasts { display: none !important; } }
