/* =====================================================================
   v73 — Version téléphone (≤ 820 px) : chargée en DERNIER sur tout le site
   - Espace agents : en-tête compact sur une ligne, barre de navigation en bas
     (Accueil · Service · Canal · Dossier · Menu), menu complet en tiroir.
   - Partout : champs à 16 px (pas de zoom iOS), cibles tactiles ≥ 40 px,
     textes minuscules relevés, formulaires : actions après le formulaire.
   ===================================================================== */

/* La barre du bas et le voile n'existent que sur téléphone */
.m73-barre, .m73-voile, .m73-tiroir-tete { display: none; }

@media (max-width: 820px) {
  :root { --m73-barre: 62px; --m73-sur: env(safe-area-inset-bottom, 0px); }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: rgba(56, 189, 248, .18); }

  /* ---------- champs : 16 px minimum = pas de zoom automatique sur iPhone */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=hidden]), select, textarea { font-size: 16px !important; }
  input[type=checkbox], input[type=radio] { min-width: 20px; min-height: 20px; }

  /* ---------- cibles tactiles */
  .btn, .btn-mini, .dv-btn, .dv-btn.petit, .pvf-bouton, .proc-dl, .tdb-lien, .tr67-ajout, .intra-main button:not(.hud-theme):not(.hud-palette),
  .avis-filtres a, .sous-onglets a, .cit-filtres a, .enq-filtres button, .bareme-filtres button, .ftm-sommaire a, .ftm-filtres button,
  .svc-b-actions a, .pontb-actions a, .pontb-actions button, .mir-copier, .pvf-fil a, .dv-fil a, .lec-retour, .recru-lien, .cp-pdf {
    min-height: 40px; }
  .btn-mini, .tdb-lien, .tr67-ajout, .svc-b-actions a, .pvf-fil a, .dv-fil a, .lec-retour, .recru-lien, .cp-pdf, .ftm-lien-div, .proc-dl {
    display: inline-flex; align-items: center; }
  .intra-main summary, .mini-action summary, .paie-bareme summary, .procedures-aide summary { min-height: 40px; display: flex; align-items: center; }
  .pvf-pastille, label.pvf-pastille { min-height: 44px; }
  .pvf-pastille span { min-height: 42px; display: inline-flex; align-items: center; }
  .dv-manuel .dv-btn { min-height: 42px; padding-inline: 18px; }
  .psdp-codes button { min-height: 36px; min-width: 44px; font-size: .8rem; }
  .psdp-voir { min-height: 36px; padding: 6px 10px; }
  .cp-ancre { display: inline-block; padding: 8px 4px; }
  .footer-links a { display: inline-block; padding: 8px 6px; }
  .doc-carte a { display: inline-block; padding: 4px 0; }

  /* notes 1 à 5 (FTER, examens) : boutons larges, faciles au pouce */
  .ftor-notes { display: grid !important; grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .ftor-note { width: 100%; }
  .ftor-note span { width: 100% !important; height: 46px !important; font-size: 1.05rem; }
  .ftor-crit { grid-template-columns: 1fr !important; }

  /* ---------- textes trop petits : plancher à 12 px */
  .dv-man-type, .dvh-sigle, .dvh-recru, .eff-nom small, .dossier-bloc .lbl, .pvf-titre-carte, .pvf-entete-titre small, .fx-code, .statut-d,
  .div-poste, .dv-noeud small, .fto-phase small, .so67-legende i, .eff-legende span, .palier-barre i, .hub-piste-txt, .dc-num small,
  .inf-tete .inf-proc, .man-type, .bul-org, .psdp-acces small, .hub-defcon-badge small, .dc-hero-badge small, .dca-badge small, .fo-compte,
  .intra-main dt, .intra-main th, .staff-pont small, .staff-pont code, .grade em, .dc-bot { font-size: max(12px, .75rem) !important; }
  .intra-main small { font-size: max(12px, .8em); }

  /* ---------- tableaux : défilement horizontal au lieu de déborder */
  .doc-table, .pvf-table, .table-wrap, .paie-table, .tab-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---------- formulaires longs : le panneau d'actions passe APRÈS le formulaire */
  .pvf-panneau { order: 2 !important; position: static; }
  .pvf-grille > * { min-width: 0; }

  /* ---------- toasts au-dessus de la barre du bas */
  .ui-toasts { left: 12px; right: 12px; bottom: calc(var(--m73-barre) + var(--m73-sur) + 12px); max-width: none; }

  /* =================================================================
     ESPACE AGENTS
     ================================================================= */
  body.intranet { padding-bottom: calc(var(--m73-barre) + var(--m73-sur)); }

  /* En-tête compact : une seule ligne */
  .intra-top { flex-wrap: nowrap !important; gap: 8px; min-height: 56px; padding: 6px 12px !important; padding-top: max(6px, env(safe-area-inset-top)) !important; }
  .intra-top .intra-brand { flex: 1 1 auto; min-width: 0; }
  .intra-top .intra-banniere { height: 38px; width: auto; }
  .intra-top .intra-espace { display: none; }
  .intra-top .hud { order: 2 !important; flex: none !important; flex-basis: auto !important; margin: 0 !important; gap: 6px; }
  .intra-top .hud-bloc { display: none !important; }
  .intra-top .hud-palette { width: 42px; height: 42px; padding: 0; justify-content: center; }
  .intra-top .hud-palette span, .intra-top .hud-palette kbd { display: none !important; }
  .intra-top .hud-theme { width: 42px; height: 42px; }
  .intra-top .intra-user { order: 3; flex: none; gap: 0; }
  .intra-top .intra-user-txt, .intra-top .intra-user form { display: none; }
  .intra-top .intra-insigne { height: 34px; width: auto; }

  /* Le menu devient un tiroir qui monte du bas */
  .intra-nav.nav67 { position: fixed !important; left: 0; right: 0; bottom: 0; top: auto; z-index: 95; height: min(86vh, 760px); height: min(86dvh, 760px);
    padding: 0 0 calc(var(--m73-barre) + var(--m73-sur)) !important; border-radius: 20px 20px 0 0; transform: translateY(105%); visibility: hidden;
    transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s linear .28s; box-shadow: 0 -20px 50px -10px rgba(0,0,0,.7);
    display: flex; flex-direction: column; overflow: hidden; border-top: 1px solid rgba(148,178,230,.25); }
  .intra-nav.nav67.ouvert { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .nav67 .nav67-mobile { display: none !important; }
  .nav67 .nav67-corps, .nav67.ouvert .nav67-corps { display: flex !important; flex: 1 1 auto; max-height: none !important; overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px 16px !important; }
  .nav67 .nav67-liens > a, .nav67 .nav67-liens > .soon, .nav67 .nav67-corps > a.nav67-pied { min-height: 46px; padding: 10px 12px !important; font-size: .98rem; }
  .nav67 .nav67-titre { min-height: 44px; }
  .m73-tiroir-tete { display: flex; align-items: center; gap: 12px; padding: 10px 16px 12px; border-bottom: 1px solid rgba(148,178,230,.15); flex: none; position: relative; }
  .m73-tiroir-tete::before { content: ""; position: absolute; top: 6px; left: 50%; width: 44px; height: 4px; margin-left: -22px; border-radius: 4px; background: rgba(148,178,230,.35); }
  .m73-tiroir-tete img { height: 40px; width: auto; flex: none; margin-top: 8px; }
  .m73-tiroir-tete div { flex: 1 1 auto; min-width: 0; margin-top: 8px; }
  .m73-tiroir-tete strong { display: block; color: #fff; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m73-tiroir-tete small { display: block; color: #9fb0c8; font-size: .82rem; }
  .m73-tiroir-tete form { margin: 8px 0 0; }
  .m73-tiroir-tete .intra-logout { min-height: 40px; padding: 0 12px; color: #e6edf8 !important; border: 1px solid rgba(148,178,230,.3) !important; background: transparent !important; }
  .m73-fermer { margin-top: 8px; width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(148,178,230,.25); background: rgba(255,255,255,.05); color: #e6edf8; font-size: 1.3rem; line-height: 1; cursor: pointer; }
  .m73-voile { display: block; position: fixed; inset: 0; z-index: 94; background: rgba(2, 6, 14, .6); opacity: 0; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(2px); }
  body.m73-ouvert .m73-voile { opacity: 1; pointer-events: auto; }
  body.m73-ouvert { overflow: hidden; }

  /* Barre de navigation du bas */
  .m73-barre { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 96;
    height: calc(var(--m73-barre) + var(--m73-sur)); padding-bottom: var(--m73-sur);
    background: rgba(9, 15, 28, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid rgba(148,178,230,.22); }
  .m73-barre a, .m73-barre button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 0; font-size: .74rem !important;
    border: 0; background: none; color: #8fa3bf; font: 600 .7rem/1.1 var(--police, "Inter", sans-serif); letter-spacing: .02em; text-decoration: none; cursor: pointer; padding: 6px 2px; }
  .m73-barre svg { width: 24px !important; height: 24px !important; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .m73-barre [aria-current="page"], .m73-barre button[aria-expanded="true"] { color: #fff; }
  .m73-barre [aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--neon, #38bdf8); }
  .m73-barre b { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #e5484d; color: #fff; font-size: .65rem; line-height: 17px; text-align: center; }
  .intra-main { padding-bottom: 12px; }
  .obs-bandeau { bottom: calc(var(--m73-barre) + var(--m73-sur) + 10px) !important; }

  /* Onglets Staff / RH : défilement horizontal au doigt */
  .so67 { scroll-snap-type: x proximity; }
  .so67 > a { scroll-snap-align: start; }

  /* =================================================================
     SITE PUBLIC
     ================================================================= */
  .site-header-inner { flex-wrap: nowrap !important; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .site-brand { min-width: 0; flex: 1 1 auto; }
  .site-banniere { height: 40px; width: auto; }
  .site-serveur { display: none; }
  .site-nav { flex-wrap: nowrap !important; align-items: center; gap: 6px; }
  .site-nav a { white-space: nowrap; min-height: 40px; display: inline-flex; align-items: center; padding: 0 12px; }
  .site-nav .hud-theme { width: 40px; height: 40px; margin: 0; }
  /* carrousel d'accueil : pistes défilantes lisibles */
  .hub-pistes { display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding-bottom: 6px; scrollbar-width: none; }
  .hub-pistes::-webkit-scrollbar { display: none; }
  .hub-piste { flex: 0 0 auto; min-height: 42px; scroll-snap-align: center; }
  .hub-piste-txt { font-size: .74rem !important; }
}

/* très petits écrans (≤ 380 px) */
@media (max-width: 380px) {
  .intra-top .intra-banniere { height: 32px; }
  .m73-barre a, .m73-barre button { font-size: .64rem; }
  .site-banniere { height: 34px; }
  .site-nav a { padding: 0 9px; font-size: .78rem; }
}

/* application installée (écran d'accueil) : pas de coupure sous l'encoche */
@media (display-mode: standalone) {
  .intra-top, .site-header { padding-top: max(6px, env(safe-area-inset-top)); }
}

/* v73 : compléments cibles tactiles (sommaires, liens de division) */
@media (max-width: 820px) {
  .lec-toc-liste a, .cp-sommaire-lat nav a { display: block; min-height: 40px; padding-top: 9px !important; padding-bottom: 9px !important; }
  .ftm-lien-div, .obs-bandeau a, .obs-fermer { min-height: 40px; }
  .doc-carte a { min-height: 32px; }
}
@media (max-width: 820px) {
  .m73-barre button { margin: 0 !important; padding: 6px 2px !important; line-height: 1.1 !important; min-height: 0 !important; }
  /* compteurs : deux par ligne au lieu d'une colonne de grandes cartes */
  .staff-resume, .compteurs, .compteurs.cinq { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  .staff-resume .compteur, .compteurs .compteur { padding: 12px 14px !important; min-height: 0; }
  .staff-resume .compteur strong, .compteurs .compteur strong { font-size: 1.5rem; }
}
@media (max-width: 820px) {
  /* site public : le logo mène déjà à l'accueil — le lien « ← Accueil » chevauchait la bannière */
  .site-nav a[href="/"] { display: none; }
  .inf-details em, .inf-tete .inf-proc { font-size: 12px !important; }
}
@media (max-width: 820px) {
  .mini-action form { min-width: 0; flex-wrap: wrap; }
  .mini-action form input { flex: 1 1 160px; min-width: 0; }
  .recru-etapes { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .recru-etapes li { padding: 12px 14px; min-width: 0; }
  .recru-etapes li:not(:last-child)::after { display: none; }
  .dv-sommaire { top: 62px; }
}
/* v172 : appli mobile — PDF (iOS n'affiche que la 1re page d'un PDF intégré → boutons « Ouvrir » / « Télécharger »),
   fond figé sous le menu, cibles tactiles ≥ 40 px, contraste de la barre du bas en thème clair */
@media (max-width: 820px) {
  .pvr-apercu { display: none; }
  html.m73-ouvert { overflow: hidden; }
  .mes-espaces > summary { min-height: 40px; }
  .app-fermer { width: 42px; height: 42px; }
  .psdp-codes button, .psdp-voir, .doc-carte a { min-height: 40px; }
}
:root[data-theme="clair"] .m73-barre.app-barre a:not([aria-current="page"]), :root[data-theme="clair"] .m73-barre.app-barre button:not([aria-current="page"]) { color: #475569; }
