/* Coque admin — barre latérale inspirée du menu Qualiopi simplifié */

.admin-shell {
    --shell-sidebar-w: 260px;
    --shell-bg: #f5f2ed;
    --shell-sidebar-bg: #fff;
    --shell-border: #e8e2d8;
    --shell-link-hover: #faf6ef;
    --shell-active-bg: #faf6ef;
    --shell-active-border: #a8905f;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Admin principal + CMS : sidebar fixe pleine hauteur */
.admin-shell--main,
.admin-shell--cms {
    display: flex;
}

.admin-shell--main > .admin-shell__sidebar,
.admin-shell--cms > .admin-shell__sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    width: var(--shell-sidebar-w);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--shell-sidebar-bg);
    border-right: 1px solid var(--shell-border);
    overflow-y: auto;
    transition: transform 0.22s ease;
}

.admin-shell--main > .admin-shell__content,
.admin-shell--cms > .admin-shell__content {
    flex: 1;
    min-width: 0;
    margin-left: var(--shell-sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Login et pages sans barre latérale */
.admin-shell--no-sidebar > .admin-shell__content {
    margin-left: 0;
}

.admin-shell__brand {
    padding: 1.25rem 1.1rem 1rem;
    border-bottom: 1px solid var(--shell-border);
}

.admin-shell__brand-title {
    display: block;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    color: var(--primary, #a8905f);
    line-height: 1.3;
}

.admin-shell__brand-sub {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    color: #888;
}

.admin-shell__nav {
    flex: 1;
    padding: 0.75rem 0.65rem 1rem;
}

.admin-shell__group {
    margin-bottom: 1rem;
}

.admin-shell__group-label {
    margin: 0 0 0.35rem 0.65rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9a9488;
}

.admin-shell__link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.15rem;
    border-radius: 10px;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text, #2d2d2d);
    font-size: 0.9rem;
    line-height: 1.25;
    transition: background 0.15s, border-color 0.15s;
}

.admin-shell__link:hover {
    background: var(--shell-link-hover);
}

.admin-shell__link--active {
    background: var(--shell-active-bg);
    border-color: rgba(168, 144, 95, 0.35);
    font-weight: 600;
    color: var(--primary, #a8905f);
}

.admin-shell__link-icon {
    flex-shrink: 0;
    width: 1.35rem;
    text-align: center;
    font-size: 1rem;
    line-height: 1;
}

.admin-shell__link-text {
    flex: 1;
    min-width: 0;
}

.admin-shell__sidebar-foot {
    padding: 0.75rem 0.85rem 1rem;
    border-top: 1px solid var(--shell-border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.admin-shell__foot-link {
    font-size: 0.82rem;
    color: #666;
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
}

.admin-shell__foot-link:hover {
    background: var(--shell-link-hover);
    color: var(--text, #2d2d2d);
}

.admin-shell__foot-link--danger {
    color: var(--danger, #c44);
}

.admin-shell__content .admin-main,
.admin-shell__content .cms-main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

.admin-shell__content .alert {
    max-width: 1100px;
    width: calc(100% - 48px);
    margin-left: auto;
    margin-right: auto;
}

.admin-shell__mobile-bar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: #fff;
    border-bottom: 1px solid var(--shell-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-shell__menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--shell-border);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.admin-shell__menu-icon,
.admin-shell__menu-icon::before,
.admin-shell__menu-icon::after {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--text, #2d2d2d);
    border-radius: 1px;
    position: relative;
}

.admin-shell__menu-icon::before,
.admin-shell__menu-icon::after {
    content: "";
    position: absolute;
    left: 0;
}

.admin-shell__menu-icon::before { top: -6px; }
.admin-shell__menu-icon::after { top: 6px; }

.admin-shell__mobile-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-shell__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.admin-shell__backdrop:not([hidden]) {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* CMS — thème cohérent avec Qualiopi */
.admin-shell--cms {
    --shell-active-bg: #f4f6ef;
    --shell-active-border: #8a9070;
}

.admin-shell--cms .admin-shell__brand-title {
    color: #6b7355;
}

/* Qualiopi mode expert — même classes sidebar/content que CMS, grille 2 colonnes */
.admin-shell--mf-expert {
    --mf-header-h: 72px;
    display: grid;
    grid-template-columns: var(--shell-sidebar-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
        "header header"
        "sidebar main";
}

.admin-shell--mf-expert > .mf-header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 120;
    background: #fff;
    padding: 0;
    box-shadow: 0 1px 0 var(--shell-border);
    width: 100%;
}

.admin-shell--mf-expert > .admin-shell__sidebar {
    grid-area: sidebar;
    position: sticky;
    top: var(--mf-header-h);
    align-self: start;
    width: var(--shell-sidebar-w);
    height: calc(100dvh - var(--mf-header-h));
    display: flex;
    flex-direction: column;
    background: var(--shell-sidebar-bg);
    border-right: 1px solid var(--shell-border);
    overflow-y: auto;
    z-index: 110;
}

.admin-shell--mf-expert > .admin-shell__content {
    grid-area: main;
    margin-left: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - var(--mf-header-h));
}

.admin-shell--mf-expert .mf-header__inner {
    display: grid;
    grid-template-columns: var(--shell-sidebar-w) minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: var(--mf-header-h);
}

.admin-shell--mf-expert .mf-header__inner .admin-brand {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 1rem 10px 1.1rem;
    border-right: 1px solid var(--shell-border);
    min-height: var(--mf-header-h);
}

.admin-shell--mf-expert .mf-header__inner .mf-nav-primary {
    padding: 10px 24px;
}

.admin-shell--mf-expert .admin-shell__expert-badge {
    display: inline-block;
    margin-top: 0.35rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #ebe6dc;
    color: #6b5c45;
}

.admin-shell--mf-expert .admin-shell__content .admin-main {
    max-width: 1100px;
}

/* Accents univers Qualiopi dans la sidebar */
.admin-shell__link.accent-apprenants.admin-shell__link--active { border-color: rgba(107, 142, 127, 0.45); color: #4a6b5f; }
.admin-shell__link.accent-formations.admin-shell__link--active { border-color: rgba(168, 144, 95, 0.45); }
.admin-shell__link.accent-facturation.admin-shell__link--active { border-color: rgba(201, 168, 95, 0.45); color: #8a7040; }
.admin-shell__link.accent-organisme.admin-shell__link--active { border-color: rgba(138, 144, 112, 0.45); color: #5a6048; }

@media (max-width: 900px) {
    .admin-shell--main > .admin-shell__sidebar,
    .admin-shell--cms > .admin-shell__sidebar {
        transform: translateX(-100%);
    }

    .admin-shell--main.is-sidebar-open > .admin-shell__sidebar,
    .admin-shell--cms.is-sidebar-open > .admin-shell__sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }

    .admin-shell--main > .admin-shell__content,
    .admin-shell--cms > .admin-shell__content {
        margin-left: 0;
    }

    .admin-shell--main .admin-shell__mobile-bar,
    .admin-shell--cms .admin-shell__mobile-bar {
        display: flex;
    }

    /* Qualiopi expert — sidebar en tiroir, contenu pleine largeur */
    .admin-shell--mf-expert {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main";
    }

    .admin-shell--mf-expert .mf-header__inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 12px 16px;
        min-height: 0;
    }

    .admin-shell--mf-expert .mf-header__inner .admin-brand {
        border-right: 0;
        padding: 0;
        min-height: 0;
    }

    .admin-shell--mf-expert .mf-header__inner .mf-nav-primary {
        padding: 0;
    }

    .admin-shell--mf-expert > .admin-shell__sidebar {
        position: fixed;
        top: var(--mf-header-h);
        left: 0;
        width: min(var(--shell-sidebar-w), 88vw);
        height: calc(100dvh - var(--mf-header-h));
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 200;
    }

    .admin-shell--mf-expert.is-sidebar-open > .admin-shell__sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    }

    .admin-shell--mf-expert > .admin-shell__content {
        min-height: 0;
    }

    .admin-shell--mf-expert .admin-shell__content > .admin-shell__mobile-bar {
        display: none;
    }
}
