/* Structure de la page admin : sidebar, contenu principal, responsive mobile. */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
}

.nav-links {
    padding: 1.5rem 1rem 1rem;
    flex: 1;
    overflow-y: auto;
    margin: 0;
    list-style: none;
}

.nav-links::-webkit-scrollbar {
    width: 4px;
}

.nav-links::-webkit-scrollbar-track {
    background: transparent;
}

.nav-links::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: calc(10px * var(--radius-scale));
}

.nav-links::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: calc(12px * var(--radius-scale));
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-link.active {
    background: var(--sidebar-active);
    color: var(--primary);
}

.nav-parent {
    cursor: pointer;
    justify-content: space-between;
}

.nav-parent .chevron {
    font-size: 0.75rem;
    transition: transform 0.3s;
}

.nav-item.open .nav-parent .chevron {
    transform: rotate(180deg);
}

.nav-submenu {
    list-style: none;
    padding-left: 1.5rem;
    margin: 0.25rem 0;
    display: none;
}

.nav-item.open .nav-submenu {
    display: block;
}

.nav-submenu .nav-link {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
}

.nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.5rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: calc(50% * var(--radius-scale));
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    overflow: hidden;
}

.user-info .name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.user-info .role {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.theme-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
}

.theme-toggle:hover {
    border-color: var(--primary);
}

.appearance-picker {
    position: relative;
}

.appearance-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: calc(12px * var(--radius-scale));
    box-shadow: var(--shadow-md);
    padding: 0.75rem;
    z-index: 50;
}

.appearance-popup.show {
    display: block;
}

.appearance-popup-group + .appearance-popup-group {
    margin-top: 0.75rem;
}

.appearance-popup-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.appearance-popup-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.appearance-option {
    flex: 1;
    min-width: 60px;
    padding: 0.4rem 0.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: calc(8px * var(--radius-scale));
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.appearance-option:hover {
    border-color: var(--primary);
    color: var(--text-main);
}

.appearance-option[data-active="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    transition: var(--transition);
    /* A flex child defaults to min-width: auto, so any wide descendant (a
       table, a long title) pushes the whole page past the viewport. */
    min-width: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.page-title h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
}

.mobile-close {
    display: none;
    margin: 1rem 1rem 0 auto;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}

.mobile-toggle {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: calc(10px * var(--radius-scale));
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    font-size: 1.2rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        /* Was 0: every admin page sat flush against both screen edges, and
           the bell's badge hung off the right edge. */
        padding: 1rem !important;
    }

    .top-bar {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .page-title {
        flex: 1;
        min-width: 0;
    }

    .page-title h1 {
        font-size: 1.35rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-bar-actions {
        gap: 8px;
        flex-shrink: 0;
    }

    .mobile-toggle {
        display: flex !important;
    }

    .sidebar-overlay {
        display: block;
    }

    .mobile-close {
        display: flex !important;
    }
}
