/* ========================================= */
/* STRUCTURE GLOBALE ET LAYOUT               */
/* ========================================= */
body {
    min-height: 100vh;
}

main:not(:where(.site-render-surface *)) {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0; /* Important pour le comportement des composants internes avec overflow */
}

/* --- COMPOSANTS NATIFS REUTILISABLES --- */
.dropdown-item.active:not(:where(.site-render-surface *)) {
    background: var(--bs-primary);
    color: #fff;
}
.dropdown-item.logout-link:hover:not(:where(.site-render-surface *)),
.dropdown-item.logout-link:focus:not(:where(.site-render-surface *)),
.dropdown-item.logout-link:active:not(:where(.site-render-surface *)),
.dropdown-item.logout-link.active:not(:where(.site-render-surface *)) {
    background-color: var(--bs-danger-bg-subtle, #f8d7da);
    color: var(--bs-danger-text-emphasis, #842029) !important;
}
.transition-all:not(:where(.site-render-surface *)) {
    transition: all 0.2s ease;
}

/* ========================================= */
/* FOOTER GENERAL                            */
/* ========================================= */
.admin-mini-footer {
    height: 50px;
    min-height: 50px;
    flex-shrink: 0;
    background-color: #ffffff;
}

.ultra-small {
    font-size: 0.7rem;
}

.footer-link:not(:where(.site-render-surface *)) {
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b; /* Gris ardoise plus lisible */
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-link:hover:not(:where(.site-render-surface *)) {
    color: var(--bs-primary) !important;
}

.isatis-logo img {
    transition: all 0.3s ease;
}

.isatis-logo:hover img {
    filter: grayscale(0) opacity(1) !important;
    transform: scale(1.05);
}

/* ========================================= */
/* BARRE DE NAVIGATION (NAVBAR)              */
/* ========================================= */
.navbar:not(:where(.site-render-surface *)) {
    height: 60px;
}

/* Style des liens de navigation */
.custom-nav-link:not(:where(.site-render-surface *)) {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    color: #64748b !important;
    padding: 0.5rem 0.8rem !important;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
}

.custom-nav-link:hover:not(:where(.site-render-surface *)),
.custom-nav-link.active:not(:where(.site-render-surface *)) {
    color: var(--bs-primary) !important;
    background-color: #f1f5f9;
}

.custom-nav-link svg:not(:where(.site-render-surface *)),
.btn-impersonate-link svg:not(:where(.site-render-surface *)) {
    font-size: 0.95rem;
    vertical-align: middle;
}

/* Bouton Profil / Utilisateur */
.btn-user-pill {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    padding: 4px 10px 4px 4px;
    transition: all 0.2s;
}

.btn-user-pill:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.user-avatar {
    width: 26px;
    height: 26px;
    background: var(--bs-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e293b;
}

.border-start.custom-navbar-actions {
    padding-left: 1.5rem;
    margin-left: 0.5rem;
}

/* Lien d'impersonation ("Quitter le test") */
.btn-impersonate-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: #dc3545 !important;
    display: inline-flex;
    align-items: center;
}

/* ========================================= */
/* CONFIGURATION DES LAYOUTS APPLICATIFS     */
/* ========================================= */
.admin-layout-wrapper {
    display: flex !important;
    flex-direction: row !important;
    width: 100%;
    height: calc(100vh - 60px);
    height: calc(100svh - 60px);
    height: calc(100dvh - 60px);
    overflow: hidden;
    position: relative;
}

.admin-content {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: #f8fafc;
    /* Masquage de la scrollbar native */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.admin-content::-webkit-scrollbar {
    display: none;
}

.admin-body-content {
    flex: 1 0 auto;
    width: 100%;
}

/* Empêche le double scroll sur desktop pour les dashboards */
@media (min-width: 992px) {
    body.overflow-hidden-desktop,
    body.overflow-hidden-desktop html {
        height: 100vh;
        width: 100vw;
        margin: 0;
        overflow: hidden;
    }
}

/* ========================================= */
/* RESPONSIVE TABLETTE & MOBILE (< 992px)    */
/* ========================================= */
@media (max-width: 991.98px) {
    /* Navbar Mobile */
    .navbar:not(:where(.site-render-surface *)) {
        height: auto;
    }
    .border-start.custom-navbar-actions {
        border: none !important;
        padding-left: 0 !important;
        margin-left: 0 !important;
    }

    /* Libération du scroll pour le tactile (Le correctif est ici !) */
    body {
        height: auto !important;
        min-height: 100vh;
        overflow-x: hidden;
    }

    .admin-layout-wrapper {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important; /* Débloque le scroll */
    }

    .admin-content {
        height: auto !important;
        overflow: visible !important; /* Débloque le scroll */
        padding-bottom: 80px;
    }

    .admin-body-content {
        padding: 1.5rem 1rem !important;
    }
}

.app-navbar {
    flex-shrink: 0;
}

@media (max-width: 991.98px) {
    body.dashboard-layout {
        height: auto !important;
        min-height: 100svh;
        min-height: 100dvh;
        padding-top: 60px;
        overflow-x: clip;
    }

    .dashboard-layout > .app-navbar {
        position: fixed;
        inset: 0 0 auto;
        z-index: 1045;
    }

    .app-navbar {
        height: 60px !important;
    }

    .app-navbar > .container-fluid {
        height: 100%;
        flex-wrap: nowrap;
    }

    .app-navbar .navbar-toggler,
    .app-navbar #adminSidebarToggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        min-width: 40px;
        height: 44px;
        padding: 0;
    }

    .app-navbar .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: calc(100vh - 60px);
        max-height: calc(100svh - 60px);
        max-height: calc(100dvh - 60px);
        overflow-y: auto;
        overscroll-behavior-y: contain;
        background: #fff;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 12px 20px rgba(15, 23, 42, 0.08);
    }

    .app-navbar .navbar-collapse > div {
        padding: 0.75rem;
        align-items: stretch !important;
    }

    .app-navbar .navbar-nav {
        align-items: stretch !important;
    }

    .app-navbar .nav-link,
    .app-navbar .btn,
    .app-navbar .dropdown-item {
        display: flex;
        align-items: center;
        min-height: 44px;
    }

    .app-navbar .nav-link {
        width: 100%;
        min-height: 44px;
    }

    .app-navbar .custom-navbar-actions {
        margin-top: 0.5rem;
        padding-top: 0.75rem !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    .app-navbar .custom-navbar-actions > .dropdown,
    .app-navbar .btn-user-pill {
        width: 100%;
    }

    .app-navbar .user-name {
        display: inline !important;
        overflow-wrap: anywhere;
        min-width: 0;
        text-align: left;
    }

    .app-navbar .user-avatar {
        flex-shrink: 0;
    }

    .app-navbar .btn-user-pill {
        min-height: 44px;
    }

    .app-navbar .dropdown-menu {
        position: fixed;
        margin: 0 !important;
        max-height: calc(100vh - 76px);
        max-height: calc(100svh - 76px);
        max-height: calc(100dvh - 76px);
        overflow-y: auto;
        overscroll-behavior-y: contain;
    }
}

@media (max-width: 991.98px) {
    .dashboard-layout .admin-content {
        padding-bottom: 0;
    }

    .dashboard-layout .admin-mini-footer {
        height: auto;
    }

    .dashboard-layout .admin-mini-footer > .container-fluid {
        height: auto !important;
        padding: 0.875rem 1rem !important;
    }

    .dashboard-layout .admin-footer-content {
        height: auto !important;
        flex-direction: column !important;
        gap: 0.5rem;
        padding: 0 !important;
        text-align: center;
    }

    .dashboard-layout .admin-footer-brand {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem !important;
    }

    .dashboard-layout .admin-mini-footer .footer-meta {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0 1rem !important;
    }

    .dashboard-layout .admin-mini-footer .footer-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
    }
}
