/* ============================================================================================================
 * MetaDex — Socle UI commun (chargé dans <head> par includes/header.php).  § refonte responsive 2026-11-27
 * Les couleurs / rayons / ombres de base restent dans includes/header.php (:root + [data-theme=dark]).
 * Ce fichier ajoute : tokens de mise en page, notifications (Toast), confirmation, focus, mouvement réduit,
 * barre du haut mobile. Les adaptations de contenu (tableaux, formulaires, modales) sont dans
 * src/css/mdx-responsive.css, chargé EN FIN DE PAGE pour passer après les styles propres à chaque page.
 *
 * Points de rupture (mobile-first, déterminés par le contenu) :
 *   ≤ 575  téléphone      ≤ 767  grand téléphone / petite tablette
 *   ≤ 991  tablette : menu latéral en tiroir      ≥ 992  ordinateur : menu latéral fixe
 * ========================================================================================================== */
:root {
    --mdx-tap: 44px;                 /* cible tactile visée (WCAG 2.5.5 / 2.5.8) */
    --mdx-gutter: 1rem;
    --mdx-topbar-h: 60px;
    --mdx-safe-top: env(safe-area-inset-top, 0px);
    --mdx-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mdx-z-sidebar: 1050;
    --mdx-z-overlay: 1049;
    --mdx-z-topbar: 1030;
    --mdx-z-toast: 2000;             /* au-dessus des modales Bootstrap (1055) */
    --mdx-focus: 0 0 0 3px rgba(37, 99, 235, .45);
    --mdx-ok: #15803d;   --mdx-ok-bg: #f0fdf4;   --mdx-ok-bd: #86efac;
    --mdx-err: #b91c1c;  --mdx-err-bg: #fef2f2;  --mdx-err-bd: #fca5a5;
    --mdx-warn: #a16207; --mdx-warn-bg: #fffbeb; --mdx-warn-bd: #fcd34d;
    --mdx-info: #1d4ed8; --mdx-info-bg: #eff6ff; --mdx-info-bd: #93c5fd;
}
[data-theme="dark"] {
    --mdx-ok: #86efac;   --mdx-ok-bg: #052e16;   --mdx-ok-bd: #166534;
    --mdx-err: #fca5a5;  --mdx-err-bg: #2a0a0a;  --mdx-err-bd: #991b1b;
    --mdx-warn: #fcd34d; --mdx-warn-bg: #261a02; --mdx-warn-bd: #854d0e;
    --mdx-info: #93c5fd; --mdx-info-bg: #0b1a33; --mdx-info-bd: #1e40af;
}

