/*
 * Socle commun du portail (« framework ») : pages liste, panneau latéral, champs obligatoires.
 * Fichier identique dans api-portail-logistic et modele-projet-ageneau : toute modification est reportée
 * dans les deux dépôts (voir CLAUDE.md, « Socle commun »). Règles propres à un écran : style.css.
 */

/* ---------------------------------------------------------------- pages liste (#97, _list_view.html) */
.list-page-title {
    margin-bottom: 1rem;
}
/* Onglets d'une page à plusieurs listes */
.list-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 1rem;
}
.list-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    min-height: 44px;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    color: var(--bs-secondary-color);
    text-decoration: none;
}
.list-tab:hover {
    color: var(--bs-primary);
}
.list-tab.active {
    color: var(--bs-primary);
    border-bottom-color: var(--bs-primary);
    font-weight: 600;
}
.list-tab-count {
    background: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
    border-radius: 999px;
    padding: 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}
/* Liste groupée (ex. Paramètres : Plateforme, Mon compte) : une ligne de groupe en tête de chaque <tbody>,
   les lignes du groupe en retrait dessous (regroupement) */
.table .list-group-row > th {
    --bs-table-bg-type: transparent;
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-top: 1px solid var(--bs-border-color);
}
/* Ligne de groupe : un titre, pas un élément à ouvrir (aucun effet de survol, #113) */
.table-hover > tbody > .list-group-row:hover > * {
    --bs-table-bg-state: transparent;
    cursor: default;
}
.table > tbody:has(> .list-group-row) > .list-row > td:first-child:not(.list-select-col),
.table > tbody:has(> .list-group-row) > .list-row > td.list-select-col + td {
    padding-left: 2.25rem;
}
/* Groupe repliable (macro group_body) : toute la ligne de groupe replie ou déplie ; triangle tourné, lignes cachées */
.table-hover > tbody > .list-group-row[data-list-group-toggle]:hover > * {
    cursor: pointer;
}
.list-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
}
.list-group-caret {
    font-size: 0.7rem;
    transition: transform 0.15s ease;
}
.table > tbody.is-collapsed .list-group-caret {
    transform: rotate(-90deg);
}
.table > tbody.is-collapsed > tr:not(.list-group-row) {
    display: none;
}
.list-group-count {
    padding: 0 0.45rem;
    border-radius: 999px;
    background: var(--bs-secondary-bg);
    font-weight: 600;
    letter-spacing: 0;
}
/* « + Créer » et les autres actions de la page, barre de recherche minimaliste, puis à droite des filtres « Import / export » */
.list-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.list-toolbar-row > .list-toolbar {
    flex: 1 1 20rem;
    min-width: 0;
    margin-bottom: 0;
}
.list-toolbar-extra > .btn {
    height: 100%;
}
.list-toolbar-new {
    flex: 0 0 auto;
    white-space: nowrap;
    border-radius: 0.6rem;
    padding-left: 1rem;
    padding-right: 1rem;
}
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.6rem;
    padding: 0.35rem 0.35rem 0.35rem 0.85rem;
    margin-bottom: 0.75rem;
}
.list-toolbar:focus-within {
    border-color: rgba(var(--bs-primary-rgb), 0.5);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.12);
}
.list-toolbar-icon {
    color: var(--bs-secondary-color);
}
.list-toolbar-search {
    flex: 1 1 16rem;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 0.45rem 0.25rem;
    font-size: 0.95rem;
}
.list-toolbar-btn {
    min-height: 40px;
}
.list-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
    border-radius: 999px;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    font-size: 0.85rem;
    text-decoration: none;
}
.list-chip:hover {
    background: rgba(var(--bs-primary-rgb), 0.18);
}
.list-chip-x {
    font-size: 1.1rem;
    line-height: 1;
}
.list-filters-menu {
    padding: 1rem;
    width: min(28rem, calc(100vw - 2rem));
}
.list-filters-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem;
}
/* Barre des actions en masse (lignes cochées) */
.list-bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    background: var(--bs-primary);
    color: #fff;
    border-radius: 0.6rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    margin-bottom: 0.75rem;
}
.list-bulk-bar[hidden] {
    display: none;
}
.list-bulk-count {
    margin-right: 0.5rem;
}
.list-bulk-bar .btn-link {
    color: #fff;
    margin-left: auto;
}
/* Boutons à contour dans la barre (fond de la couleur principale, ex. « Sélectionner les … de la recherche ») :
   texte et contour blancs, lisibles ; au survol, fond blanc */
