/* Jupiter Mobile Lists — listes en cartes sur téléphone (voir js/jupiter-mobile-lists.js).
 * Tout est limité à body.jmn-on (navigation mobile active) et ≤ 767 px : le bureau ne change pas. */

td.jl-more-cell {
    display: none;
}

@media (max-width: 767px) {
    /* ── Conteneurs : plus de défilement horizontal ni de largeur minimale ── */
    body.jmn-on #main .list-container .list:has(> table.jl-cards),
    body.jmn-on #main .sh-table-wrap:has(> table.jl-cards) {
        overflow: visible !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    body.jmn-on #main .list-container .list:has(> table.jl-cards),
    body.jmn-on #main .list-container .list:has(> table.jl-cards) > .show-more {
        width: auto !important;
        min-width: 0 !important;
    }

    body.jmn-on table.jl-cards {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0;
        border: 0 !important;
        background: transparent !important;
    }

    body.jmn-on table.jl-cards > thead {
        display: none;
    }

    body.jmn-on table.jl-cards > tbody {
        display: block;
    }

    /* ── La carte ── */
    body.jmn-on table.jl-cards > tbody > tr.jl-row {
        position: relative;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px 14px;
        margin: 0 0 10px;
        padding: 12px 14px;
        border: 1px solid var(--jt-border, #e3e9f2) !important;
        border-radius: var(--jt-radius-lg, 14px);
        background: var(--jt-surface, #fff) !important;
        box-shadow: var(--jt-shadow-xs, 0 1px 2px rgba(16, 24, 40, .05));
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row:hover {
        background: var(--jt-surface, #fff) !important;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td {
        display: block;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        text-align: left !important;
        white-space: normal !important;
        overflow: visible !important;
        overflow-wrap: anywhere;
        font-size: 13px;
        line-height: 1.35;
        position: static;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-check,
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-empty,
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-extra {
        display: none;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row.jl-open > td.jl-extra:not(.jl-empty) {
        display: block;
    }

    /* Contenu riche : toute la largeur, sans déborder de la carte */
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-wide {
        grid-column: 1 / -1;
        max-height: 60vh;
        overflow: auto !important;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-wide table,
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-wide img {
        max-width: 100% !important;
        height: auto;
    }

    /* Titre : toute la largeur, place réservée au menu ⋮ */
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-title {
        grid-column: 1 / -1;
        order: -1;
        padding-right: 34px !important;
        font-size: 15px;
        font-weight: 600;
        line-height: 1.3;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-title a {
        font-weight: 600;
    }

    /* Champ : libellé au-dessus de la valeur */
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-field::before {
        content: attr(data-jl-label);
        display: block;
        margin-bottom: 2px;
        color: var(--jt-text-3, #687387);
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .03em;
        text-transform: uppercase;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-field[data-jl-label=""]::before {
        display: none;
    }

    /* Menu ⋮ en haut à droite */
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-acts {
        position: absolute;
        top: 6px;
        right: 6px;
        width: auto !important;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-acts .list-row-buttons,
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-acts .btn-group {
        float: none !important;
    }

    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-acts .dropdown-toggle {
        min-width: 36px;
        min-height: 36px;
    }

    /* « + N champs » */
    body.jmn-on table.jl-cards > tbody > tr.jl-row > td.jl-more-cell {
        display: block;
        grid-column: 1 / -1;
    }

    body.jmn-on .jl-more {
        padding: 2px 0;
        border: 0;
        background: none;
        color: var(--jt-accent, #1a4fd6);
        font-size: 12.5px;
        font-weight: 600;
    }

    body.jmn-on .jl-more .jl-more-close,
    body.jmn-on tr.jl-open .jl-more .jl-more-open {
        display: none;
    }

    body.jmn-on tr.jl-open .jl-more .jl-more-close {
        display: inline;
    }

    /* Lignes hors carte (ex. « aucune donnée », « afficher plus ») : pleine largeur */
    body.jmn-on table.jl-cards > tbody > tr:not(.jl-row) {
        display: block;
    }

    body.jmn-on table.jl-cards > tbody > tr:not(.jl-row) > td {
        display: block;
        width: auto !important;
        border: 0 !important;
    }

    /* ── Listes Espo : barre de recherche ── */

    /* Le menu des filtres enregistrés (Tous, Perso…) n'affiche rien quand aucun n'est choisi :
       on lui donne une icône (signet) au lieu d'un « – » vide. */
    body.jmn-on #main .search-container .filters-button {
        min-width: 40px;
    }

    body.jmn-on #main .search-container .filters-button .filters-label:empty::before {
        content: "\f02e"; /* signet : filtres enregistrés (le bouton Filtrer garde l'entonnoir) */
        font-family: "Font Awesome 5 Free", "Font Awesome 6 Free", "FontAwesome";
        font-weight: 900;
        font-size: 13px;
    }

    body.jmn-on #main .search-container .filters-button .filters-label:empty + .caret {
        display: none;
    }

    /* Barre « Filtrer » qui ne contient que le bouton (aucun filtre appliqué, pas de raccourcis
       propres à la page) : plus de cadre vide, le bouton remonte sur la ligne de recherche
       (place réservée à droite du champ). */
    body.jmn-on #main.list-has-custom-filter-bar:has(.custom-filter-bar:has(.custom-applied-filters-wrap:empty):not(:has(> * > :not(.custom-applied-filters-wrap, .custom-filter-btn)))) .search-container .search-row > .form-group:first-child {
        padding-right: 60px;
    }

    body.jmn-on #main .custom-filter-bar:has(.custom-applied-filters-wrap:empty):not(:has(> * > :not(.custom-applied-filters-wrap, .custom-filter-btn))) {
        position: relative;
        height: 0;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    body.jmn-on #main .custom-filter-bar:has(.custom-applied-filters-wrap:empty):not(:has(> * > :not(.custom-applied-filters-wrap, .custom-filter-btn))) > * {
        position: static;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    body.jmn-on #main .custom-filter-bar:has(.custom-applied-filters-wrap:empty):not(:has(> * > :not(.custom-applied-filters-wrap, .custom-filter-btn))) .custom-filter-btn {
        position: absolute;
        right: 7px;
        bottom: 25px;
        width: 42px;
        height: 40px;
        padding: 0 !important;
        font-size: 0 !important;
    }

    body.jmn-on #main .custom-filter-bar:has(.custom-applied-filters-wrap:empty):not(:has(> * > :not(.custom-applied-filters-wrap, .custom-filter-btn))) .custom-filter-btn > .fas {
        font-size: 14px;
    }
}