/* ── Focus visible partout (clavier) ───────────────────────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }

/* ── Lien d'évitement ─────────────────────────────────────────────────────────────────────────────────── */
.mdx-skip { position: absolute; left: -9999px; top: 8px; z-index: 3000; background: var(--accent, #2563eb); color: #fff;
    padding: .6rem 1rem; border-radius: 8px; font-weight: 600; text-decoration: none; }
.mdx-skip:focus { left: 8px; }

/* ── Notifications (Toast) — design 2026-11-28 ────────────────────────────────────────────────────────────
   Carte claire teintée selon le niveau, icône dans une pastille de couleur, titre + message, bouton fermer,
   barre de temps restant en bas (se met en pause au survol / au focus). Entrée par la droite (ordinateur),
   par le haut (téléphone). */
.mdx-toasts {
    position: fixed; z-index: var(--mdx-z-toast);
    top: calc(18px + var(--mdx-safe-top)); right: 18px;
    width: min(400px, calc(100vw - 36px));
    display: flex; flex-direction: column; gap: 12px;
    pointer-events: none;
}
.mdx-toast {
    --tc: var(--mdx-info); --tbg: var(--mdx-info-bg);
    position: relative; overflow: hidden; pointer-events: auto;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: .85rem;
    padding: .9rem .6rem 1.05rem .9rem;
    background: linear-gradient(100deg, color-mix(in srgb, var(--tbg) 85%, transparent) 0%, var(--bg-card, #fff) 55%);
    background-color: var(--bg-card, #fff);
    color: var(--text, #0f172a);
    border: 1px solid color-mix(in srgb, var(--tc) 22%, var(--border, #e5e7eb));
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 32px -8px rgba(15, 23, 42, .22);
    font-size: .875rem; line-height: 1.45;
    animation: mdxToastIn .32s cubic-bezier(.16, 1, .3, 1);
}
.mdx-toast.is-leaving { animation: mdxToastOut .22s ease forwards; }
.mdx-toast-icon {
    width: 38px; height: 38px; border-radius: 11px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--tc); color: #fff; font-size: 1.05rem;
    box-shadow: 0 6px 14px -6px var(--tc);
}
.mdx-toast-body { padding-top: .05rem; min-width: 0; }
.mdx-toast-title { font-weight: 700; font-size: .9rem; color: var(--text, #0f172a); letter-spacing: .005em; }
.mdx-toast-count {
    display: inline-block; margin-left: .35rem; padding: 0 .4rem; border-radius: 999px;
    font-size: .7rem; font-weight: 700; line-height: 1.5; vertical-align: 1px;
    background: var(--tc); color: #fff;
}
.mdx-toast-count[hidden] { display: none; }
.mdx-toast-msg { margin-top: .15rem; overflow-wrap: anywhere; color: var(--text-muted, #475569); }
.mdx-toast-msg b, .mdx-toast-msg strong { color: var(--text, #0f172a); }
.mdx-toast-close {
    width: 32px; height: 32px; min-width: 32px; margin: -.2rem 0 0 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: var(--text-muted, #64748b); border-radius: 9px; cursor: pointer;
    transition: background .15s, color .15s;
}
.mdx-toast-close:hover { background: color-mix(in srgb, var(--tc) 12%, transparent); color: var(--text, #0f172a); }
.mdx-toast-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--tc) 14%, transparent); }
.mdx-toast-bar > i {
    display: block; height: 100%; background: var(--tc); transform-origin: left center;
    animation: mdxToastBar var(--mdx-dur, 5s) linear forwards;
}
.mdx-toast.is-paused .mdx-toast-bar > i { animation-play-state: paused; }
.mdx-toast.is-persistent .mdx-toast-bar { display: none; }
.mdx-toast-success { --tc: var(--mdx-ok);   --tbg: var(--mdx-ok-bg); }
.mdx-toast-error   { --tc: var(--mdx-err);  --tbg: var(--mdx-err-bg); }
.mdx-toast-warning { --tc: var(--mdx-warn); --tbg: var(--mdx-warn-bg); }
.mdx-toast-info    { --tc: var(--mdx-info); --tbg: var(--mdx-info-bg); }
/* Thème sombre : pastille et barre dans la couleur claire du niveau, icône sombre pour le contraste */
[data-theme="dark"] .mdx-toast-icon, [data-theme="dark"] .mdx-toast-count { color: #0b1220; }
[data-theme="dark"] .mdx-toast { box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 36px -8px rgba(0, 0, 0, .6); }
@keyframes mdxToastIn  { from { opacity: 0; transform: translateX(24px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mdxToastOut { to { opacity: 0; transform: translateX(24px) scale(.97); } }
@keyframes mdxToastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 575px) {
    .mdx-toasts { left: 10px; right: 10px; width: auto; top: calc(10px + var(--mdx-safe-top)); }
    .mdx-toast { animation-name: mdxToastInTop; }
    .mdx-toast.is-leaving { animation-name: mdxToastOutTop; }
    .mdx-toast-close { width: 40px; height: 40px; min-width: 40px; margin: -.4rem -.2rem 0 0; }
    @keyframes mdxToastInTop  { from { opacity: 0; transform: translateY(-16px) scale(.98); } to { opacity: 1; transform: none; } }
    @keyframes mdxToastOutTop { to { opacity: 0; transform: translateY(-12px) scale(.97); } }
}
@media (prefers-reduced-motion: reduce) { .mdx-toast-bar { display: none; } }

/* ── Confirmation commune ─────────────────────────────────────────────────────────────────────────────── */
.mdx-confirm .modal-body { overflow-wrap: anywhere; }
.mdx-confirm .btn-go.mdx-danger { background: var(--red, #dc2626); border-color: var(--red, #dc2626); }
.mdx-confirm .modal-footer { gap: .5rem; }
@media (max-width: 575px) {
    .mdx-confirm .modal-footer { flex-direction: column-reverse; align-items: stretch; }
    .mdx-confirm .modal-footer > * { width: 100%; min-height: var(--mdx-tap); margin: 0; justify-content: center; text-align: center; }
}

/* ── Bouton menu (tiroir) de la barre du haut : visible seulement quand le menu latéral est replié ───── */
.mdx-menu-btn, .mdx-search-btn {
    display: none; align-items: center; justify-content: center;
    width: var(--mdx-tap); height: var(--mdx-tap); min-width: var(--mdx-tap);
    border: 1px solid var(--border, #e5e7eb); background: var(--bg-card, #fff); color: var(--text, #0f172a);
    border-radius: 10px; font-size: 1.1rem; cursor: pointer;
}
.mdx-menu-btn:hover, .mdx-search-btn:hover { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }

/* ── Mouvement réduit ─────────────────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ── Application installable (src/js/mdx-pwa.js) ──────────────────────────────────────────────────────── */
.mdx-install-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: var(--mdx-tap); height: var(--mdx-tap); min-width: var(--mdx-tap);
    border: 1px solid var(--border, #e5e7eb); background: var(--bg-card, #fff); color: var(--accent, #2563eb);
    border-radius: 10px; font-size: 1.05rem; cursor: pointer;
}
.mdx-install-btn:hover { border-color: var(--accent, #2563eb); background: var(--accent-dim, #eff6ff); }
.mdx-install-btn[hidden] { display: none !important; }
.mdx-pwa-dlg { position: fixed; inset: 0; z-index: calc(var(--mdx-z-toast) + 1); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.mdx-pwa-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); opacity: 0; transition: opacity .2s ease; }
.mdx-pwa-sheet {
    position: relative; width: min(440px, 100%); background: var(--bg-card, #fff); color: var(--text, #0f172a);
    border-radius: 18px; padding: 1.4rem; box-shadow: 0 20px 50px rgba(15, 23, 42, .3);
    transform: translateY(12px) scale(.98); opacity: 0; transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
}
.mdx-pwa-dlg.is-open .mdx-pwa-backdrop { opacity: 1; }
.mdx-pwa-dlg.is-open .mdx-pwa-sheet { transform: none; opacity: 1; }
.mdx-pwa-head { display: flex; gap: .9rem; align-items: flex-start; }
.mdx-pwa-head img { border-radius: 14px; flex: none; background: #0b1220; }
.mdx-pwa-head h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 .3rem; }
.mdx-pwa-head p { margin: 0; color: var(--text-muted, #64748b); font-size: .9rem; line-height: 1.45; }
.mdx-pwa-pros, .mdx-pwa-steps { margin: 1rem 0 0; padding-left: 1.2rem; color: var(--text, #0f172a); font-size: .9rem; line-height: 1.7; }
.mdx-pwa-ico { display: inline-block; padding: 0 .3rem; border: 1px solid var(--border, #e5e7eb); border-radius: 6px; }
.mdx-pwa-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; }
/* Boutons du popup stylés ici (copie de .btn-go / .btn-rst de includes/header.php) : la page de connexion
   (index.php) charge ce popup SANS header.php — sans ces règles, ses boutons y restaient bruts. */
.mdx-pwa-actions > button {
    min-height: var(--mdx-tap); padding: 0 1.2rem; font: inherit; font-size: .84rem; font-weight: 600;
    border-radius: var(--radius-sm, 8px); cursor: pointer; white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.mdx-pwa-actions > .btn-go { background: var(--accent, #2563eb); border: none; color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .15); }
.mdx-pwa-actions > .btn-go:hover { background: var(--accent-2, #1d4ed8); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.mdx-pwa-actions > .btn-rst { background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e7eb); color: var(--text-muted, #64748b); font-weight: 500; }
.mdx-pwa-actions > .btn-rst:hover { border-color: var(--border-hi, #cbd5e1); color: var(--text, #0f172a); background: var(--bg-raised, #f8fafc); }
.mdx-pwa-actions > button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .3); }
@media (max-width: 575px) {
    .mdx-pwa-dlg { align-items: flex-end; padding: 0; }
    .mdx-pwa-sheet { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: calc(1.4rem + var(--mdx-safe-bottom)); }
    .mdx-pwa-actions { flex-direction: column-reverse; }
    .mdx-pwa-actions > button { width: 100%; }
}
