/* Navigation mobile / WebView APK — complète styles.css (chargé en dernier) */

@media (max-width: 900px) {
    /* Pendant le boot, aucune animation (évite le flash largeur/transform au chargement) */
    body.sidebar-booting.afa-mobile-nav-active .sidebar,
    body.sidebar-booting.afa-mobile-nav-active .afa-mobile-backdrop {
        transition: none !important;
    }

    body.sidebar-booting.afa-mobile-nav-active .container {
        transition: none !important;
    }

    body.afa-mobile-nav-active .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(300px, 90vw);
        max-width: none;
        transform: translateX(-100%);
        z-index: 200;
        transition: transform 0.22s ease;
        box-shadow: none;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    body.afa-mobile-nav-active.afa-drawer-open .sidebar {
        transform: translateX(0);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.22);
    }

    body.afa-mobile-nav-active .sidebar .label {
        display: inline;
    }

    body.afa-mobile-nav-active .afa-mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(6, 6, 15, 0.72);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        border: 0;
        padding: 0;
        margin: 0;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    body.afa-mobile-nav-active.afa-drawer-open .afa-mobile-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.afa-mobile-nav-active .container {
        margin-left: 14px !important;
        margin-right: 14px !important;
        width: auto !important;
        max-width: 100%;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    body.afa-mobile-nav-active .sidebar-toggle {
        display: none;
    }

    .afa-mobile-fab-menu {
        display: none;
        position: fixed;
        top: calc(10px + env(safe-area-inset-top, 0px));
        left: calc(10px + env(safe-area-inset-left, 0px));
        z-index: 180;
        width: 48px;
        height: 48px;
        align-items: center;
        justify-content: center;
        border-radius: 14px;
        border: 0;
        background: var(--sidebar-bg);
        color: #e6eddc;
        box-shadow: var(--shadow);
        font-size: 1.35rem;
        line-height: 1;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    body.afa-mobile-nav-active .afa-mobile-fab-menu {
        display: flex;
    }

    body.afa-mobile-nav-active.afa-drawer-open .afa-mobile-fab-menu {
        opacity: 0;
        pointer-events: none;
    }

    .afa-mobile-bar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 170;
        min-height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        background: var(--sidebar-bg);
        border-top: 1px solid var(--sidebar-edge);
        box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45), 0 -1px 0 rgba(0, 229, 255, 0.15);
        justify-content: space-around;
        align-items: center;
        gap: 4px;
    }

    .afa-mobile-bar__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 48px;
        padding: 6px 4px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: #b8ecff;
        text-decoration: none;
        font-size: 0.65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        max-width: 88px;
    }

    .afa-mobile-bar__item:active,
    .afa-mobile-bar__item--active {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .afa-mobile-bar__item svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        fill: none;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .dashboard-tiles {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .dashboard-tile {
        min-height: 120px;
        padding: 16px 12px !important;
    }

    .dashboard-tile__icon {
        width: 40px !important;
        height: 40px !important;
    }

    .admin-tools--tiles {
        grid-template-columns: repeat(2, 1fr) !important;
        align-items: stretch;
    }

    /* Les <form> autour de Sauvegarde / Reset doivent occuper toute la cellule comme les boutons seuls */
    .admin-tools--tiles > form {
        display: flex;
        flex-direction: column;
        margin: 0;
        min-height: 0;
    }

    .admin-tools--tiles > form > .admin-tools__icon-btn {
        flex: 1 1 auto;
        min-height: 120px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Ne pas écraser les tuiles admin (sinon submit → 48px comme les filtres) */
    .admin-tools--tiles .admin-tools__icon-btn {
        min-height: 120px;
        padding: 10px 8px;
    }

    .results-filter input[type="text"],
    .results-filter input[type="email"],
    .results-filter input[type="password"],
    .results-filter input[type="number"],
    .results-filter select,
    .results-filter textarea {
        min-height: 48px;
        font-size: 16px;
    }

    .bulk-delete-submit button,
    .results-filter button[type="submit"],
    button[type="submit"]:not(.afa-mobile-bar__item):not(.admin-tools__icon-btn) {
        min-height: 48px;
        padding: 12px 18px;
    }

    /* Infos participants : recherche pleine largeur utile */
    .participants-search {
        max-width: none;
        margin-left: 0;
        margin-right: 0;
    }

    .participant-edit-card__field input[type="text"],
    .participant-edit-card__field input[type="email"] {
        min-height: 44px;
        font-size: 16px;
        box-sizing: border-box;
    }

    .participant-edit-card__field input[type="email"] {
        padding-right: 2.75rem;
    }

    .participants-edit-toolbar select {
        min-height: 48px;
        font-size: 16px;
    }

    /* Dashboard + Résultats : tableaux contenus dans la largeur (pas de scroll horizontal) */
    .results-table-scroll {
        overflow-x: visible;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .results-table-scroll .results-table,
    .dashboard-card > .results-table {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100%;
        table-layout: fixed;
    }

    .results-table-scroll .results-table th,
    .results-table-scroll .results-table td,
    .dashboard-card > .results-table th,
    .dashboard-card > .results-table td {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        padding: 5px 4px;
        font-size: 0.76rem;
        line-height: 1.25;
        vertical-align: top;
    }

    .results-table--cols-2 th:nth-child(1),
    .results-table--cols-2 td:nth-child(1) {
        width: 58%;
    }

    .results-table--cols-2 th:nth-child(2),
    .results-table--cols-2 td:nth-child(2) {
        width: 42%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-6 th:nth-child(1),
    .results-table--cols-6 td:nth-child(1) {
        width: 7%;
        text-align: center;
    }

    .results-table--cols-6 th:nth-child(2),
    .results-table--cols-6 td:nth-child(2) {
        width: 20%;
    }

    .results-table--cols-6 th:nth-child(3),
    .results-table--cols-6 td:nth-child(3) {
        width: 20%;
    }

    .results-table--cols-6 th:nth-child(4),
    .results-table--cols-6 td:nth-child(4) {
        width: 13%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-6 th:nth-child(5),
    .results-table--cols-6 td:nth-child(5) {
        width: 17%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-6 th:nth-child(6),
    .results-table--cols-6 td:nth-child(6) {
        width: 13%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-7 th:nth-child(1),
    .results-table--cols-7 td:nth-child(1) {
        width: 7%;
        text-align: center;
    }

    .results-table--cols-7 th:nth-child(2),
    .results-table--cols-7 td:nth-child(2) {
        width: 8%;
        text-align: center;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-7 th:nth-child(3),
    .results-table--cols-7 td:nth-child(3) {
        width: 18%;
    }

    .results-table--cols-7 th:nth-child(4),
    .results-table--cols-7 td:nth-child(4) {
        width: 18%;
    }

    .results-table--cols-7 th:nth-child(5),
    .results-table--cols-7 td:nth-child(5) {
        width: 12%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-7 th:nth-child(6),
    .results-table--cols-7 td:nth-child(6) {
        width: 15%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .results-table--cols-7 th:nth-child(7),
    .results-table--cols-7 td:nth-child(7) {
        width: 12%;
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    th.th-tir-cible-manque {
        max-width: none;
        padding-left: 2px;
        padding-right: 2px;
    }
}

@media (min-width: 901px) {
    .afa-mobile-bar,
    .afa-mobile-backdrop,
    .afa-mobile-fab-menu {
        display: none !important;
    }
}

@media (max-width: 900px) {
    .auth-login input[type="text"],
    .auth-login input[type="email"],
    .auth-login input[type="password"],
    .auth-login button[type="submit"] {
        min-height: 48px;
        font-size: 16px;
    }
}
