/* Design de la version Node : s'applique par-dessus style.css (chargé juste avant).
   Ordinateur : menu latéral fixe. Téléphone : barre du haut + onglets en bas, comme une appli.
   Les pages s'enchaînent en fondu (transitions de vue) au lieu de clignoter. */

:root {
  --fond: #f4f5fa;
  --surface: #ffffff;
  --texte: #0b1220;
  --muted: #5d667b;
  --bord: #e3e6ef;
  --accent: #5b5bf0;
  --accent-2: #19b8dd;
  --violet: #8b5cf6;
  --rayon: 18px;
  --ombre: 0 1px 2px rgb(11 18 32 / .04), 0 10px 30px -12px rgb(11 18 32 / .12);
  --degrade: linear-gradient(135deg, var(--accent), var(--violet));
  --largeur-menu: 252px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #090c15;
    --surface: #111625;
    --texte: #e9edf6;
    --muted: #8e9ab3;
    --bord: #212a3e;
    --accent: #8c8cff;
    --accent-2: #38d0f0;
    --violet: #a78bfa;
    --ombre: 0 1px 0 rgb(255 255 255 / .03) inset, 0 16px 40px -16px rgb(0 0 0 / .6);
  }
}

/* ---------- Fond et typographie ---------- */
body {
  font-size: 15px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 520px at 105% -8%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 62%),
    radial-gradient(900px 480px at -12% 108%, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 60%),
    var(--fond);
  background-attachment: fixed;
  min-height: 100dvh;
}
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2rem); font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
h2 { letter-spacing: -.01em; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 40%, transparent) transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Enchaînement des pages : fondu, le menu ne bouge pas ---------- */
@view-transition { navigation: auto; }
.barre { view-transition-name: menu; }
main { view-transition-name: contenu; }
::view-transition-old(contenu) { animation: 110ms ease-out both vue-sort; }
::view-transition-new(contenu) { animation: 260ms cubic-bezier(.2, .7, .2, 1) both vue-entre; }
@keyframes vue-sort { to { opacity: 0; } }
@keyframes vue-entre { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; } }

