/* Interface ordinateur, lot 2 (16/11) : panneau latéral (règle 5) et composant « tableau + fiche » (règle 4).
   Chargé après style.css et equipe.css. TOUT ce fichier est sous `min-width:861px` : à 860 px et moins, rien ne change.
   Variable à régler par le cadre (lot 1) : --tf-haut, hauteur de la barre collante du haut (0 tant qu'elle n'existe pas). */

/* ===== Lot 5 · Moniteur ===== */
/* Ma journée en deux colonnes, Les élèves en tableau + fiche (la fiche vient de .tf-*). Tout sous min-width:861px. */
@media (min-width:861px){
  .eq-day.mj{display:grid;grid-template-columns:minmax(300px,5fr) minmax(0,7fr);gap:18px;align-items:start}
  .mj-liste{background:var(--surface);border:1px solid var(--line);border-radius:var(--eg-radius,14px);overflow:hidden;display:grid;box-shadow:var(--shadow)}
  .mj-ligne{--k:#0b7f86;display:flex;align-items:center;gap:14px;width:100%;min-height:62px;margin:0;padding:8px 14px;background:transparent;border:0;border-top:1px solid var(--line);
    border-left:4px solid transparent;border-radius:0;color:var(--ink);text-align:left;font-weight:500;cursor:pointer;box-shadow:none}
  .mj-ligne:first-child{border-top:0}
  .mj-ligne:hover{background:var(--surface-2)}
  .mj-ligne.choisie,.mj-ligne[aria-pressed=true]{background:var(--kbg,#e3f5f3);border-left-color:var(--k)}
  .mj-ligne.cancelled{opacity:.55}.mj-ligne.cancelled .mj-qui b{text-decoration:line-through}
  .mj-heure{flex:none;min-width:52px;font:800 var(--fs-md,16px) var(--font-display);font-variant-numeric:tabular-nums;color:var(--ink)}
  .mj-qui{flex:1;min-width:0;display:flex;flex-direction:column;line-height:1.3}
  .mj-qui b{font-size:var(--fs-sm);color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .mj-qui small{color:var(--muted);font-size:var(--fs-xs);font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .mj-ligne .chip{flex:none;margin:0}
  .mj-detail{display:grid;gap:14px;min-width:0;position:sticky;top:calc(var(--tf-haut,0px) + 12px);align-content:start}
  .mj-detail{background:none;border:0;padding:0;box-shadow:none}
  .mj-detail>*{margin:0}
  .mj-detail .lesson-actions{display:flex;flex-wrap:wrap;gap:8px}
  .mj-detail .lesson-actions>p{flex:1 0 100%;margin:0}
  .mj-detail .lesson-actions .btn-block,.mj-detail .lesson-actions button{width:auto;flex:0 0 auto;padding-left:20px;padding-right:20px}
  .mj-detail .eq-ring-row{display:flex;justify-content:flex-start;gap:28px;margin:6px 0 10px}
  .eq-day.mj+button{width:auto;align-self:flex-start;margin-top:14px}
  .day-nav button{width:auto}

  /* Les élèves du moniteur : le tableau garde sa largeur, la fiche réduite se lit sans s'étirer. */
  /* Fiche et bilan du moniteur : anneaux C1 à C4 sur une ligne, à gauche ; boutons à leur taille ; fiche réduite alignée. */
  #app .eq-ring-row{display:flex;justify-content:flex-start;gap:28px}
  .mo-btns.col button{width:auto;align-self:flex-start}
  .mo-reduite .hub-summary{align-items:center}
  .tf-fiche .mo-reduite{margin:0 0 12px}
  .tf-fiche .mo-tabs{margin:12px 0}
  .tf-fiche .mo-card .btn-block,.tf-fiche .mo-last .btn-block,.tf-fiche .mo-btns .btn-block{width:auto}
}

/* ——— Panneau latéral : la feuille commune feuille() (.vf-sheet) et la famille .sheet-backdrop (.filter-sheet) ——— */
@media (min-width:861px){
  .vf-veil{background:rgba(15,42,47,.16)}
  .vf-sheet,.vf-sheet.sec-form{top:0;bottom:0;left:auto;right:0;width:480px;max-width:100vw;height:100vh;height:100dvh;max-height:none;margin:0;
    border-radius:0;border-left:1px solid var(--line-2);box-shadow:-14px 0 36px rgba(0,40,48,.16);transform:none;padding:0}
  .vf-sheet .vf-grab,.vf-sheet.sec-form .vf-grab{display:none}
  .vf-sheet .vf-sheet-head{padding:18px 20px 12px;border-bottom:1px solid var(--line)}
  .vf-sheet .vf-sheet-body{flex:1 1 auto;min-height:0;padding:16px 20px}
  .vf-sheet .vf-sheet-foot{flex:none;padding:12px 20px 18px;background:var(--surface)}

  .filter-sheet{align-items:stretch;justify-content:flex-end}
  .filter-sheet .sheet-backdrop{background:rgba(15,42,47,.16)}
  .filter-sheet .sheet-panel{width:480px;max-width:100vw;height:100%;max-height:none;border-radius:0;box-shadow:-14px 0 36px rgba(0,40,48,.16);padding:0 20px 16px}
}
@media (min-width:861px) and (prefers-reduced-motion:no-preference){
  .vf-sheet,.filter-sheet .sheet-panel{animation:vf-droite .22s cubic-bezier(.16,1,.3,1)}
  @keyframes vf-droite{from{transform:translateX(48px);opacity:.5}}
}

/* ——— Tableau + fiche ——— */
@media (min-width:861px){
  .tf-outils{display:flex;align-items:center;flex-wrap:wrap;gap:10px 16px;margin:0 0 14px}
  #app .tf-outils input[type=search]:not([type=checkbox]):not([type=radio]):not([type=file]){flex:0 1 380px;min-width:260px;width:380px;margin:0}
  .tf-outils .filter-strip{flex:1 1 auto;flex-wrap:wrap;margin:0;padding:0;overflow:visible}

  .tf{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;align-items:start}
  /* Retour de Mahonri (17/11) : fiche ouverte, elle prend la plus grande part (55 %, 560 px au moins) ; la liste se resserre
     (ses colonnes .tf-sec et .tf-ter se masquent par les requêtes de conteneur de .tf-zone, plus bas). Avant : 440 px fixes. */
  /* 17/11, mesure : avec 20 px d'écart, 45fr/55fr ne donnait que 54 % ; 43fr/57fr donne au moins 55 % de la zone. */
  .tf.avec-fiche{grid-template-columns:minmax(0,43fr) minmax(560px,57fr)}
  .tf-table{width:100%;border-collapse:separate;border-spacing:0;background:var(--surface);border:1px solid var(--line);border-radius:14px;font-size:14px}
  .tf-th{position:sticky;top:var(--tf-haut,0px);z-index:2;height:40px;padding:0 12px;background:var(--surface-2);border-bottom:1px solid var(--line);
    text-align:left;font-size:11px;font-weight:750;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);white-space:nowrap}
  .tf-th:first-child{border-top-left-radius:13px}
  .tf-th:last-child{border-top-right-radius:13px}
  .tf-th:has(.tf-tri){padding:0}
  .tf-tri{display:flex;align-items:center;gap:6px;width:100%;height:40px;margin:0;padding:0 12px;background:none;border:0;border-radius:0;
    font:inherit;letter-spacing:inherit;text-transform:inherit;color:inherit;cursor:pointer;text-align:left}
  .tf-tri:hover{background:none;color:var(--ink)}
  .tf-tri:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}
  .tf-th.tf-num .tf-tri{justify-content:flex-end}
  .tf-th[aria-sort=ascending] .tf-tri,.tf-th[aria-sort=descending] .tf-tri{color:var(--ink)}
  .tf-fl{font-style:normal;min-width:10px}
  .tf-th[aria-sort=ascending] .tf-fl::after{content:'↑'}
  .tf-th[aria-sort=descending] .tf-fl::after{content:'↓'}
  .tf-ligne{height:44px;cursor:pointer}
  .tf-ligne td{height:44px;padding:4px 12px;border-bottom:1px solid var(--line);vertical-align:middle;white-space:nowrap;scroll-margin-top:48px}
  .tf-ligne:last-child td{border-bottom:0}
  .tf-ligne:last-child td:first-child{border-bottom-left-radius:13px}
  .tf-ligne:last-child td:last-child{border-bottom-right-radius:13px}
  .tf-ligne:hover td{background:color-mix(in srgb,var(--primary) 5%,var(--surface))}
  .tf-ligne.choisie td{background:var(--primary-soft)}
  .tf-ligne.choisie td:first-child{box-shadow:inset 3px 0 0 var(--primary)}
  .tf-ligne:focus-visible{outline:2px solid var(--primary);outline-offset:-2px}
  .tf-num{text-align:right;font-variant-numeric:tabular-nums}
  .tf-nom{display:flex;align-items:center;gap:10px}
  .tf-nom .avatar{width:32px;height:32px;font-size:12px}
  .tf-nom>span:last-child{display:flex;flex-direction:column;line-height:1.25;min-width:0}
  .tf-nom b{font-size:14.5px}
  .tf-nom small{color:var(--muted);font-size:12px}
  .tf-acces{display:flex;align-items:center;gap:6px}
  .tf-acces .acces-a-activer{margin-top:0!important;align-self:center!important}
  .tf-ligne .docs-line{margin:0;font-size:13px;white-space:nowrap}
  /* Fiche ouverte, tableau étroit : les colonnes secondaires s'effacent (l'information reste dans la fiche), puis reviennent. */
  .tf-zone{container-type:inline-size;min-width:0}
  @container (max-width:760px){.tf-sec{display:none}}
  @container (max-width:640px){.tf-ter{display:none}}
  .tf-fiche .dos-card{grid-template-columns:minmax(0,1fr);gap:18px}
  .tf-vide{margin:12px 0 0}
  .tf-aide{margin:10px 2px 0;color:var(--muted);font-size:12.5px}

  .tf-fiche{position:sticky;top:var(--tf-haut,12px);max-height:calc(100vh - var(--tf-haut,12px) - 12px);overflow-y:auto;overscroll-behavior:contain;
    background:var(--surface);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow)}
  .tf-fiche[hidden]{display:none}
  .tf-fiche-tete{position:sticky;top:0;z-index:1;display:flex;align-items:center;gap:10px;padding:12px 14px;background:var(--surface);border-bottom:1px solid var(--line)}
  .tf-fiche-nom{display:flex;flex-direction:column;flex:1;min-width:0;line-height:1.25}
  .tf-fiche-nom b{font-size:16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .tf-fiche-nom small{color:var(--muted);font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .tf-grand{flex:none;margin:0;min-height:36px;padding:0 12px;border:0;border-radius:10px;background:#0b6b78;color:#fff;font-size:13px;font-weight:700;white-space:nowrap}
  .tf-grand:hover{background:#09545f}
  .tf-x{flex:none;display:grid;place-items:center;width:36px;height:36px;margin:0;padding:0;border:1px solid var(--line-2);border-radius:50%;background:var(--surface);color:var(--ink-2);font-size:20px;line-height:1}
  .tf-x:hover{background:var(--surface-2);color:var(--ink)}
  .tf-fiche-corps{padding:12px 14px 16px}
  .tf-fiche-corps>*{margin-top:0}
  .tf-fiche-corps .eq-docs{padding:4px 2px 10px}
  .tf-attente{padding:24px 16px;margin:0;color:var(--muted)}
}

/* ===== Lot 4 · Administrateur ===== */
/* Les écrans de l'Administration (classes adm-*, equipe.css) passent dans le cadre de 1 280 px : la classe adm-large est posée
   par admLarge() (app.js) seulement au-dessus de 861 px, adm-cols pour deux colonnes. Les formulaires (Créditer, Corriger,
   Nouvelle auto-école, Logo, réglages) gardent leurs 720 px de lecture. */
@media (min-width:861px){
  #app:has(.adm.adm-large){max-width:calc(1280px + 2*var(--marge))}
  .adm.adm-large{max-width:none}
  #app:has(.adm-form){max-width:calc(720px + 2*var(--marge))}   /* Créditer, Corriger, Nouvelle auto-école : formulaires de 720 px */
  .adm.adm-large>.eq-tiles{grid-template-columns:repeat(auto-fill,minmax(200px,260px));justify-content:start;gap:12px}
  .adm.adm-cols{column-count:2;column-gap:36px}
  .adm.adm-cols>*{break-inside:avoid}
  .adm.adm-cols>.eq-tiles{column-span:all}
  /* Accueil : les quatre lignes à gauche (avec la légende des pastilles dessous), la note à droite. */
  .adm.adm-accueil{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);column-gap:36px;align-items:start}
  .adm.adm-accueil>.eq-tiles{grid-column:1/-1}
  .adm.adm-accueil>.vf-card{grid-column:1}
  .adm.adm-accueil>.adm-aide{grid-column:1}
  .adm.adm-accueil>.pil-sec{grid-column:2;grid-row:2/span 2;margin-top:0}
  .adm.adm-cols>.pil-sec{margin:0 0 18px}

  /* Auto-écoles : barre d'outils (aide à gauche, « + Nouvelle auto-école » à droite), puis tableau + fiche. */
  .adm-outils{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0 0 14px}
  .adm-outils .adm-aide{margin:0}
  .adm-outils .vf-btn{flex:none;width:auto;min-width:220px}
  .adm .tf-table .sec-pill{display:inline-block;min-width:40px}
  /* La fiche de droite : le contenu de la fiche téléphone, sans .adm (qui fixerait la largeur de la page). */
  .adm-fiche>.adm-note:first-child,.adm-fiche>.code-once{margin-bottom:14px}
  .adm-fiche>.pil-sec+.pil-sec,.adm-fiche>.adm-aide+.pil-sec{margin-top:14px}
  .adm-fiche>.pil-sec:first-child{margin-top:0}
  .adm-fiche .adm-pile .vf-btn{width:100%}
  .adm-fiche .adm-solde b{font-size:30px}

  /* Tableau simple (journal, comptes du Workshop) : pas de fiche, lignes non cliquables. */
  .adm-table{margin:0 0 14px}
  .adm-table .tf-ligne{cursor:default}
  .adm-table .tf-ligne:hover td{background:var(--surface)}
  .adm-table td{white-space:normal}
  .adm-table .adm-inter{display:flex;width:40px;height:24px;min-height:0;padding:0;border:0}
  .adm-table td:has(.adm-inter){padding-top:0;padding-bottom:0}
  .adm-table .adm-inter>span{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  .adm-table .adm-inter input{left:0;width:40px;height:24px}
  .adm-table .adm-inter i{margin:0}
}
@media (min-width:861px){
  .adm-acces-nouveau{width:auto}
}

/* ===== Blocs en grille (17/11) ===== */
/* Uniquement les fiches equipe et les parametres du gerant. Les colonnes suivent
   la largeur REELLE de la fiche laterale ; aucune regle nouvelle sous 1200 px.
   Pas de placement dense ni de changement de l'ordre des blocs. */
@media (min-width:1200px){
  .tf-fiche{container:blocs-panneau / inline-size;min-width:0}
  .tf-fiche-corps{container:blocs-fiche / inline-size;--blocs-cols:1}

  /* Page entiere : le titre, les validites et les onglets restent transversaux. */
  #app:has(>.mo-fhead){--blocs-cols:2;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;align-items:start}
  #app:has(>.mo-fhead)>*{grid-column:1/-1;min-width:0;margin-block:0}
  #app:has(>.mo-fhead)>.mo-reduite,
  #app:has(>.mo-fhead)>.eq-note{grid-column:auto}

  #app:has(>.mo-fhead):not(:has(>.mo-reduite))>.eq-note{grid-column:1/-1}

  /* Les conteneurs intermediaires des onglets restent des blocs : aucun DOM aplati. */
  .mo-tabbody .mo-col,
  .mo-tabbody .sec-fin,
  .mo-tabbody .mo-code-tab>.pg-levels,
  .mo-tabbody .mo-dossier .dos-card{
    display:grid;grid-template-columns:repeat(var(--blocs-cols,1),minmax(0,1fr));gap:14px;align-items:start
  }
  .mo-tabbody :is(.mo-col,.sec-fin,.pg-levels,.dos-card)>*{min-width:0;margin-block:0}
  .mo-tabbody .mo-col>:is(.mo-skills,.mo-reports,.mo-listen),
  .mo-tabbody .sec-fin>.sec-pieces{grid-column:1/-1}
  /* Identite, formation, validites : trois parties independantes dans le dossier. */
  .mo-tabbody .mo-dossier .dos-col{display:contents}
  .mo-tabbody .mo-dossier{max-width:none}
  .mo-tabbody .mo-code-tab{max-width:none}
  .mo-tabbody .mo-code-tab>.pg-chart{width:100%;min-width:0}
  .mo-tabbody .mo-hours-row{grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
  .mo-tabbody .mo-hours-fig{min-width:0}
  .mo-tabbody .pg-level-head{flex-wrap:wrap}
  .mo-tabbody .pg-level-text{min-width:0;flex:1 1 120px}

  /* Le corps ne peut pas interroger sa propre largeur : le panneau parent
     pilote sa grille (500 + ~20 px de padding ; seuils abaissés le 17/11 pour la fiche à 55 % à 1440 px), le corps pilote ses descendants. */
  .tf-fiche-corps:has(>.mo-tabbody){display:grid;grid-template-columns:minmax(0,1fr);gap:12px;align-items:start}
  .tf-fiche-corps:has(>.mo-tabbody)>*{grid-column:1/-1;min-width:0;margin-block:0}
  @container blocs-panneau (min-width:520px){
    .tf-fiche-corps:has(>.mo-tabbody){grid-template-columns:repeat(2,minmax(0,1fr))}
    .tf-fiche-corps:has(>.mo-tabbody)>.mo-reduite,
    .tf-fiche-corps:has(>.mo-tabbody)>.eq-note{grid-column:auto}
    .tf-fiche-corps:has(>.mo-tabbody):not(:has(>.mo-reduite))>.eq-note{grid-column:1/-1}
    .tf-fiche-corps.eq-fiche-corps{grid-template-columns:repeat(2,minmax(0,1fr))}
    .tf-fiche-corps.eq-fiche-corps>*{grid-column:1/-1;min-width:0}
    .tf-fiche-corps.eq-fiche-corps>.sec-fld{grid-column:auto}
  }
  @container blocs-fiche (min-width:500px){
    .mo-tabbody{--blocs-cols:2}
    .eq-fiche-corps>.eq-droits{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;align-items:start}
  }
  @container blocs-panneau (min-width:928px){
    .tf-fiche-corps:has(>.mo-tabbody),
    .tf-fiche-corps.eq-fiche-corps{grid-template-columns:repeat(3,minmax(0,1fr))}
  }
  @container blocs-fiche (min-width:900px){
    .mo-tabbody{--blocs-cols:3}
    .eq-fiche-corps>.eq-droits{grid-template-columns:repeat(3,minmax(0,1fr))}
  }

  /* Ma journee : les anneaux replies et le dernier bilan peuvent se partager
     une ligne ; les sous-competences ouvertes reprennent toute la largeur. */
  .eq-day.mj{container:blocs-jour / inline-size}
  @container blocs-jour (min-width:1020px){
    /* Compétences C1 à C4 toujours en anneaux sur UNE ligne (règle de Mahonri) : la colonne des compétences prend la largeur des quatre anneaux, le bilan le reste. */
    .mj-detail{grid-template-columns:auto minmax(0,1fr);align-items:start}
    .mj-detail>*{grid-column:1/-1;min-width:0}
    .mj-detail>.mj-comp:not(:has(.eq-sublist)),
    .mj-detail>.mj-dernier{grid-column:auto}
    .mj-detail>.mj-comp:has(.eq-sublist)+.mj-dernier{grid-column:1/-1}
    #app .mj-detail .eq-ring-row{gap:10px;flex-wrap:nowrap}
  }

  /* Parametres : seule cette page de cartes quitte le plafond de 720 px.
     Les formulaires Identite / Reprise et les ecrans Workshop restent exclus. */
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres){
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;align-items:start;
    max-width:calc(1280px + 2*var(--marge))
  }
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres)>*{min-width:0;margin-block:0}
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres)>.page-head{grid-column:1/-1}
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres)>.retour-ges{grid-column:1/-1;justify-self:start}   /* « ‹ Gestion » (master, 17/11) : sa propre rangée */
  /* Un élément vide (message, bandeau masqué) ne prend pas de case de la grille. */
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres)>:empty{display:none}
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres)>.adm-unites:has(.sec-row:nth-child(n+4)){grid-column:1/-1}
}
@media (min-width:1680px){
  #app:has(>.mo-fhead){--blocs-cols:3;grid-template-columns:repeat(3,minmax(0,1fr))}
  body[data-espace="Gérant"] #app:has(>.page-head.blocs-parametres){grid-template-columns:repeat(3,minmax(0,1fr))}
  /* Pilotage : trois petites cartes au sein d'une colonne transversale seulement.
     Graphiques et tableaux gardent le gabarit a deux colonnes du lot 3d. */
  .pv-page.pv-gabarit>.pv-col-seule{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;align-items:start}
  .pv-page.pv-gabarit>.pv-col-seule>*{grid-column:1/-1;min-width:0}
  .pv-page.pv-gabarit>.pv-col-seule>:is(.pv-ch,.pv-trio){grid-column:auto;margin:0}
}

/* ===== Fiche à côté, grand écran (17/11, Mahonri : « plus à 1920 ») ===== */
/* Dès 1680 px, un écran tableau + fiche quitte la largeur de travail de 1 280 px (jusqu'à 1 600) et la fiche prend 60 %. */
@media (min-width:1680px){
  #app:has(.tf){max-width:calc(1600px + 2*var(--marge))}
  .tf.avec-fiche{grid-template-columns:minmax(0,40fr) minmax(560px,60fr)}
}