.list-bulk-bar .btn-outline-primary,
.list-bulk-bar .btn-outline-secondary,
.list-bulk-bar .btn-outline-light {
    --bs-btn-color: #fff;
    --bs-btn-border-color: rgba(255, 255, 255, 0.75);
    --bs-btn-hover-color: var(--bs-primary);
    --bs-btn-hover-bg: #fff;
    --bs-btn-hover-border-color: #fff;
    --bs-btn-active-color: var(--bs-primary);
    --bs-btn-active-bg: #fff;
    --bs-btn-active-border-color: #fff;
    --bs-btn-focus-shadow-rgb: 255, 255, 255;
}
.list-bulk-bar .form-select {
    width: auto;
    min-width: 12rem;
}
/* Pagination « ‹ Page [ 1 ] / 2 › » */
.list-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
}
.list-pagination.is-bottom {
    justify-content: flex-end;
}
.list-pagination-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}
.list-pager {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}
.list-pager-btn {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.list-pager-label,
.list-pager-total {
    margin: 0;
    white-space: nowrap;
}
.list-pager-input {
    width: 3.5rem;
    height: 2.25rem;
    text-align: center;
}
/* Tableau d'une page liste et d'une liste intégrée dans un panneau (inline_list, #117) : cadre blanc arrondi comme
   la barre de recherche, en-tête discret, toutes les lignes de la même couleur (grisée au survol), séparateurs
   légers, hauteur de ligne régulière */
:is([data-list-view], .inline-list) .table-responsive {
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.6rem;
    margin-bottom: 0.75rem;
}
:is([data-list-view], .inline-list) .table {
    --bs-table-hover-bg: rgba(0, 0, 0, 0.045);
    --bs-table-border-color: var(--bs-border-color-translucent);
    margin-bottom: 0;
}
:is([data-list-view], .inline-list) .table > :not(caption) > * > * {
    padding: 0.7rem 0.9rem;
}
:is([data-list-view], .inline-list) .table > thead > tr > th {
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom-width: 1px;
}
:is([data-list-view], .inline-list) .table > tbody:last-child > tr:last-child > * {
    border-bottom: 0;
}
/* Largeur des colonnes (list_view.ts, modele-projet-ageneau#80) : largeurs figées au chargement (replier un groupe
   ne déplace plus les intitulés), poignée au bord droit des intitulés pour élargir ou réduire */
.table.has-column-widths {
    table-layout: fixed;
}
.table.has-column-widths > thead > tr > th {
    overflow: hidden;
    text-overflow: ellipsis;
}
.table.has-column-widths > tbody > tr > td {
    overflow-wrap: anywhere;
}
.table > thead > tr > th.list-col-resizable {
    position: relative;
}
.list-col-resize {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 9px;
    cursor: col-resize;
    touch-action: none;
    z-index: 1;
}
.list-col-resize::after {
    content: "";
    position: absolute;
    top: 25%;
    bottom: 25%;
    right: 3px;
    width: 2px;
    border-radius: 1px;
    background: var(--bs-border-color);
}
.list-col-resize:hover::after,
.list-col-resize:focus-visible::after,
.table.is-resizing .list-col-resize::after {
    top: 0;
    bottom: 0;
    background: rgba(var(--bs-primary-rgb), 0.6);
}
.list-col-resize:focus-visible {
    outline: 0;
}
.table.is-resizing {
    cursor: col-resize;
    user-select: none;
}
/* Liste intégrée : cellules plus serrées (champs modifiables dans les lignes) */
.inline-list .table > :not(caption) > * > * {
    padding: 0.45rem 0.6rem;
}
.inline-list .list-toolbar {
    margin-bottom: 0;
}
/* Lignes cliquables */
.list-select-col {
    width: 2.5rem;
}
.list-row {
    cursor: pointer;
}
.list-row.is-open > * {
    --bs-table-bg-state: rgba(var(--bs-primary-rgb), 0.08);
}
.list-row.is-selected > * {
    --bs-table-bg-state: rgba(var(--bs-primary-rgb), 0.12);
}
.list-row.is-selected > td:first-child {
    box-shadow: inset 4px 0 0 var(--bs-primary);
}
.list-open {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--bs-primary);
    text-align: left;
}
.list-open:hover,
.list-open:focus-visible {
    text-decoration: underline;
}
/* Panneau latéral */
/* Largeur d'origine bornée comme la poignée (list_view.ts) : d'un quart aux trois quarts de l'écran (#117) */
.list-panel.offcanvas-end {
    width: clamp(25vw, 520px, 75vw);
    display: flex;
    flex-direction: column;
}
.list-panel-wide.offcanvas-end {
    width: clamp(25vw, 960px, 75vw);
}
/* Poignée du bord gauche, toujours visible (trait vertical) : panneau réglable d'un quart aux trois quarts de
   l'écran, pour tous les panneaux (list_view.ts) */
