/* ============================================================
   Navigation adaptative (Phase 1b)
   - Desktop  (> 1024px) : pilules en haut (inchangé).
   - Tablette (701–1024) : rail vertical d'icônes + libellés à gauche, toujours visible.
   - Téléphone (≤ 700)   : tiroir latéral qui glisse derrière le burger (état React `.is-open` sur .navx).
   Dropdowns (Véhicules/Gestion) : accordéon inline en rail/tiroir. Pilule dorée « Extension » gardée distincte.
   ============================================================ */

/* Desktop : le wrapper ne crée pas de boîte → le panneau participe au flex du topbar comme l'ancienne nav. */
.navx { display: contents; }
.navx-burger { display: none; background: none; border: 0; padding: 0; color: #1f2a3d; cursor: pointer; }
.navx-scrim { display: none; }
.navx-ico { display: none; }                /* icônes seulement en rail/tiroir */
.navx-caret { margin-left: 2px; opacity: 0.7; transition: transform var(--ux-dur-fast) var(--ux-ease); }

/* ===================== TABLETTE — RAIL =====================
   `pointer: coarse` : le rail ne s'applique qu'aux écrans TACTILES (vraies tablettes). Une fenêtre de
   navigateur DESKTOP étroite (701–1024) garde les pilules du haut (topbar flex scrollable de showcase-interface.css). */
@media (min-width: 701px) and (max-width: 1024px) and (pointer: coarse) {
  .app-shell .showcase-topbar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 208px; height: 100vh; z-index: 200;
    background: #fff; border-right: 0.5px solid #e6e9ef;
    transform: none !important; transition: none;
  }
  .app-shell .showcase-topbar.is-hidden { transform: none !important; }
  .app-shell .showcase-topbar-inner {
    flex-direction: column; align-items: stretch;
    height: 100%; gap: 6px; padding: 16px 12px; overflow-y: auto;
  }
  .app-shell .showcase-brand { flex: 0 0 auto; margin: 0 0 8px; justify-content: flex-start; }
  .app-shell .showcase-brand .brand-logo { height: 42px; }

  .navx-panel { flex-direction: column; align-items: stretch; gap: 4px; flex: 1 1 auto; flex-wrap: nowrap; align-self: stretch; }
  .navx-ico { display: inline-flex; flex: 0 0 auto; }
  .navx-panel .nav2-pill { width: 100%; justify-content: flex-start; gap: 11px; padding: 11px 13px; border-radius: 12px; font-size: 14.5px; }
  .navx-panel .navx-label { flex: 1 1 auto; }
  .navx-panel .nav2-drop > summary .navx-caret { margin-left: auto; }
  .navx-panel .nav2-drop[open] > summary .navx-caret { transform: rotate(180deg); }

  /* Dropdowns en accordéon inline. */
  .navx-panel .nav2-drop { width: 100%; }
  .navx-panel .nav2-panel { position: static; box-shadow: none; border: 0; background: transparent; padding: 2px 0 6px 8px; margin: 0; width: 100%; min-width: 0; animation: none; }
  .navx-panel .veh-menu { display: flex; flex-direction: column; gap: 8px; }
  .navx-panel .veh-cats { flex-wrap: wrap; gap: 5px; }
  .navx-panel .veh-tiles { display: flex; flex-direction: column; gap: 3px; grid-template-columns: none; }
  .navx-panel .veh-tile { width: 100%; }
  .navx-panel .nav2-menu { display: flex; flex-direction: column; gap: 2px; }

  .app-shell .showcase-topbar-inner > .account-menu { margin-top: auto; }

  /* Le contenu se décale à droite du rail. */
  .app-shell > .stage { margin-left: 208px; }
}

