/* NexusFit — composants communs (phase 1 de l'audit UI, 25/10/2026).
   Uniquement des jetons de theme.css : rendu juste en clair ET en sombre. */

/* Verrou SUR html SEULEMENT : body a height:100% (main.css) ; lui mettre
   overflow:hidden coupait le contenu a un ecran de haut -> la page derriere
   une feuille remontait tout en haut (et y restait a la fermeture). */
html.nx-verrou { overflow: hidden !important; overscroll-behavior: none; }

.nx-fond {
  position: fixed; inset: 0; z-index: var(--z-feuille-fond, 9000);
  background: rgba(0, 0, 0, 0.45); opacity: 0; pointer-events: none; visibility: hidden;
}
.nx-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-feuille, 9001);
  margin: 0 auto; max-width: 560px; max-height: 92%;
  display: flex; flex-direction: column;
  background: var(--surface-glass, var(--bg-secondary));
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  border-top: 1px solid var(--border-strong); border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.3);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color: var(--text-primary); will-change: transform;
}
.nx-poignee {
  flex-shrink: 0; width: 100%; height: 26px; position: relative; cursor: grab; touch-action: none;
}
.nx-poignee::before {
  content: ""; position: absolute; left: 50%; top: 9px; width: 38px; height: 5px;
  margin-left: -19px; border-radius: 99px; background: var(--border-strong);
}
.nx-corps { overflow-y: auto; overscroll-behavior: contain; padding: 0 18px 20px; }
.nx-fermer {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex-shrink: 0;
  background: var(--bg-tertiary); color: var(--text-secondary); font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 100ms ease-out;
}
.nx-fermer:active { transform: scale(0.92); }