.list-panel-resize {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -4px;
    width: 8px;
    cursor: ew-resize;
    z-index: 2;
}
.list-panel-resize::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 2px;
    width: 4px;
    height: 3rem;
    margin-top: -1.5rem;
    border-radius: 2px;
    background: rgba(var(--bs-primary-rgb), 0.45);
}
.list-panel-resize:hover,
.list-panel-resize:focus-visible,
.list-panel.is-resizing .list-panel-resize {
    background: rgba(var(--bs-primary-rgb), 0.35);
    outline: 0;
}
.list-panel.is-resizing {
    transition: none;
    user-select: none;
}
.list-panel-header {
    border-bottom: 1px solid var(--bs-border-color);
}
.list-panel-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.list-panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}
.list-panel-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--bs-border-color);
    background: #fff;
}
/* Menu « Actions » du pied : au-dessus du bouton, raisons des actions impossibles sur plusieurs lignes */
.list-panel-more .dropdown-menu {
    max-width: min(24rem, 90vw);
}
.list-panel-more-off small {
    white-space: normal;
    font-size: 0.8rem;
}
/* Modifications non enregistrées : une seule zone en bas, à la place du pied du panneau */
.list-panel-unsaved {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: #fff4e5;
    color: #6b4100;
    border-top: 1px solid #f0c27a;
}
.list-panel:has(> .list-panel-unsaved:not([hidden])) .list-panel-footer {
    display: none;
}
.list-panel-unsaved[hidden] {
    display: none;
}
/* Interrupteur « Actif » en tête du formulaire du panneau (macro active_switch) */
.list-panel-active {
    padding: 0.6rem 0.75rem 0.6rem 3.25rem;
    margin-bottom: 1.25rem;
    background: var(--bs-tertiary-bg);
    border-radius: 0.5rem;
}
.list-panel-active .form-check-label {
    font-weight: 600;
}
/* Champ demandé dans la fenêtre de confirmation (data-confirm-field, list_view.ts) */
.modal-body.list-confirm-field {
    padding-top: 0;
}
.list-panel-unsaved-actions {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
}
/* Toutes les fenêtres (pied de panneau, avertissement, modales, formulaires) : actions et validation à gauche,
   « Annuler » toujours juste à leur droite (espacement normal), quel que soit l'ordre d'écriture */
.modal-footer {
    justify-content: flex-start;
}
.btn-cancel,
[data-panel-cancel],
[data-panel-discard] {
    order: 99;
}
/* Pied d'un panneau : « Supprimer » seul, tout à droite, après « Annuler » (macro spec_panel_footer) */
.list-panel-footer .list-panel-delete {
    order: 100;
    margin-left: auto;
}
/* Fermeture refusée (modifications en cours) : le panneau tremble, l'avertissement prend le focus (list_view.ts) */
@keyframes list-panel-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}
.list-panel.is-shaking {
    animation: list-panel-shake 0.4s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
    .list-panel.is-shaking {
        animation: none;
    }
    .list-panel.is-shaking .list-panel-unsaved {
        outline: 3px solid #f0c27a;
        outline-offset: -3px;
    }
}
/* Formulaire empilé : chaque champ (et chaque encadré) sur toute la largeur, les uns sous les autres, quelle que
   soit la largeur du panneau ou de l'écran (ex. Paramètres) : class="list-panel-body list-panel-stacked" */
