/* Retour visuel des actions : confirmations, erreurs, boutons « en cours », pulsations. */

/* ── Notifications ─────────────────────────────────── */
#toasts { position: fixed; right: 20px; bottom: 72px; left: auto; transform: none; width: min(430px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; z-index: 80; pointer-events: none; align-items: stretch; }
#toasts .toast { position: relative; pointer-events: auto; display: flex; align-items: flex-start; gap: 12px; padding: 14px 44px 14px 14px; max-width: none; border-radius: 16px; border: 1px solid var(--line); border-left: 5px solid var(--green);
  background: #fff; color: var(--ink); box-shadow: 0 14px 36px rgba(20, 11, 30, .22); font-size: 14px; font-weight: 400; overflow: hidden; animation: toastIn .22s ease-out; }
#toasts .toast.err { border-left-color: var(--danger-2); background: #fff; }
#toasts .toast.warn { border-left-color: var(--warn, #F5A64B); }
#toasts .toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
.t-ic { flex: none; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(63, 199, 126, .16); color: var(--green-ink); }
.toast.err .t-ic { background: rgba(229, 85, 91, .14); color: var(--danger); }
.toast.warn .t-ic { background: rgba(245, 166, 75, .2); color: var(--amber-ink); }
.t-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.t-title { font-weight: 800; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--green-ink); }
.toast.err .t-title { color: var(--danger); }
.toast.warn .t-title { color: var(--amber-ink); }
.t-msg { font-weight: 600; color: var(--purple); line-height: 1.35; overflow-wrap: anywhere; }
.t-hint { font-size: 13px; color: var(--text2); line-height: 1.4; }
.t-ref { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.t-x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.t-x:hover { background: var(--track); color: var(--purple); }
.t-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--green); transform-origin: left; animation: toastBar linear forwards; opacity: .7; }
.toast.warn .t-bar { background: #F5A64B; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 560px) { #toasts { right: 12px; left: 12px; bottom: 64px; width: auto; } }

/* ── Erreur dans un formulaire ─────────────────────── */
.err.fbox { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: #FCEBEC; border: 1.5px solid rgba(229, 85, 91, .5); color: var(--danger); font-weight: 400; }
.fb-ic { flex: none; margin-top: 1px; display: flex; }
.fb-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 13.5px; line-height: 1.4; color: #7A1E24; }
.fb-body b { font-size: 14px; color: var(--danger); }
.fb-body span { overflow-wrap: anywhere; }
.fb-hint { color: var(--text2); font-size: 13px; }
.fb-ref { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.field-err { font-size: 12.5px; font-weight: 600; color: var(--danger); }
.input[aria-invalid="true"] { border-color: var(--danger-2); box-shadow: 0 0 0 3px rgba(229, 85, 91, .18); }

/* ── Boutons « en cours » ──────────────────────────── */
.btn.is-busy { position: relative; opacity: 1; cursor: progress; color: transparent !important; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after { content: ''; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  border: 2.5px solid rgba(15, 46, 44, .25); border-top-color: var(--on-teal); animation: spin .7s linear infinite; }
.btn:not(.primary):not(.teal):not(.dark).is-busy::after { border-color: rgba(43, 27, 61, .2); border-top-color: var(--purple); }
.btn.dark.is-busy::after { border-color: rgba(255, 255, 255, .3); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pulsation sur l'élément modifié ───────────────── */
.flash-ok { animation: flashOk 1s ease-out; }
.flash-err { animation: flashErr .5s ease-in-out; }
@keyframes flashOk { 0% { box-shadow: 0 0 0 0 rgba(63, 199, 126, .85); } 60% { box-shadow: 0 0 0 9px rgba(63, 199, 126, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 199, 126, 0); } }
@keyframes flashErr { 0%, 100% { transform: translateX(0); box-shadow: 0 0 0 3px rgba(229, 85, 91, .7); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  #toasts .toast, .flash-ok, .flash-err, .btn.is-busy::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .t-bar { animation: none; display: none; }
}

/* ── Indicateur d'enregistrement (coin inférieur droit, fixe) ── */
#saving { position: fixed; right: 20px; bottom: 20px; z-index: 81; display: flex; align-items: center; gap: 9px; padding: 9px 15px 9px 11px; border-radius: 999px; background: var(--purple); color: #fff;
  font-size: 13px; font-weight: 600; box-shadow: 0 8px 22px rgba(20, 11, 30, .28); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s, background .2s; }
#saving.show { opacity: .96; transform: none; }
#saving .sv-ic { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
#saving.busy .sv-ic { border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .28); border-top-color: var(--teal); animation: spin .7s linear infinite; }
#saving.busy .sv-ic > * { display: none; }
#saving.ok { background: var(--green-ink); }
#saving.err { background: var(--danger); }
@media (max-width: 560px) { #saving { right: 12px; bottom: 12px; } }
@media (prefers-reduced-motion: reduce) { #saving { transition: none; } #saving.busy .sv-ic { animation-duration: 1.6s; } }