/* Feuille d'actions (confirmer / alerte / demander) */
.nx-action { max-width: 520px; }
.nx-action-titre { margin: 4px 0 6px; font-size: 20px; letter-spacing: -0.01em; text-align: center; }
.nx-action-texte { margin: 0 0 14px; font-size: 15px; line-height: 1.5; color: var(--text-secondary); text-align: center; white-space: pre-line; }
.nx-action-champ {
  width: 100%; box-sizing: border-box; padding: 14px 16px; border-radius: 14px; margin-bottom: 14px;
  border: 1.5px solid var(--border-strong); background: var(--bg-primary); color: var(--text-primary);
  font: inherit;
}
.nx-action-champ:focus { outline: none; border-color: var(--accent); }
.nx-action-boutons { display: grid; gap: 10px; }
.nx-btn {
  width: 100%; min-height: 50px; border: 0; border-radius: 16px; font: inherit; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: transform 100ms ease-out, opacity 150ms;
}
.nx-btn:active { transform: scale(0.98); opacity: 0.9; }
.nx-btn-principal { background: var(--accent-fill); color: #fff; }
.nx-btn-danger { background: var(--danger); color: #fff; }
.nx-btn-second { background: var(--bg-tertiary); color: var(--text-primary); }

/* Toast */
.nx-toast {
  position: fixed; left: 50%; z-index: var(--z-toast, 9500);
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 140%); opacity: 0; visibility: hidden;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px; min-height: 44px; box-sizing: border-box;
  border-radius: 16px; background: var(--toast-bg); color: var(--toast-text);
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow-lg);
}
.nx-toast > span { flex: 1; min-width: 0; padding: 4px 6px 4px 0; }
/* feuille ouverte : le message s'affiche en haut (30/10) */
.nx-toast.nx-toast-haut { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }
.nx-toast-erreur { box-shadow: var(--shadow-lg), inset 3px 0 0 var(--danger); }
.nx-toast-action {
  flex-shrink: 0; min-height: 36px; min-width: 44px; padding: 0 14px; border: 0; border-radius: 11px;
  /* (30/10) le message est TOUJOURS sombre : violet clair fixe (9,5:1) ; l'accent du
     thème clair n'y faisait que 2,7:1. Zone de toucher portée à 44 px de haut. */
  background: rgba(185, 168, 255, 0.18); color: #B9A8FF;
  font: inherit; font-weight: 800; cursor: pointer; position: relative;
}
.nx-toast-action::after { content: ""; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
.nx-toast-action:active { transform: scale(0.95); }

@media (prefers-reduced-transparency: reduce) {
  .nx-sheet { background: var(--bg-secondary); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* Zone de toucher de 44 x 44 px autour d'un petit bouton (croix, effacer…)
   sans changer son dessin (audit UI phase 1c, 25/10) */
.nx-cible44 { position: relative; }
.nx-cible44::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 44px; height: 44px; transform: translate(-50%, -50%);
}

/* ═══ APPARENCE UNIQUE DE TOUTES LES FEUILLES (25/10, demande Salvatore :
   « tous les overlays doivent être identiques ») ═══════════════════════
   Modèle : « Mes objectifs ». Les !important sont VOULUS : chaque page avait
   ses propres fond / coins / ombre / poignée en CSS ou en style en ligne ;
   cette règle passe devant pour qu'aucun écran ne s'en écarte. */
.nx-sheet {
  background: var(--surface-glass, var(--bg-secondary)) !important;
  -webkit-backdrop-filter: blur(24px) saturate(160%) !important;
  backdrop-filter: blur(24px) saturate(160%) !important;
  border: 0 !important;
  border-top: 1px solid var(--border-strong) !important;
  border-radius: 26px 26px 0 0 !important;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.35) !important;
}
.nx-fond { background: rgba(0, 0, 0, 0.45) !important;
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
/* Poignée : même trait partout (36 × 5) */
.nx-sheet .nx-poignee::before, .nx-sheet .sheet-handle::before, .nx-sheet .sq-handle::before,
.nx-sheet .anse::before, .nx-sheet .journal-drawer-handle::before, .nx-sheet .overlay-handle::before {
  width: 36px !important; height: 5px !important; margin-left: -18px !important; left: 50% !important;
  transform: none !important; border-radius: 3px !important; opacity: 1 !important;
  background: color-mix(in srgb, var(--text-tertiary) 55%, transparent) !important;
}
/* Croix : petit rond gris 32 px (zone de toucher 44 px) */
.nx-fermer { width: 32px; height: 32px; font-size: 15px; position: relative; }
.nx-fermer::after { content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  transform: translate(-50%, -50%); }

/* Glisser vers la gauche pour supprimer (25/10, phase 2) — voir nx-ui.js */
.nx-swipe { position: relative; overflow: hidden; touch-action: pan-y; }
/* (26/10) pastille compacte et arrondie, centree sur la ligne — le bloc rouge
   pleine hauteur etait enorme sur une carte haute (retour Salvatore, Journal). */
.nx-swipe-zone { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); width: 72px;
  height: min(calc(100% - 16px), 72px); border-radius: 16px; display: flex;
  align-items: center; justify-content: center; background: var(--danger); color: #fff; font-size: 22px; opacity: .85; }
.nx-swipe.pret .nx-swipe-zone { opacity: 1; }
.nx-swipe-carte { position: relative; z-index: 1; background: var(--nx-swipe-fond, var(--bg-secondary)); }
.items-list { overflow: hidden; }   /* la zone rouge reste dans les coins arrondis (Repas) */

/* ── Sélecteur segmenté unique (26/10, phase 2d) ─────────────────────────
   Modèle « Mes objectifs » (rectangle arrondi iOS, pas de capsule) :
   <div class="nx-seg"><span class="seg on">A</span><a class="seg" href>B</a></div> */
.nx-seg { display: flex; background: var(--bg-tertiary); border-radius: 12px; padding: 3px; }
.nx-seg .seg { flex: 1 1 0; min-width: 0; min-height: 38px; display: flex; align-items: center; justify-content: center;
  padding: 0 6px; border-radius: 9px; font-size: 15px; font-weight: 600; line-height: 1.2;
  color: var(--text-secondary); text-decoration: none; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; -webkit-tap-highlight-color: transparent; transition: color .15s; }
.nx-seg .seg.on { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.nx-seg a.seg:active { opacity: .55; }
@media (hover: hover) { .nx-seg a.seg:hover { color: var(--text-primary); } }

/* ── Interrupteur unique (iOS 51×31, vert système) ───────────────────────
   <label class="nx-switch"><input type="checkbox" role="switch"></label>
   ou <span class="nx-switch [on]"></span> quand l'état est piloté en JS. */
:root { --switch-off: #E9E9EA; }
[data-theme="dark"] { --switch-off: #39393D; }
.nx-switch { position: relative; display: inline-block; width: 51px; height: 31px; flex-shrink: 0;
  border-radius: 9999px; background: var(--switch-off); cursor: pointer; vertical-align: middle;
  transition: background .25s ease; -webkit-tap-highlight-color: transparent; }
.nx-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06);
  transition: transform .28s cubic-bezier(.3,.7,.4,1); }
.nx-switch.on, .nx-switch:has(input:checked) { background: var(--success); }
.nx-switch.on::after, .nx-switch:has(input:checked)::after { transform: translateX(20px); }
.nx-switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.nx-switch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .nx-switch, .nx-switch::after { transition: none; } }

/* Onglets du panneau Profil (barre défilante, définie dans 6 pages) : même
   forme que .nx-seg ; !important car chaque page la redéfinit après nous. */
.sheet-onglets { border-radius: 12px !important; padding: 3px !important; }
.sheet-onglets a, .sheet-onglets .on { border-radius: 9px !important; }

/* Accord pour l'analyse par IA (27/10/2026, refonte 01/11/2026 d'après le
   prototype « Nouveau repas, 4 écrans » validé) — feuille construite par nx-ui.js.
   Pastille de marque (dégradé gardé), titre 28/700, intro d'une phrase,
   3 lignes à icônes au trait, note de 2 lignes, bouton plein + « Plus tard ».
   Anneau de focus au clavier seulement (:focus-visible). */
.nx-ia-feuille:focus { outline: none; }
.nx-ia { overflow-y: auto; padding: 4px 22px 8px; text-align: center; }
.nx-ia-pastille { width: 64px; height: 64px; border-radius: 18px; margin: 4px auto 14px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, #B83DD9, #2F6FE0); }
.nx-ia-svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round;
  stroke-linejoin: round; display: block; }
.nx-ia-pastille .nx-ia-svg { width: 34px; height: 34px; stroke-width: 1.7; }
.nx-ia h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; margin: 0; color: var(--text-primary); }
.nx-ia-intro { font-size: 17px; line-height: 1.35; color: var(--text-secondary); margin: 10px auto 0; max-width: 420px; }
.nx-ia-liste { list-style: none; margin: 24px 0 8px; padding: 0 4px; display: grid; gap: 18px; text-align: left; }
.nx-ia-liste li { display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: start; }
.nx-ia-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent-light); color: var(--accent); }
.nx-ia-liste b { display: block; font-size: 17px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.nx-ia-liste span:not(.nx-ia-ico) { font-size: 15px; line-height: 1.35; color: var(--text-secondary); }
.nx-ia-note { font-size: 13px; line-height: 1.45; color: var(--text-secondary); margin: 18px 8px 0; }
.nx-ia-note a { color: var(--accent); font-weight: 600; text-decoration: none; display: inline-block; padding: 13px 6px; margin: -13px 0; }
.nx-ia-pied { flex: none; padding: 10px 18px 12px; display: grid; gap: 2px; }
.nx-ia-oui, .nx-ia-non { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0;
  border-radius: 14px; min-height: 50px; padding: 0 16px; font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent; }
.nx-ia-oui { color: #fff; background: var(--accent-fill); transition: transform 100ms ease-out, opacity 150ms; }
.nx-ia-oui:active { transform: scale(0.97); opacity: .9; }
.nx-ia-oui:disabled { opacity: 0.75; transform: none; }
.nx-ia-non { background: transparent; color: var(--accent); }
.nx-ia-non:active { opacity: 0.45; }
.nx-ia-oui:focus, .nx-ia-non:focus, .nx-ia-note a:focus { outline: none; }
.nx-ia-oui:focus-visible, .nx-ia-non:focus-visible, .nx-ia-note a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 14px; }
.nx-ia-err { margin: 8px 0 0; text-align: center; font-size: 15px; color: var(--danger); }
.nx-ia-spin { width: 18px; height: 18px; border-radius: 50%; border: 2.4px solid currentColor; border-right-color: transparent;
  animation: nx-tourne .8s linear infinite; flex: none; }
@keyframes nx-tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nx-ia-spin { animation-duration: 2s; } }
/* Ordinateur : fenêtre centrée (le ressort de nx.sheet la fait monter jusqu'au centre) */
@media (min-width: 900px) {
  .nx-ia-feuille.nx-sheet { top: 0; bottom: 0; margin: auto; height: fit-content; width: 560px; max-width: calc(100vw - 48px);
    max-height: min(80vh, 760px); border-radius: 16px !important; border: 0 !important; padding-bottom: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .25), 0 2px 8px rgba(0, 0, 0, .1) !important; }
  .nx-ia-feuille .nx-poignee { height: 14px; visibility: hidden; }
}