/* ---------- Menu ---------- */
.logo { font-size: 1rem; letter-spacing: -.01em; }
.logo span { flex: none; width: 34px; height: 34px; border-radius: 11px; background: var(--degrade); box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.barre nav a { display: flex; align-items: center; gap: 10px; transition: background .15s, color .15s; }
.barre nav a .icone { flex: none; }
.barre nav a .badge { margin-left: auto; }
.badge { font-weight: 700; padding: 1px 7px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }

.barre nav a.onglet-admin.actif { background: color-mix(in srgb, #f97316 16%, transparent); color: #ea580c; }

/* Témoin du temps réel */
.etat-direct {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 99px; font-size: 12px; font-weight: 600;
  color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent);
}
.etat-direct i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.direct-actif .etat-direct { color: #16a34a; background: color-mix(in srgb, #22c55e 14%, transparent); }
.direct-actif .etat-direct i { background: #22c55e; animation: pouls 2s ease-out infinite; }
@keyframes pouls { 0% { box-shadow: 0 0 0 0 rgb(34 197 94 / .55); } 100% { box-shadow: 0 0 0 9px rgb(34 197 94 / 0); } }
@media (prefers-reduced-motion: reduce) { .direct-actif .etat-direct i { animation: none; } }

.moi-carte { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--texte); border-radius: 12px; }
.moi-carte strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moi-carte .avatar { width: 34px; height: 34px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.qui-actions { display: flex; gap: 8px; }

/* Ordinateur : menu latéral fixe */
@media (min-width: 900px) {
  body:has(> .barre) { padding-left: var(--largeur-menu); }
  .barre {
    position: fixed; inset: 0 auto 0 0; width: var(--largeur-menu); z-index: 20;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 22px; padding: 22px 14px 16px;
    background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(18px);
    border-bottom: 0; border-right: 1px solid var(--bord);
  }
  .barre .logo { padding: 0 8px; }
  .barre nav { flex: 1 1 auto; flex-direction: column; flex-wrap: nowrap; gap: 3px; overflow-y: auto; }
  .barre nav a { position: relative; padding: 10px 12px; border-radius: 12px; }
  .barre nav a.actif { background: color-mix(in srgb, var(--accent) 13%, transparent); font-weight: 600; }
  .barre nav a.actif::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--degrade); }
  .barre nav a.onglet-admin { margin-top: auto; }
  .barre nav a.onglet-admin.actif::before { background: #f97316; }
  .qui { margin: 0; flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 8px 0; border-top: 1px solid var(--bord); }
  .qui .etat-direct { align-self: flex-start; }
  .qui-actions .btn { flex: 1; justify-self: stretch; }
  .qui-actions #bouton-son { flex: 0 0 auto; }
  main, .bannieres { max-width: 1120px; }
  main { padding: 28px 28px 70px; }
  .bannieres { padding: 0 28px; margin-top: 24px; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); }
}

/* Téléphone et tablette : barre du haut + onglets en bas */
@media (max-width: 899.98px) {
  /* Pas de flou ici : il ferait de la barre le repère des onglets « fixed », qui resteraient collés en haut. */
  .barre { position: sticky; top: 0; flex-wrap: nowrap; gap: 10px; padding: 10px 14px; backdrop-filter: none; background: var(--surface); }
  .barre .logo { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .qui { margin: 0; gap: 8px; }
  .qui .etat-direct { padding: 6px; }
  .qui .etat-direct span, .moi-carte strong, .texte-deconnexion { display: none; }
  .icone-deconnexion { display: inline !important; }
  .barre nav {
    position: fixed; inset: auto 0 0 0; z-index: 20; order: 0; margin: 0; flex: none; flex-wrap: nowrap; gap: 0;
    padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto; scrollbar-width: none;
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(18px); border-top: 1px solid var(--bord);
  }
  .barre nav::-webkit-scrollbar { display: none; }
  .barre nav a {
    position: relative; flex: 1 0 68px; flex-direction: column; gap: 3px; padding: 6px 4px; border-radius: 12px;
    font-size: 10.5px; font-weight: 600; white-space: nowrap;
  }
  .barre nav a .icone { width: 22px; height: 22px; }
  .barre nav a .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
  main { padding-bottom: 110px; }
  .pied { padding-bottom: 86px; }
  .toasts { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .chat { height: max(360px, calc(100dvh - 250px)); }
}

/* ---------- Composants ---------- */
.carte { border-radius: var(--rayon); transition: border-color .2s, transform .2s, box-shadow .2s; }
.lien:hover, .tuile:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -18px color-mix(in srgb, var(--accent) 45%, transparent); }
.btn {
  border-radius: 12px; background: var(--degrade); letter-spacing: -.005em;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 80%, transparent);
  transition: transform .12s, box-shadow .15s, filter .15s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn.secondaire { background: var(--surface); box-shadow: none; }
.btn.secondaire:hover:not(:disabled) { border-color: var(--accent); filter: none; }
.btn.danger { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 8px 20px -10px rgb(220 38 38 / .8); }
input, textarea, select { border-radius: 12px; padding: 10px 13px; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.champ-msg input:focus { box-shadow: none; }
.tag { padding: 3px 11px; }
.flash { border-radius: 14px; border-color: color-mix(in srgb, var(--accent) 45%, transparent); animation: vue-entre .3s both; }
.filtres a { transition: border-color .15s, background .15s, color .15s; }
.filtres a.actif { background: var(--degrade); border-color: transparent; }
.onglets { border-radius: 14px; }
.onglets a, .onglets.jeux button { border-radius: 10px; }

/* Bannières */
.banniere { border-radius: 22px; padding: 20px 24px; }
.infos {
  position: relative; overflow: hidden;
  background: linear-gradient(125deg, var(--accent) 0%, var(--violet) 55%, var(--accent-2) 120%);
  box-shadow: 0 20px 44px -22px color-mix(in srgb, var(--accent) 80%, transparent);
}
.infos::after { /* reflet discret */
  content: ''; position: absolute; inset: -40% -10% auto auto; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgb(255 255 255 / .22), transparent 65%); pointer-events: none;
}
.techs li { background: rgb(255 255 255 / .18); backdrop-filter: blur(6px); border-radius: 12px; }
.bloc-bannieres > summary { border-radius: 14px; }

/* Listes de procédures et tableaux */
.groupe-procs { border-radius: var(--rayon); }
.ligne-proc { transition: background .15s; }
table { border-radius: var(--rayon); }
.statut, .rang { letter-spacing: .01em; }

/* Chat */
.chat { border-radius: 22px; }
.chat-icone { background: var(--degrade); }
.mien .bulle, .envoi { background: var(--degrade); }

/* Alertes en direct */
.toast-direct { border-radius: 14px; border-color: color-mix(in srgb, var(--accent) 55%, transparent); backdrop-filter: blur(12px); }

/* ---------- Page de connexion ---------- */
body:not(:has(> .barre)) main { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; max-width: none; }
body:not(:has(> .barre)) main > .flash { position: fixed; top: 16px; left: 50%; translate: -50% 0; z-index: 5; max-width: calc(100vw - 32px); }
.centre {
  width: min(460px, 100%); margin: 0; padding: 32px; border-radius: 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px -30px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 0 1px var(--bord);
  animation: vue-entre .45s cubic-bezier(.2, .7, .2, 1) both;
}
.centre .logo.grand span { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; }
@media (prefers-reduced-motion: reduce) { .centre, .flash { animation: none; } }
