/* ==========================================================================
   IsiSolve — Surcouche applicative au design system ISITRAC
   Layout app (sidebar + topbar + contenu), adaptations spécifiques.
   ========================================================================== */

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   App shell : sidebar à gauche, zone content à droite
   -------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    background-color: var(--color-greyscale-light-white);
}

.app-sidebar {
    width: 260px;
    background-color: var(--color-greyscale-white);
    border-right: 1px solid var(--color-greyscale-dark-white);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    /* Nav longue (Home + Portail + Agent + Admin = 15+ liens) : sans overflow
       auto, la section Admin (en bas) devient inatteignable dès que la hauteur
       du contenu dépasse 100vh — typiquement sur téléphone en mode portrait. */
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.app-sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-greyscale-dark-white);
    line-height: 1.15;
}

.app-sidebar-brand-logo {
    display: block;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.app-sidebar-brand-logo--full {
    height: 40px;
}

.app-sidebar-brand-logo--icon {
    height: 36px;
    width: 36px;
    display: none;
}

.app-sidebar-brand .tagline {
    font-size: var(--body-p3-size);
    color: var(--color-text-tertiary);
}

.app-sidebar-section {
    padding: 12px 16px 6px;
    font-size: var(--body-p3-size);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Bouton repliable : conserve la typographie de la section, ajoute un chevron */
button.app-sidebar-section {
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font: inherit;
    color: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button.app-sidebar-section:hover,
button.app-sidebar-section:focus-visible {
    color: var(--color-text-primary);
}

.app-sidebar-section-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar-section-star {
    width: 14px;
    height: 14px;
    color: var(--color-warning-100, #f5a623);
    flex-shrink: 0;
}

.app-sidebar-section-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.app-sidebar-group.is-collapsed .app-sidebar-section-chevron {
    transform: rotate(-90deg);
}

.app-sidebar-group.is-collapsed .app-sidebar-nav,
.app-sidebar-group.is-collapsed .app-sidebar-favorites-empty {
    display: none;
}

.app-sidebar-favorites-empty {
    padding: 4px 24px 12px;
    margin: 0;
    font-size: var(--body-p3-size);
    color: var(--color-text-tertiary);
    line-height: 1.4;
}

.app-sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

/* Ligne d'item : NavLink (flex:1) + étoile à droite */
.app-sidebar-item {
    display: flex;
    align-items: stretch;
}

.app-sidebar-item .app-sidebar-link {
    flex: 1;
    min-width: 0;
}

.app-sidebar-fav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    flex-shrink: 0;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: var(--color-text-tertiary);
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.app-sidebar-fav-toggle svg {
    width: 16px;
    height: 16px;
}

.app-sidebar-item:hover .app-sidebar-fav-toggle,
.app-sidebar-fav-toggle:focus-visible,
.app-sidebar-fav-toggle.is-favorited {
    opacity: 1;
}

.app-sidebar-fav-toggle:hover,
.app-sidebar-fav-toggle.is-favorited {
    color: var(--color-warning-100, #f5a623);
}

.app-sidebar-fav-toggle.is-favorited svg {
    fill: currentColor;
    stroke: currentColor;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px 10px 23px;
    color: var(--color-text-primary);
    font-size: var(--body-p2-size);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    border-left: 4px solid transparent;
}

.app-sidebar-link:hover {
    background-color: var(--color-greyscale-light-white);
    color: #019DE0;
    text-decoration: none;
}

.app-sidebar-link:hover:not(.active) .txt {
    text-decoration: underline;
}

.app-sidebar-link.active,
.app-sidebar-link.active:hover {
    background-color: #CCEBF9;
    color: #017BB0;
    border-left-color: #017BB0;
    font-weight: 700;
    text-decoration: none;
}

.app-sidebar-link.active .txt {
    text-decoration: none;
    color: #017BB0;
}

.app-sidebar-link .ico {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: currentColor;
}

.app-sidebar-footer {
    margin-top: auto;
    padding: 16px 24px;
    border-top: 1px solid var(--color-greyscale-dark-white);
    font-size: var(--body-p3-size);
    color: var(--color-text-tertiary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.app-sidebar-legal {
    flex-basis: 100%;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: var(--body-p3-size);
}

.app-sidebar-legal a {
    color: var(--color-text-tertiary);
    text-decoration: none;
}

.app-sidebar-legal a:hover,
.app-sidebar-legal a:focus-visible {
    color: var(--color-text-primary);
    text-decoration: underline;
}

.legal-page h2 {
    margin-top: 32px;
}

.legal-page table.grid {
    margin: 12px 0;
}

/* --------------------------------------------------------------------------
   Topbar (à droite de la sidebar, au-dessus du contenu)
   -------------------------------------------------------------------------- */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background-color: var(--color-greyscale-white);
    border-bottom: 1px solid var(--color-greyscale-dark-white);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-topbar-title {
    font-family: var(--font-family-primary);
    font-size: var(--heading-h3-size);
    color: var(--color-text-primary);
    font-weight: 600;
    margin: 0;
}

.app-topbar-spacer {
    flex: 1;
}

.app-topbar-search {
    position: relative;
    min-width: 260px;
}

.app-content {
    padding: 28px;
    flex: 1;
}

/* --------------------------------------------------------------------------
   Language switcher
   -------------------------------------------------------------------------- */
.lang-switch {
    display: inline-flex;
    background: var(--color-greyscale-light-white);
    border: 1px solid var(--color-greyscale-dark-white);
    border-radius: var(--radius-button);
    padding: 2px;
    gap: 2px;
}

.lang-switch a {
    padding: 4px 10px;
    font-size: var(--body-p3-size);
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.lang-switch a:hover {
    color: var(--color-text-primary);
    text-decoration: none;
}

.lang-switch a.active {
    background: var(--color-primary-100);
    color: var(--color-greyscale-white);
}

/* --------------------------------------------------------------------------
   Page headers & tiles
   -------------------------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: var(--heading-h2-size);
    font-weight: 600;
    color: var(--color-text-primary);
}

.page-header .subtitle {
    color: var(--color-text-tertiary);
    font-size: var(--body-p2-size);
    margin-top: 4px;
}

.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--color-greyscale-white);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-global);
    padding: 18px 20px;
}

.stat-card .label {
    display: block;
    font-size: var(--body-p3-size);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text-primary);
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.tile {
    display: block;
    background: var(--color-greyscale-white);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-global);
    padding: 20px;
    color: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.tile:hover {
    border-color: var(--color-primary-60);
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.tile h3 {
    margin: 0 0 6px 0;
    font-size: var(--heading-h4-size);
    color: var(--color-primary-110);
    font-weight: 600;
}

.tile p {
    margin: 0;
    color: var(--color-text-tertiary);
    font-size: var(--body-p2-size);
}

/* --------------------------------------------------------------------------
   Toolbar (filtres + recherche au-dessus d'une table)
   -------------------------------------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar .toolbar-left {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 220px;
}

.toolbar .toolbar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.grid-wrapper {
    background: var(--color-greyscale-white);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-global);
    overflow: hidden;
}

.grid-wrapper .grid {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.grid-actions {
    display: inline-flex;
    gap: 6px;
}

.grid-action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--color-text-tertiary);
    border-radius: 6px;
    font-size: var(--body-p2-size);
}

.grid-action-btn:hover {
    background: var(--color-greyscale-light-white);
    color: var(--color-primary-100);
}

.grid-action-btn.delete:hover {
    color: var(--color-error-110);
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-tertiary);
}

.empty-state h3 {
    margin: 0 0 8px;
    color: var(--color-text-secondary);
    font-weight: 600;
}

.empty-state p {
    margin: 0 0 16px;
    font-size: var(--body-p2-size);
}

/* --------------------------------------------------------------------------
   Drawer / modal form
   -------------------------------------------------------------------------- */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(48, 48, 58, 0.3);
    z-index: 50;
    display: flex;
    justify-content: flex-end;
}

.drawer {
    width: 480px;
    max-width: 100vw;
    height: 100%;
    background: var(--color-greyscale-white);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    animation: drawer-in 0.2s ease-out;
}

@keyframes drawer-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-greyscale-dark-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h2 {
    margin: 0;
    font-size: var(--heading-h3-size);
    font-weight: 600;
}

.drawer-close {
    background: transparent;
    border: none;
    color: var(--color-text-tertiary);
    cursor: pointer;
    font-size: 22px;
    padding: 4px 8px;
    border-radius: 8px;
}

.drawer-close:hover {
    background: var(--color-greyscale-light-white);
    color: var(--color-text-primary);
}

.drawer-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--color-greyscale-dark-white);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   Burger button (visible en mobile uniquement)
   -------------------------------------------------------------------------- */
.app-topbar-burger {
    display: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px;
    color: var(--color-text-primary);
    cursor: pointer;
    margin-right: 4px;
    position: relative;
}

.app-topbar-burger:hover {
    background: var(--color-greyscale-light-white);
}

.app-topbar-burger:focus-visible {
    border-color: var(--color-primary-100);
    outline: none;
}

/* Pastille rouge style Outlook posée en haut-à-droite du burger : quand le drawer
   est fermé sur mobile, l'utilisateur voit quand même qu'il y a des mouvements.
   Additionne les mouvements portail + agent. */
.burger-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #EF4444;
    color: white;
    border: 2px solid var(--color-greyscale-white, white);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

/* Backdrop mobile : invisible sauf quand la sidebar est ouverte */
.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(48, 48, 58, 0.45);
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 40;
    animation: isi-fade 0.2s ease-out;
}

@keyframes isi-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Le rôle de l'utilisateur est visible sauf sur mobile (gain de place) */
.app-topbar-role {
    margin-right: 12px;
}

.app-topbar-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
    margin-right: 12px;
}

/* Bloc utilisateur + déconnexion visible uniquement dans le drawer en mobile.
   Caché en desktop (le drawer est également caché par la sidebar classique). */
.app-sidebar-user-mobile { display: none; }

.app-topbar-user-name {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 14px;
}

.app-topbar-user-sub {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.app-topbar-searchbtn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.04);
    border: 1px solid var(--color-greyscale-dark-white, #E5E7EB);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--color-text-tertiary);
    font-size: 13px;
    margin-right: 12px;
}
.app-topbar-searchbtn:hover { background: rgba(0,0,0,0.07); }
.app-topbar-searchbtn kbd {
    background: white;
    border: 1px solid var(--color-greyscale-dark-white, #E5E7EB);
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 11px;
    font-family: inherit;
    margin-left: 2px;
}
@media (max-width: 720px) {
    .app-topbar-searchbtn-txt { display: none; }
}

.global-search-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: flex; justify-content: center; align-items: flex-start;
    padding-top: 12vh;
}
.global-search-panel {
    background: white;
    border-radius: 10px;
    width: min(640px, 92vw);
    max-height: 70vh;
    overflow: auto;
    padding: 0;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.global-search-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 18px 20px;
    font-size: 16px;
    border-bottom: 1px solid var(--color-greyscale-dark-white, #E5E7EB);
    box-sizing: border-box;
}
.global-search-section {
    padding: 8px 16px 4px;
    font-size: 11px;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    background: #FAFBFC;
}
.global-search-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-greyscale-dark-white, #F3F4F6);
    font-size: 14px;
}
.global-search-item:hover { background: var(--color-primary-20, #CCEBF9); }
.global-search-hint {
    padding: 18px 20px;
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: 14px;
}

/* Badge style Outlook : rond rouge avec nombre, aligné à droite de l'item de nav.
   L'animation pulse est continue tant que le badge est visible — c'est le signal
   visuel que quelque chose attend l'utilisateur (mails à approuver, mouvements
   tickets…). prefers-reduced-motion supprime l'animation pour les utilisateurs
   sensibles aux animations. */
.nav-badge-red {
    background: #EF4444;
    color: white;
    border-radius: 999px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    margin-left: auto;
    box-shadow: 0 0 0 2px var(--app-sidebar-bg, white),
                0 0 0 4px rgba(239, 68, 68, 0.35);
    animation: nav-badge-pulse 2.2s ease-in-out infinite;
}

@keyframes nav-badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 2px var(--app-sidebar-bg, white),
                    0 0 0 4px rgba(239, 68, 68, 0.35);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 0 2px var(--app-sidebar-bg, white),
                    0 0 0 8px rgba(239, 68, 68, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-badge-red { animation: none; }
}

/* --------------------------------------------------------------------------
   Responsive — Tablette : sidebar compactée en icônes
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .app-sidebar {
        width: 72px;
    }

    .app-sidebar-brand .tagline,
    .app-sidebar-section,
    .app-sidebar-link span.txt,
    .app-sidebar-favorites-empty,
    .app-sidebar-fav-toggle,
    .app-sidebar-footer {
        display: none;
    }

    /* En mode icônes, on garde les listes ouvertes (le chevron est caché) */
    .app-sidebar-group.is-collapsed .app-sidebar-nav { display: block; }

    .app-sidebar-brand { align-items: center; padding: 16px 8px; }
    .app-sidebar-brand-logo--full { display: none; }
    .app-sidebar-brand-logo--icon { display: block; }

    .app-sidebar-link {
        justify-content: center;
        padding: 12px;
    }

    .app-content { padding: 20px; }
    .app-topbar { padding: 12px 20px; }
}

/* --------------------------------------------------------------------------
   Responsive — Mobile : sidebar off-canvas (drawer) + burger button
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
    .app-topbar-burger {
        display: inline-flex;
        flex-shrink: 0;
        padding: 8px;
        background: var(--color-primary-10, #E6F5FC);
        border: 1px solid var(--color-primary-100, #019DE0);
        color: var(--color-primary-110, #017BB0);
    }
    .app-topbar-role { display: none; }
    .app-topbar-user-sub { display: none; }
    /* On dégage la topbar sur mobile : le nom d'utilisateur et le bouton se-déconnecter
       partent dans le footer du drawer (via .app-topbar-mobile-hide). Il ne reste que :
       [burger] [titre] [recherche]. Ainsi on garantit que le burger est toujours visible. */
    .app-topbar-mobile-hide { display: none; }
    .app-topbar-spacer { min-width: 0; }
    .app-topbar-searchbtn { margin-right: 0; }

    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.22s ease-out;
        z-index: 50;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
        overflow-y: auto;
    }

    /* quand ouverte, on rétablit toute la nav (texte + sections) */
    .app-shell--nav-open .app-sidebar {
        transform: translateX(0);
    }

    .app-shell--nav-open .app-sidebar-brand .tagline,
    .app-shell--nav-open .app-sidebar-section,
    .app-shell--nav-open .app-sidebar-link span.txt,
    .app-shell--nav-open .app-sidebar-favorites-empty,
    .app-shell--nav-open .app-sidebar-fav-toggle,
    .app-shell--nav-open .app-sidebar-footer {
        display: revert;
    }

    .app-shell--nav-open button.app-sidebar-section {
        display: flex;
    }

    /* En mobile drawer ouvert, on respecte le repli */
    .app-shell--nav-open .app-sidebar-group.is-collapsed .app-sidebar-nav,
    .app-shell--nav-open .app-sidebar-group.is-collapsed .app-sidebar-favorites-empty {
        display: none;
    }

    .app-shell--nav-open .app-sidebar-brand { align-items: flex-start; padding: 16px 20px; }
    .app-shell--nav-open .app-sidebar-brand-logo--full { display: block; }
    .app-shell--nav-open .app-sidebar-brand-logo--icon { display: none; }

    .app-shell--nav-open .app-sidebar-link {
        justify-content: flex-start;
        padding: 10px 24px;
    }

    .app-shell--nav-open .app-sidebar-backdrop {
        display: block;
    }

    /* Bloc utilisateur + déconnexion cloné dans le drawer mobile.
       On retire margin-top:auto du footer en mobile pour que user-mobile soit
       collé au footer en bas du drawer. */
    .app-sidebar-user-mobile {
        display: block;
        padding: 16px 20px;
        border-top: 1px solid var(--color-greyscale-dark-white);
        margin-top: auto;
    }
    .app-sidebar-footer { margin-top: 0; }
    .app-sidebar-user-mobile .name {
        display: block;
        font-weight: 600;
        color: var(--color-text-primary);
        margin-bottom: 4px;
    }
    .app-sidebar-user-mobile .role {
        display: block;
        color: var(--color-text-tertiary);
        font-size: 12px;
        margin-bottom: 10px;
    }
    .app-sidebar-user-mobile .btn { width: 100%; }

    .app-content { padding: 16px 14px; }
    .app-topbar { padding: 10px 14px; gap: 10px; }
    .app-topbar-title {
        font-size: var(--heading-h4-size);
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .drawer { width: 100%; }

    /* Les stats/tiles : une colonne */
    .stats-row,
    .tile-grid {
        grid-template-columns: 1fr;
    }

    /* Page header : empilé, les actions passent sous le titre */
    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .page-actions .btn {
        flex: 1 1 auto;
    }

    /* Toolbar filtres : full width, empilée */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar .toolbar-left,
    .toolbar .toolbar-right {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* --------------------------------------------------------------------------
   Tableaux / grilles — scroll horizontal sur écran étroit
   Ajouter la classe .grid-scroll au wrapper pour l'activer.
   -------------------------------------------------------------------------- */
.grid-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
    .grid-wrapper { overflow-x: auto; }
    .grid-wrapper .grid { min-width: 640px; }

    /* Les tables .grid qui ne sont PAS dans un .grid-wrapper
       (dashboards, login, détail ticket) gagnent un scroll sur leur parent direct. */
    *:has(> table.grid) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.grid { min-width: 520px; }
}

/* Zone drop pour pièces jointes : feedback visuel pendant un drag. Le drop est géré
   en JS par wireDropZone (wwwroot/js/attachments.js) ; on ajoute .drop-over pendant
   dragenter et on la retire sur dragleave/drop. */
.attachments-drop {
    border: 1px dashed var(--color-greyscale-mid, #C6CED5);
    border-radius: 8px;
    padding: 12px;
    transition: background 120ms ease, border-color 120ms ease;
}

.attachments-drop.drop-over {
    border-color: var(--color-primary-100, #019DE0);
    background: var(--color-primary-10, #E6F5FC);
}

/* --------------------------------------------------------------------------
   Loading overlay réutilisable : voile semi-transparent + spinner + message.
   Usage : <div class="isi-loading-overlay"><div class="isi-loading-card">
             <div class="isi-spinner"></div><p>Chargement…</p></div></div>
   Variante .isi-loading-overlay--inline : pas de position fixed, reste dans le flux
   (utile pour un loader de zone, type "carte" d'attente).
   -------------------------------------------------------------------------- */
.isi-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.isi-loading-overlay--inline {
    position: static;
    background: transparent;
    min-height: 180px;
    padding: 24px 12px;
    backdrop-filter: none;
}

.isi-loading-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px 32px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 380px;
    text-align: center;
}

.isi-loading-overlay--inline .isi-loading-card {
    box-shadow: none;
    background: transparent;
}

.isi-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-greyscale-light, #E5E7EB);
    border-top-color: var(--color-primary-100, #019DE0);
    border-radius: 50%;
    animation: isi-spinner-rotate 0.7s linear infinite;
}

@keyframes isi-spinner-rotate {
    to { transform: rotate(360deg); }
}

.isi-loading-card p {
    margin: 0;
    color: var(--color-text-primary, #1f2937);
    font-weight: 500;
}

.isi-loading-card .text-tertiary {
    font-size: 13px;
    margin-top: -4px;
}

/* --------------------------------------------------------------------------
   Aide contextuelle (HelpButton / HelpDrawer)
   -------------------------------------------------------------------------- */
.help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-secondary, #5b6470);
    cursor: pointer;
    margin-right: 8px;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.help-btn:hover {
    background: var(--color-greyscale-light-white, #F4F5F7);
    color: var(--color-primary-100, #019DE0);
}

.help-btn:focus-visible {
    outline: none;
    border-color: var(--color-primary-100, #019DE0);
    box-shadow: 0 0 0 3px var(--color-primary-10, #E6F5FC);
}

/* Drawer dédié à l'aide — un peu plus large que les drawers de formulaire
   pour accueillir un contenu structuré (sections, listes, callouts, icônes). */
.help-drawer { width: 520px; }
.help-drawer-body { line-height: 1.55; font-size: 14px; color: var(--color-text-primary, #1f2329); }
.help-drawer-body p { margin: 0 0 10px; }
.help-drawer-body ul { margin: 0 0 12px 20px; padding: 0; }
.help-drawer-body li { margin: 0 0 4px; }
.help-drawer-body ol { margin: 0 0 12px 20px; padding: 0; }
.help-drawer-body ol li { margin: 0 0 6px; }
.help-drawer-body strong { color: var(--color-text-primary, #1f2329); }
.help-drawer-body code {
    background: var(--color-greyscale-light-white, #F4F5F7);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--color-primary-110, #017BB0);
}
.help-drawer-body a { color: var(--color-primary-100, #019DE0); text-decoration: none; }
.help-drawer-body a:hover { text-decoration: underline; }
.help-drawer-footer { font-size: 12px; color: var(--color-text-tertiary, #8a8f99); }
.help-drawer-hint { line-height: 1.4; }

/* Icône inline dans le corps de l'aide : alignée avec le texte. */
.help-drawer-body .help-ico {
    width: 16px; height: 16px;
    display: inline-block;
    vertical-align: -3px;
    margin-right: 2px;
    color: var(--color-primary-100, #019DE0);
}

/* Sections semantiques utilisées dans les contenus d'aide. */
.help-drawer-body .help-section {
    margin: 0 0 18px;
}
.help-drawer-body .help-section > h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-primary, #1f2329);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.help-drawer-body .help-section > h3 .help-ico {
    color: var(--color-primary-100, #019DE0);
    width: 18px; height: 18px;
    margin-right: 0;
    vertical-align: 0;
}

/* Liste d'étapes "1. 2. 3." avec numéros visuels. */
.help-drawer-body .help-steps {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    counter-reset: help-step;
}
.help-drawer-body .help-steps > li {
    position: relative;
    padding: 6px 0 6px 32px;
    counter-increment: help-step;
    margin: 0;
}
.help-drawer-body .help-steps > li::before {
    content: counter(help-step);
    position: absolute;
    left: 0; top: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--color-primary-100, #019DE0);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Callouts (astuce, alerte, info) — bandeau gauche coloré + fond doux. */
.help-drawer-body .help-callout {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 0 0 14px;
    border-left: 3px solid var(--color-primary-100, #019DE0);
    background: var(--color-primary-10, #E6F5FC);
}
.help-drawer-body .help-callout .help-ico {
    flex: 0 0 auto;
    width: 20px; height: 20px;
    margin: 1px 0 0 0;
    vertical-align: 0;
    color: var(--color-primary-100, #019DE0);
}
.help-drawer-body .help-callout p:last-child { margin: 0; }

.help-drawer-body .help-callout.help-callout-tip {
    border-left-color: #2BAF6E;
    background: #E6F5EC;
}
.help-drawer-body .help-callout.help-callout-tip .help-ico { color: #2BAF6E; }

.help-drawer-body .help-callout.help-callout-warning {
    border-left-color: #E08A1A;
    background: #FBF2E1;
}
.help-drawer-body .help-callout.help-callout-warning .help-ico { color: #E08A1A; }

.help-drawer-body .help-callout.help-callout-danger {
    border-left-color: #D43E3E;
    background: #FCE7E7;
}
.help-drawer-body .help-callout.help-callout-danger .help-ico { color: #D43E3E; }

/* Listes "raccourci → effet" — pratique pour les actions UI. */
.help-drawer-body .help-actions {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}
.help-drawer-body .help-actions > li {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-greyscale-dark-white, #E5E7EB);
}
.help-drawer-body .help-actions > li:last-child { border-bottom: none; }
.help-drawer-body .help-actions .help-ico {
    flex: 0 0 18px;
    width: 18px; height: 18px;
    margin: 2px 0 0 0;
    vertical-align: 0;
}
.help-drawer-body .help-actions strong { display: inline; }

@media (max-width: 760px) {
    /* En mobile, le drawer prend tout l'écran (cf. .drawer { width: 100% }
       déjà défini plus haut). On garde le bouton "?" visible dans la topbar. */
    .help-btn { margin-right: 4px; }
}