/* ── Orbe du coach (27/10, valide par Salvatore) : sphere violet-bleu + N blanc.
   Identite unique du coach partout (« Coach Nexus »). Taille : --t.
   <span class="nx-orbe" style="--t:22px"><svg …N…></svg></span> ── */
.nx-orbe { --t: 22px; width: var(--t); height: var(--t); border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  background: radial-gradient(circle at 34% 28%, #F6C8FF 0%, #C65BE6 38%, #8A4FE0 68%, #4F6BE8 100%);
  box-shadow: 0 2px 8px rgba(138, 79, 224, .30); }
[data-theme="dark"] .nx-orbe { box-shadow: 0 0 10px rgba(198, 91, 230, .50); }
.nx-orbe svg { width: 55%; height: 55%; margin-top: 4%; display: block; }

/* ── Navigation des pages poussees (27/10, « tout coherent », demande Salvatore)
   Modele iOS : « ‹ Parent » a gauche (couleur d accent, sans fond), titre
   centre, actions a droite. Meme rendu sur toutes les pages qui ne sont pas
   un onglet racine. Comportement (retour arriere intelligent) : nx-ui.js. ── */
.nx-retour { display: inline-flex; align-items: center; gap: 1px; min-height: 44px; padding: 0 8px 0 2px;
  margin-left: -4px; color: var(--accent); font-size: 17px; font-weight: 400; letter-spacing: -0.01em;
  text-decoration: none; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
  flex-shrink: 0; position: relative; z-index: 1; font-family: inherit; }
.nx-retour svg { width: 22px; height: 22px; flex: none; }
.nx-retour .nx-retour-txt { max-width: 7.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-retour:active { opacity: .45; }
.mobile-header.nx-pousse { justify-content: space-between; padding-left: 8px !important; }
.mobile-header.nx-pousse .mobile-header-title { position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 0; height: 56px; line-height: 56px; margin: 0 !important; max-width: 44%; text-align: center;
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* (30/10) 44 % : un titre long ne passe plus sous « ‹ Activités » (il se coupe avant) */
.mobile-header.nx-pousse > :last-child { margin-left: auto; }
/* Bouton retour flottant (pages a grande image, ex. recette) : meme chevron */
.nx-retour-flottant { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; background: var(--surface-glass, var(--bg-secondary)); color: var(--text-primary);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--shadow-md); text-decoration: none; }
.nx-retour-flottant svg { width: 22px; height: 22px; margin-left: -2px; }

/* ── Grands titres des onglets racine (27/10, charte §6) ──────────────── */
.nx-titre-compact { display: none; }
@media (max-width: 768px) {
  .mobile-header.nx-racine { background: transparent; border-bottom-color: transparent;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    transition: background-color .2s ease, border-color .2s ease; }
  .mobile-header.nx-racine .mobile-header-title { flex: 1 1 auto; min-width: 0; font-size: 34px; font-weight: 700;
    letter-spacing: -0.022em; line-height: 1.15; transition: opacity .18s ease, transform .18s ease; }
  .mobile-header.nx-racine .nx-titre-compact { display: block; position: absolute; left: 50%; bottom: 0; height: 56px;
    line-height: 56px; max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary);
    transform: translate(-50%, 4px); opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
  .mobile-header.nx-racine.compact { background: var(--header-glass);
    -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
    border-bottom-color: var(--border); }
  .mobile-header.nx-racine.compact .mobile-header-title { opacity: 0; transform: translateY(-6px); }
  .mobile-header.nx-racine.compact .nx-titre-compact { opacity: 1; transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-header.nx-racine, .mobile-header.nx-racine .mobile-header-title, .mobile-header.nx-racine .nx-titre-compact { transition: none; }
}
/* Icones de l interface (charte §7) */
.nx-ico { display: block; flex: none; }

/* Bouton de fermeture d une modale (« OK », charte : presentation modale) */
.nx-ok { min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px 0 10px; margin-left: auto;
  color: var(--accent); font-size: 17px; font-weight: 600; text-decoration: none; position: relative; z-index: 1;
  -webkit-tap-highlight-color: transparent; }
.nx-ok:active { opacity: .45; }
/* etat de la barre pose sans animation (chargement / retour arriere) */
.mobile-header.nx-racine.sans-anim, .mobile-header.nx-racine.sans-anim .mobile-header-title,
.mobile-header.nx-racine.sans-anim .nx-titre-compact { transition: none !important; }
/* Onglets de Compte : fondu sur les bords quand ca deborde (on devine qu il y a la suite) */
.sheet-onglets { -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent); }
.sheet-onglets.fin { -webkit-mask-image: none; mask-image: none; }
/* Icone de ligne de reglage (charte §7, facon Reglages iOS) : symbole fin dans un carre arrondi teinte */
.nx-ico-carre { width: 30px; height: 30px; border-radius: 8px; flex: none; display: flex; align-items: center;
  justify-content: center; background: var(--accent-light); color: var(--accent); }

/* ── Liste groupee facon Reglages iOS (charte, 27/10) ─────────────────────
   <div class="nx-titre-groupe">Titre</div>
   <div class="nx-groupe"><a class="nx-ligne" href="…"><span class="nx-ico-carre">…</span>
     <span class="t">Libelle</span><span class="v">valeur</span><span class="nx-chev">›</span></a></div> */
.nx-titre-groupe { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-secondary); margin: 22px 4px 6px; }
.nx-groupe { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-top: 12px; }
.nx-titre-groupe + .nx-groupe { margin-top: 0; }
.nx-ligne { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 11px 14px; border: 0;
  border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; font-family: inherit;
  color: var(--text-primary); text-decoration: none; box-sizing: border-box; }
.nx-ligne:last-child { border-bottom: 0; }
.nx-ligne:active { background: var(--bg-tertiary); }
.nx-ligne .t { flex: 1; min-width: 0; font-size: 16px; }
.nx-ligne .t small { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.nx-ligne .v { font-size: 15px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.nx-chev { color: var(--text-tertiary); font-size: 20px; line-height: 1; }
