/**
 * Shell admin : header épuré + sidebar gauche
 */

:root {
    --header-height-minimal: 140px;
}

.header--minimal {
    height: var(--header-height-minimal);
    overflow: visible;
}

.header--minimal .header-container,
.header--minimal .header-content {
    height: 100%;
}

.header--minimal .header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0 var(--spacing-md);
}

.header--minimal .header-zone--left {
    grid-column: 1;
    justify-self: start;
    flex-shrink: 0;
    gap: 0.65rem;
}

.header--minimal .header-zone--center {
    grid-column: 2;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    padding-left: 0;
    margin: 0;
    overflow: visible;
}

.header--minimal .header-zone--right {
    grid-column: 3;
    justify-self: end;
    flex-shrink: 0;
    margin-left: 0;
}

.header--minimal .header-zone {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-logo .logo-text {
    font-size: 1.15rem;
}

.header--minimal .header-logo img {
    height: 100px;
    width: auto;
}

.header-spacer {
    height: var(--header-height-minimal);
}

.header-context-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.85rem 1.75rem 1.15rem;
    margin: 0.35rem 50px;
    border-radius: 12px;
    border: 1px solid #dbe7f5;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f6fc 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    text-align: center;
    overflow: visible;
}

.header-context-card--platform {
    border-color: #e3d8f0;
    background: linear-gradient(180deg, #faf8ff 0%, #f3eefb 100%);
}

.header-context-card--clickable {
    cursor: pointer;
    font: inherit;
    color: inherit;
    position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.header-context-card--clickable:hover {
    border-color: #90caf9;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.12);
}

.header-context-card__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #78909c;
    width: 100%;
    text-align: center;
}

.header-context-card--platform .header-context-card__label {
    color: #7e57c2;
}

.header-context-card--platform-active {
    border-color: #d1c4e9;
    background: linear-gradient(180deg, #faf8ff 0%, #f3eefb 55%, #f8fbff 100%);
}

.header-context-card__mode-tag {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6a1b9a;
    background: #ede7f6;
    border-radius: 999px;
    padding: 0.12rem 0.45rem;
    margin-bottom: 0.1rem;
    align-self: center;
}

.header-context-card__value {
    font-size: 1rem;
    font-weight: 600;
    color: #263238;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    width: 100%;
    text-align: center;
}

.header-context-card__action {
    position: absolute;
    right: 0;
    bottom: 0;
    transform: translate(40%, 42%);
    font-size: 0.72rem;
    font-weight: 600;
    color: #1565c0;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 999px;
    padding: 0.28rem 0.7rem;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.22);
    line-height: 1.2;
    white-space: nowrap;
    z-index: 2;
    pointer-events: none;
}

.user-panel-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 999px;
    padding: 0.3rem 0.75rem 0.3rem 0.35rem;
    cursor: pointer;
    font: inherit;
    color: var(--color-dark);
}