.list-panel-stacked .row > * {
    flex: 0 0 auto;
    width: 100%;
}
.list-panel-section + .list-panel-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--bs-border-color);
}
.list-panel-section > h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.75rem;
}
.list-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.list-panel-actions form {
    margin: 0;
}
@media (max-width: 575.98px) {
    .list-panel.offcanvas-end {
        width: 100vw !important;    /* plein écran sur mobile, même après un élargissement */
    }
    .list-panel-resize {
        display: none;
    }
}

/* Champs obligatoires (attribut required), règle commune à tous les formulaires : fond bleu très léger (réglable :
   --app-required-bg, Paramètres > Apparence) et astérisque après le libellé (classe label-required posée par
   required_fields.ts) */
.form-control:required,
.form-select:required {
    background-color: var(--app-required-bg, #f5f8fe);
}
.label-required::after {
    content: "\00a0*";
    color: var(--bs-danger);
    font-weight: 600;
}

/* Zone de dépôt d'un fichier (macro file_drop, list_view.ts) : cadre en pointillés ; un fichier se dépose sur tout le
   panneau latéral, mis en évidence pendant le survol (cadre et message par-dessus le panneau) */
.file-drop {
    border: 2px dashed var(--bs-border-color);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    transition: background-color 0.15s, border-color 0.15s;
}
.file-drop-hint {
    margin-bottom: 0.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}
.file-drop-message {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
}
.file-drop.file-drop-over,
.list-panel.file-drop-over .file-drop {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.08);
}
.list-panel.file-drop-over::after {
    content: "Déposez le fichier pour l’importer";
    position: absolute;
    inset: 0.5rem;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 3px dashed var(--bs-primary);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    background: rgba(var(--bs-body-bg-rgb, 255, 255, 255), 0.85);
    color: var(--bs-primary);
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
    .file-drop {
        transition: none;
    }
}

/* Tâches de fond (app/services/background_jobs.py) : résultat ou erreur dans le panneau, retours à la ligne
   conservés */
.text-pre-wrap {
    white-space: pre-wrap;
}

/* Menu du compte (barre du haut, à droite) : ouvert vers la gauche, jamais hors de l'écran */
@media (min-width: 992px) {
    .app-navbar [data-menu-group="Compte"] {
        position: relative;
    }
    .app-navbar [data-menu-group="Compte"] > .dropdown-menu {
        left: auto;
        right: 0;
    }
}

/* Menu du compte (barre du haut) : nom affiché et rôle */
.account-menu .role-badge {
    background: var(--app-navbar-text, #2c347e);
    color: #fff;
    font-weight: 600;
}
.role-badge-panel {
    background: var(--bs-primary);
    color: #fff;
    font-weight: 600;
}

/* Menu du compte : bulle des nouveautés non lues sur l'icône ; pages Nouveautés et Aide (Markdown limité) */
.user-icon {
    position: relative;
    display: inline-block;
}
.news-dot {
    position: absolute;
    top: -.1rem;
    right: -.25rem;
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    background: #dc3545;
    box-shadow: 0 0 0 2px var(--bs-body-bg, #fff);
}
.news-entry.is-new {
    border-left: 4px solid var(--bs-primary);
}
.md-content > :last-child {
    margin-bottom: 0;
}
.md-content ul {
    padding-left: 1.25rem;
}
.md-heading {
    font-size: 1rem;
    font-weight: 600;
    margin-top: .75rem;
}
.help-search {
    max-width: 32rem;
}
.help-toc {
    font-size: .9rem;
    line-height: 1.8;
}
.help-toc-group {
    font-weight: 600;
    margin-right: .35rem;
}