/* ===================== TÉLÉPHONE — TIROIR ===================== */
@media (max-width: 700px) {
  /* Le topbar crée un BLOC ENGLOBANT (backdrop-filter + will-change:transform) qui casserait le `position:fixed`
     du tiroir (il se calerait sur le topbar, pas le viewport). On neutralise les deux sur téléphone + fond solide.
     Le tiroir ne s'ouvre qu'en haut de page (transform identité) avec verrou de scroll (AppNav). */
  .app-shell .showcase-topbar { will-change: auto; backdrop-filter: none; -webkit-backdrop-filter: none; background: #fff; }
  .navx { display: block; order: -1; }
  .navx-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 12px;
  }
  .app-shell .showcase-topbar-inner { align-items: center; }
  .app-shell .showcase-topbar-inner > .account-menu { order: 2; margin-left: auto; }
  .app-shell .showcase-brand { order: 1; }

  /* Voile : overlay réel cliquable (ferme le tiroir via onClick d'AppNav). */
  .navx-scrim {
    display: block; position: fixed; inset: 0; z-index: 300;
    background: rgba(12, 22, 44, 0.42);
    opacity: 0; pointer-events: none;
    transition: opacity var(--ux-dur) var(--ux-ease);
  }
  .navx-scrim.is-open { opacity: 1; pointer-events: auto; }

  /* Panneau = tiroir off-canvas qui glisse depuis la gauche. */
  .navx-panel {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(84vw, 320px); z-index: 320;
    background: #fff; border-right: 0.5px solid #e6e9ef;
    box-shadow: 18px 0 50px rgba(8, 20, 45, 0.18);
    flex-direction: column; align-items: stretch; gap: 4px; flex-wrap: nowrap; align-self: stretch;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto;
    transform: translateX(-102%); transition: transform var(--ux-dur-slow) var(--ux-ease);
    will-change: transform;
  }
  .navx-panel.is-open { transform: translateX(0); }

  .navx-ico { display: inline-flex; flex: 0 0 auto; }
  .navx-panel .nav2-pill { width: 100%; justify-content: flex-start; gap: 12px; padding: 13px 14px; border-radius: 12px; font-size: 15.5px; }
  .navx-panel .navx-label { flex: 1 1 auto; }
  .navx-panel .nav2-drop > summary .navx-caret { margin-left: auto; }
  .navx-panel .nav2-drop[open] > summary .navx-caret { transform: rotate(180deg); }
  .navx-panel .nav2-drop { width: 100%; }
  .navx-panel .nav2-panel { position: static; box-shadow: none; border: 0; background: transparent; padding: 2px 0 6px 8px; margin: 0; width: 100%; min-width: 0; animation: none; }
  .navx-panel .veh-menu { display: flex; flex-direction: column; gap: 8px; }
  .navx-panel .veh-cats { flex-wrap: wrap; gap: 5px; }
  .navx-panel .veh-tiles { display: flex; flex-direction: column; gap: 3px; grid-template-columns: none; }
  .navx-panel .veh-tile { width: 100%; }
  .navx-panel .nav2-menu { display: flex; flex-direction: column; gap: 2px; }
}

/* ===================== BARRE D'ACTION COLLANTE (débrief / fiche, Phase 1c) =====================
   Portalisée au <body> (StudentDossier). L'action primaire reste dans la zone du pouce sur mobile/tablette,
   pour ne pas avoir à remonter en haut après avoir validé les compétences. Masquée sur desktop. */
.sd-actionbar { display: none; }
@media (max-width: 1024px) and (pointer: coarse) {
  .sd-actionbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 180;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    border-top: 0.5px solid #e6e9ef;
    box-shadow: 0 -10px 30px rgba(8, 20, 45, 0.10);
    animation: ux-rise var(--ux-dur) var(--ux-ease) both;
  }
  .sd-actionbar-name { flex: 1 1 auto; min-width: 0; font-weight: 800; font-size: 14px; color: #16243e; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sd-actionbar .showcase-btn { flex: 0 0 auto; min-height: 48px; }
  /* Réserve de la place en bas pour ne pas masquer le dernier contenu de la fiche derrière la barre fixe. */
  .sd-body.has-actionbar { padding-bottom: 84px; }
  /* L'action vit dans la barre collante → on masque le bouton inline du panneau (évite le doublon). */
  .sd-debrief-actions { display: none; }
}
@media (min-width: 701px) and (max-width: 1024px) and (pointer: coarse) {
  .sd-actionbar { left: 208px; } /* après le rail tablette (tactile) */
}