.user-panel-btn:hover {
    border-color: #bdbdbd;
    background: #fafafa;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1976d2, #42a5f5);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-panel-email {
    font-size: 0.78rem;
    color: #666;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-toggle {
    display: none;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.app-shell {
    display: flex;
    min-height: calc(100vh - var(--header-height-minimal));
}

.app-main {
    flex: 1;
    min-width: 0;
    margin: 0;
}

/* Apps : pas de breakout pleine viewport (shell persistant avec sidebar) */
.app-main .gderpi-shell,
.app-main .pm-shell,
.app-main .annuaire-shell {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.app-main .agent-editor-app {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 1rem 1.25rem 1.5rem;
    box-sizing: border-box;
}

.admin-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #f5f9ff;
    border-right: 1px solid #dbe7f5;
    padding: 1rem 0.75rem 0.5rem;
    position: sticky;
    top: var(--header-height-minimal);
    height: calc(100vh - var(--header-height-minimal));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, padding 0.2s ease;
}

.admin-sidebar__collapse-btn {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    background: #fff;
    color: #546e7a;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

.admin-sidebar__collapse-btn:hover {
    background: #eef3f7;
}

.app-shell.sidebar-collapsed .admin-sidebar {
    width: 72px;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
}

.app-shell.sidebar-collapsed .admin-sidebar__section-label,
.app-shell.sidebar-collapsed .admin-sidebar__link-text,
.app-shell.sidebar-collapsed .admin-sidebar__collapse-label,
.app-shell.sidebar-collapsed .sidebar-mode-picker__label,
.app-shell.sidebar-collapsed .sidebar-mode-picker__chevron,
.app-shell.sidebar-collapsed .sidebar-mode-picker__option-text,
.app-shell.sidebar-collapsed .admin-sidebar__hint,
.app-shell.sidebar-collapsed .admin-sidebar__hint-btn {
    display: none !important;
}

.app-shell.sidebar-collapsed .admin-sidebar__link {
    justify-content: center;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.app-shell.sidebar-collapsed .admin-sidebar__collapse-btn {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.app-shell.sidebar-collapsed .sidebar-mode-picker__current {
    justify-content: center;
}

@media (min-width: 993px) {
    .app-shell.sidebar-collapsed .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

.admin-sidebar--platform {
    background: #f6f2fb;
    border-right-color: #e3d8f0;
}

.admin-sidebar__switch {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.admin-sidebar__switch-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.admin-sidebar__switch-btn--to-platform {
    background: #ede7f6;
    color: #4527a0;
    border-color: #d1c4e9;
}

.admin-sidebar__switch-btn--to-platform:hover {
    background: #e1d5f3;
}

.admin-sidebar__switch-btn--to-entity {
    background: #e3f2fd;
    color: #1565c0;
    border-color: #bbdefb;
}

.admin-sidebar__switch-btn--to-entity:hover {
    background: #d2e9fc;
}

.admin-sidebar__section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: #78909c;
    margin: 0 0 0.65rem 0.55rem;
}

.admin-sidebar--platform .admin-sidebar__section-label {
    color: #7e57c2;
}

.admin-sidebar__nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.admin-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.7rem;
    border-radius: 8px;
    color: #37474f;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 0.15rem;
}

.admin-sidebar--platform .admin-sidebar__link {
    color: #4a148c;
}

.admin-sidebar__link:hover {
    background: rgba(25, 118, 210, 0.08);
}

.admin-sidebar--platform .admin-sidebar__link:hover {
    background: rgba(103, 58, 183, 0.1);
}

.admin-sidebar__link.is-active {
    background: #1976d2;
    color: #fff;
}

.admin-sidebar--platform .admin-sidebar__link.is-active {
    background: #673ab7;
    color: #fff;
}

.admin-sidebar__link-icon {
    width: 1.25rem;
    text-align: center;
}

.admin-sidebar__hint {
    font-size: 0.82rem;
    color: #607d8b;
    padding: 0 0.55rem;
    line-height: 1.4;
}

.admin-sidebar__hint-btn {
    margin: 0.75rem 0.55rem 0;
    width: calc(100% - 1.1rem);
    border: 1px dashed #90caf9;
    background: #fff;
    color: #1565c0;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.82rem;
}

.admin-sidebar-backdrop {
    display: none;
}

.dropdown-menu--right {
    right: 0;
    left: auto;
}

.user-panel .dropdown-menu {
    min-width: 210px;
}

@media (max-width: 992px) {
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .user-panel-email {
        display: none;
    }

    .header--minimal .header-logo img {
        height: 80px;
    }

    .header-logo .logo-text {
        display: none;
    }

    .header-context-card {
        padding: 0.7rem 1.25rem 0.95rem;
        margin: 0.25rem 50px;
    }

    .header-context-card__action {
        transform: translate(35%, 38%);
        font-size: 0.68rem;
        padding: 0.22rem 0.55rem;
    }

    .admin-sidebar {
        position: fixed;
        left: 0;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-md);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
    }

    .admin-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: var(--header-height-minimal) 0 0 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1090;
    }

    .admin-sidebar-backdrop[hidden] {
        display: none;
    }
}

@media (max-width: 576px) {
    .header-context-card {
        margin-left: 16px;
        margin-right: 16px;
    }

    .header-context-card__value {
        font-size: 0.85rem;
    }
}

.header-context-card--compact {
    width: auto;
    min-width: 0;
    padding: 0.45rem 0.85rem 0.55rem;
    margin: 0;
}

.sidebar-mode-picker {
    position: relative;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.sidebar-mode-picker__current {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.7rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    border: 1px solid transparent;
    user-select: none;
}

.sidebar-mode-picker--platform .sidebar-mode-picker__current {
    background: #ede7f6;
    color: #4527a0;
    border-color: #d1c4e9;
}

.sidebar-mode-picker--entity .sidebar-mode-picker__current {
    background: #e3f2fd;
    color: #1565c0;
    border-color: #bbdefb;
}

.sidebar-mode-picker--user .sidebar-mode-picker__current {
    background: #e8f5e9;
    color: #2e7d32;
    border-color: #c8e6c9;
}

.sidebar-mode-picker__icon {
    font-size: 1rem;
    line-height: 1;
}

.sidebar-mode-picker__label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-mode-picker__chevron {
    font-size: 0.7rem;
    opacity: 0.75;
    transition: transform 0.15s ease;
}

.sidebar-mode-picker__menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    padding-top: 6px;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
}

.sidebar-mode-picker:hover .sidebar-mode-picker__menu,
.sidebar-mode-picker:focus-within .sidebar-mode-picker__menu {
    display: block;
}

.sidebar-mode-picker:hover .sidebar-mode-picker__chevron,
.sidebar-mode-picker:focus-within .sidebar-mode-picker__chevron {
    transform: rotate(180deg);
}

.sidebar-mode-picker__option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    color: #37474f;
    background: #fff;
    border: 1px solid #dee2e6;
    border-top: none;
}

.sidebar-mode-picker__option:first-child {
    border-top: 1px solid #dee2e6;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.sidebar-mode-picker__option:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.sidebar-mode-picker__option:only-child {
    border-radius: 8px;
}

.sidebar-mode-picker__option:hover {
    background: #f8f9fa;
}

.sidebar-mode-picker__option.is-active {
    background: #f1f3f5;
}

.sidebar-mode-picker__option--platform.is-active {
    color: #4527a0;
}

.sidebar-mode-picker__option--entity.is-active {
    color: #1565c0;
}

.sidebar-mode-picker__option--user.is-active {
    color: #2e7d32;
}

.admin-sidebar--mode-user {
    background: #f8faf8;
    border-right-color: #dfe8df;
}
