/* Phone layout only. Desktop planning density and business rules stay unchanged. */
.navbar-menu-toggle { display: none; }

@media (max-width: 639px) {
  body .navbar[data-mobile-menu-ready] {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px max(12px, env(safe-area-inset-left));
  }
  body .navbar[data-mobile-menu-ready] .navbar-title { justify-content: flex-start; font-size: 20px; }
  body .navbar[data-mobile-menu-ready] .navbar-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 76px;
    padding: 8px 14px;
    border: 1px solid currentColor;
    border-radius: 10px;
    font: inherit;
    font-weight: 600;
    color: inherit;
    background: transparent;
  }
  body .navbar[data-mobile-menu-ready] .navbar-links {
    flex-basis: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding-top: 6px;
  }
  body .navbar[data-menu-open="false"] .navbar-links { display: none; }
  body .navbar .navbar-links .navbar-link { min-height: 44px; margin: 0; text-align: center; }
  body .navbar :focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
  body.dashboard-page .page-title, body.dashboard-page #titre-semaine.page-title, body.dashboard-page #titre-semestrielle.page-title { font-size: 22px; line-height: 1.25; margin-bottom: 12px; overflow-wrap: anywhere; }
  body.dashboard-page main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]), select, textarea) {
    font-size: 16px !important;
  }
  body :is(.popup-btn, .action-add-btn, .account-button, .profile-copy, .profile-close, .request-mobile-nav button, .request-validation-tabs button, .request-item-actions button, .history-pagination button) {
    min-height: 44px;
  }
  body .popup-root.popup-overlay, body.formation-page #formation-modal { padding: 12px; width: 100vw; max-width: 100vw; height: 100dvh; }
  body .popup-root.popup-overlay > div, body.formation-page #bloc-formation-modal {
    max-height: calc(100dvh - 24px);
    min-width: 0;
    max-width: calc(100vw - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-top: 0;
    margin-bottom: 0;
  }
  body :is(#modal-close, #close-modal, .hebdo-dialog-close, .tds-noel-close, .popup-root button[aria-label="Fermer"]) {
    min-width: 44px;
    min-height: 44px;
  }
  body.hebdo-page .hebdo-dialog { padding: 20px 16px; }
  body.hebdo-page .hebdo-dialog-close { flex-basis: 44px; }
  body.semestrielle-page .popup-root:not(.popup-overlay) {
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    width: calc(100% - 24px) !important;
    max-width: none;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: none !important;
  }
  body.semestrielle-page .popup-root:not(.popup-overlay) > h2 { padding-inline: 28px; }
  body.hebdo-page #week-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  body.hebdo-page #week-group :is(#btn-prev, #btn-next),
  body.hebdo-page .hebdo-nav .filtre-btn,
  body.hebdo-page .hebdo-back-link { min-height: 44px; }
  body.hebdo-page #planning-container .hebdo-table-main,
  body.semestrielle-page .semestrielle-table-frame .semestrielle-table-main { overflow: visible; }
  body.hebdo-page .hebdo-table-main :is(th, td):first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 108px;
    width: 108px;
    padding-inline: 8px;
    font-size: 13px;
  }
  body.hebdo-page .hebdo-table-main :is(th, td):first-child::after {
    content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 1px; background: #64748b;
  }
  body.semestrielle-page {
    --sem-ui-scale: 1;
    --sem-row-scale: 1;
    --sem-table-font: 12px;
    --sem-month-font: 10px;
    --sem-badge-font: 11px;
    --sem-left-col-w: 128px;
    --sem-week-link-min-h: 32px;
  }
  body.semestrielle-page main { padding: 8px 10px 24px; }
  body.semestrielle-page main > .container-main { padding: 0 !important; overflow: visible; }
  body.semestrielle-page .semestrielle-table-shell { width: 100%; }
  body.semestrielle-page .semestrielle-table-frame {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.semestrielle-page .semestrielle-table-main { max-width: none; }
  body.semestrielle-page :is(#months-header, #weeks-header, #table-body-semestrielle tr:not(.separation-row)) > :first-child {
    position: sticky;
    left: 0;
    z-index: 3;
  }
  body.semestrielle-page .semestre-nav-row {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    width: 100%;
    gap: 4px;
  }
  body.semestrielle-page .filtre-groupe-semestre { justify-self: center; flex-wrap: nowrap; gap: 4px; min-width: 0; }
  body.semestrielle-page .filtre-groupe-semestre .filtre-btn { flex: 1; min-width: 0; font-size: 11px; padding-inline: 4px; }
  body.semestrielle-page :is(.semestrielle-topbar, .semestrielle-table-actions) :is(.filtre-btn, button) { min-height: 44px; }
  body.semestrielle-page .semestrielle-topbar .chevron-btn { width: 44px; height: 44px; }
  body.semestrielle-page .semestrielle-table-actions-right { flex-wrap: wrap; }
  body.semestrielle-page .semestrielle-table-actions-right { gap: 6px !important; }
  body.semestrielle-page .semestrielle-table-actions-right .tds-action-button { font-size: 11px; padding-inline: 7px; }
  body.semestrielle-page .tds-agent-cell-content { flex-direction: column; gap: 4px; }
  body.semestrielle-page .tds-counter-label { font-size: 9px; }
  body.semestrielle-page .tds-counter-value { font-size: 11px; }
  body.semestrielle-page #boutons-section-semestre { margin-bottom: 12px; }
  body.formation-page #bloc-liste-formations { -webkit-overflow-scrolling: touch; }
  body.formation-page #admin-users-table .formation-cell-actions button { min-height: 44px; }
  body .request-item > button { min-height: 44px; min-width: 44px; }

  body.formation-page #bloc-liste-formations { overflow: hidden; border-radius: 12px; box-shadow: none; }
  body.formation-page #admin-users-table { display: block; min-width: 0; width: 100%; background: transparent; box-shadow: none; }
  body.formation-page #admin-users-table colgroup { display: none; }
  body.formation-page #admin-users-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body.formation-page #table-formations { display: block; }
  body.formation-page #table-formations tr { display: block; }
  body.formation-page #table-formations tr:not(.formation-group-row):not(.formation-empty-row) {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px;
    padding: 14px; margin-block: 8px 16px; border: 1px solid #64748b; border-radius: 12px;
  }
  body.formation-page #table-formations td { display: block; width: auto; min-width: 0; max-width: none; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  body.formation-page #table-formations td[class*="formation-cell-"] { padding: 0 !important; }
  body.formation-page #table-formations :is(.formation-cell-subject, .formation-cell-actions) { grid-column: 1 / -1; }
  body.formation-page #table-formations td[class*="formation-cell-"]::before { display: block; margin-bottom: 4px; opacity: .8; font-size: 11px; font-weight: 500; }
  body.formation-page .formation-cell-date::before { content: "Date"; }
  body.formation-page .formation-cell-week::before { content: "Semaine"; }
  body.formation-page .formation-cell-subject::before { content: "Sujet"; }
  body.formation-page .formation-cell-formateur::before { content: "Formateur"; }
  body.formation-page .formation-cell-formes::before { content: "Formé(s)"; }
  body.formation-page .formation-cell-actions::before { content: "Actions"; }
  body.formation-page #table-formations tr:not(.formation-group-row):not(.formation-empty-row) > td { background: transparent; }
  body.formation-page #table-formations .formation-group-row td { border-radius: 12px; }
  body.formation-page .formation-actions { justify-content: flex-start; }
  body.formation-page .formation-actions button { min-width: 44px; }
  body.formation-page .formation-group-content { padding: 8px 0; }
  body.formation-page .formation-group-toggle { flex-wrap: wrap; padding: 8px 0; min-height: 44px; }
  body.formation-page .formation-group-toggle-action { white-space: normal; text-align: left; }
  body.formation-page .formation-group-toggle-action--placeholder { display: none; }

  body :is(.dropdown-toggle, .dropdown-item, .popup-fonction-bouton, .request-calendar-day, .formation-calendar-day) { min-height: 44px; }
  body.formation-page :is(.formation-group-label, .formation-group-toggle-label) { display: flex; gap: 8px; }
  body.formation-page .formation-group-title { width: auto; white-space: nowrap; }
  body.demandes-page #modal > div, body.formation-page #bloc-formation-modal { padding: 16px; }
  body.demandes-page #modal .w-fit, body.formation-page #formation-modal .w-fit { width: 100%; max-width: 100%; }
  body.demandes-page #modal .grid-cols-7, body.formation-page #formation-modal .grid-cols-7 { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  body.demandes-page #modal .grid-cols-7 > *, body.formation-page #formation-modal .grid-cols-7 > * { width: 100%; min-width: 0; }
}