/* ===================== PLANNING — VUE JOUR TÉLÉPHONE =====================
   La grille hebdo 7 colonnes est illisible sur ~393px → sélecteur de 7 pastilles + grille d'UN jour pleine largeur. */
.pl-daychips { display: none; }
@media (max-width: 700px) {
  .pl-daychips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 4px 0 10px; }
  .pl-daychip { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px; border: 0.5px solid #e3e7ee; border-radius: 11px; background: #fff; cursor: pointer; min-height: 50px; }
  .pl-daychip .pl-dow { font-size: 10px; font-weight: 700; color: #8a929d; text-transform: uppercase; }
  .pl-daychip .pl-dom { font-size: 16px; font-weight: 800; color: #16243e; line-height: 1.1; }
  .pl-daychip.is-today:not(.is-on) { border-color: #1879ff; }
  .pl-daychip.is-today:not(.is-on) .pl-dom { color: #1879ff; }
  .pl-daychip.is-on { background: #1879ff; border-color: #1879ff; box-shadow: 0 4px 12px rgba(24, 121, 255, 0.28); }
  .pl-daychip.is-on .pl-dow, .pl-daychip.is-on .pl-dom { color: #fff; }
  /* Sélecteur de MONITEUR (vue « Par moniteur ») : rangée de pastilles en SCROLL horizontal (1 ligne).
     Classe distincte de `.pl-monchips` des FILTRES (qui restent nowrap, planning.css) — pas de collision. */
  .pl-monpick { display: flex; flex-wrap: nowrap; gap: 6px; margin: 4px 0 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .pl-monpick .pl-daychip { flex: 0 0 auto; min-width: 0; min-height: 44px; padding: 8px 13px; }
  .pl-monpick .pl-daychip .pl-dom { font-size: 13.5px; white-space: nowrap; }
}

/* ===================== BOTTOM SHEETS (Phase 2) =====================
   Sur téléphone, les modales centrées deviennent des FEUILLES qui montent du bas (zone du pouce),
   pleine largeur, coins arrondis en haut, poignée de glissement + slide-up. */
@keyframes ux-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 700px) {
  .pl-modal-overlay, .mc-popup-overlay, .smgr-modal-overlay { place-items: end center; padding: 0; }
  .pl-modal, .mc-popup, .smgr-modal {
    width: 100%; max-width: 100%; max-height: 92vh; overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
    animation: ux-sheet-up var(--ux-dur-slow) var(--ux-ease) both;
  }
  .pl-modal::before, .mc-popup::before, .smgr-modal::before {
    content: ""; display: block; width: 40px; height: 4px; border-radius: 999px;
    background: #d4d8e0; margin: 0 auto 14px;
  }
  /* Un scroll qui atteint le bout d'une feuille / du tiroir ne fait pas défiler le fond. */
  .navx-panel, .pl-modal, .mc-popup, .smgr-modal { overscroll-behavior: contain; }
}

/* ===================== FAB « + » PLANNING (téléphone, Phase 3) ===================== */
.pl-fab { display: none; }
@media (max-width: 700px) {
  .pl-fab {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 999px; border: 0;
    background: #1879ff; color: #fff; z-index: 190; cursor: pointer;
    box-shadow: 0 10px 26px rgba(24, 121, 255, 0.42);
    animation: ux-pop var(--ux-dur) var(--ux-ease-spring) both;
  }
  .pl-fab:active { transform: scale(0.94); }
}
