/**
 * FantasyLap — Sidebar droite
 * Rail permanent (desktop) + panneau coulissant.
 *
 * Variables:
 *   --rail-w  : largeur du rail (toujours visible sur desktop)
 *   --panel-w : largeur du panneau ouvert
 *
 * Comportement:
 *   Desktop (≥1024px) : body a padding-right = rail-w (fermé) ou rail-w + panel-w (ouvert)
 *   Mobile (<1024px)  : rail masqué, panneau = overlay right
 */

/* ================================================================
   Variables
   ================================================================ */
:root {
    --rail-w:  56px;
    --panel-w: 444px;
    --sidebar-bg:       #0f0f1c;
    --sidebar-bg-panel: #131326;
    --sidebar-border:   rgba(255, 255, 255, 0.07);
    --sidebar-hover:    rgba(255, 255, 255, 0.05);
    --sidebar-active:   rgba(59, 130, 246, 0.2);
    --sidebar-accent:   var(--accent);
    --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-rail-shadow: -2px 0 12px rgba(0, 0, 0, 0.35);
    --sidebar-panel-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
    --sidebar-panel-shadow-mobile: -8px 0 32px rgba(0, 0, 0, 0.6);
    --sidebar-search-input-bg: rgba(0, 0, 0, 0.28);
    --sidebar-focus-ring: rgba(96, 165, 250, 0.45);
    --sidebar-result-hover-bg: rgba(102, 126, 234, 0.18);
    --sidebar-notif-meta: rgba(255, 255, 255, 0.36);
    --sidebar-profile-card-bg: rgba(0, 0, 0, 0.22);
    --sidebar-danger-hover-bg: rgba(255, 77, 77, 0.12);
    --sidebar-toggle-hover-border: rgba(255, 255, 255, 0.18);
    --sidebar-backdrop-bg: rgba(0, 0, 0, 0.65);
    --sidebar-gold-soft: rgba(245, 200, 66, 0.1);
    --sidebar-gold-soft-mid: rgba(245, 200, 66, 0.13);
    --sidebar-gold-faint: rgba(245, 200, 66, 0.04);
    --sidebar-admin-hover-border: rgba(255, 255, 255, 0.1);
}

html[data-theme="light"] {
    --sidebar-bg:       #e3e6f2;
    --sidebar-bg-panel: #ecf0fb;
    --sidebar-border:   rgba(13, 13, 30, 0.09);
    --sidebar-hover:    rgba(13, 13, 30, 0.06);
    --sidebar-active:   rgba(37, 99, 235, 0.12);
    --sidebar-rail-shadow: -2px 0 12px rgba(13, 13, 30, 0.07);
    --sidebar-panel-shadow: -4px 0 20px rgba(13, 13, 30, 0.1);
    --sidebar-panel-shadow-mobile: -8px 0 32px rgba(13, 13, 30, 0.14);
    --sidebar-search-input-bg: rgba(255, 255, 255, 0.94);
    --sidebar-focus-ring: rgba(37, 99, 235, 0.35);
    --sidebar-result-hover-bg: rgba(102, 126, 234, 0.12);
    --sidebar-notif-meta: rgba(13, 13, 30, 0.42);
    --sidebar-profile-card-bg: rgba(13, 13, 30, 0.05);
    --sidebar-danger-hover-bg: rgba(204, 32, 32, 0.1);
    --sidebar-toggle-hover-border: rgba(13, 13, 30, 0.16);
    --sidebar-backdrop-bg: rgba(13, 13, 30, 0.4);
    --sidebar-gold-soft: rgba(212, 160, 0, 0.14);
    --sidebar-gold-soft-mid: rgba(212, 160, 0, 0.18);
    --sidebar-gold-faint: rgba(212, 160, 0, 0.07);
    --sidebar-admin-hover-border: rgba(13, 13, 30, 0.1);
}

html[data-theme="light"] .rail-btn img.nav-icon.nav-icon--img,
html[data-theme="light"] .rail-toggle img.rail-toggle-icon,
html[data-theme="light"] .rail-theme-toggle img.nav-icon.nav-icon--img,
html[data-theme="light"] .sidebar-tab img.nav-icon.nav-icon--img,
html[data-theme="light"] .sidebar-search-input-wrap img.sidebar-search-icon,
html[data-theme="light"] .sidebar-profile-link:not(.sidebar-profile-link--danger) img.nav-icon.nav-icon--img,
html[data-theme="light"] .nav-sidebar-btn img.nav-icon.nav-icon--img {
    filter: brightness(0) saturate(100%);
}

/* ================================================================
   Desktop : body ajuste son padding-right pour laisser la place au rail
   ================================================================ */
@media (min-width: 1024px) {
    body {
        padding-right: var(--rail-w);
        transition: padding-right var(--sidebar-transition);
    }

    body.sidebar-panel-open {
        padding-right: calc(var(--rail-w) + var(--panel-w));
    }
}

/* ================================================================
   Rail — bande étroite toujours visible sur desktop
   Le rail est à gauche du panneau : quand le panneau s'ouvre,
   le rail glisse vers la gauche de var(--panel-w).
   ================================================================ */
.sidebar-rail {
    position: fixed;
    right: 0;
    top: 0;
    height: 100dvh;
    width: var(--rail-w);
    background: var(--sidebar-bg);
    border-left: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0;
    gap: 0;
    z-index: 201;
    box-shadow: var(--sidebar-rail-shadow);
    transition: right var(--sidebar-transition);
}

@media (min-width: 1024px) {
    /* Quand le panneau est ouvert, le rail se décale vers la gauche */
    body.sidebar-panel-open .sidebar-rail {
        right: var(--panel-w);
    }
}

.rail-icons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    width: 100%;
    padding-top: 0.5rem;
}

/* Boutons d'icônes du rail */
.rail-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.rail-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text);
}

.rail-btn.is-active {
    background: var(--sidebar-active);
    color: var(--accent);
}

.rail-btn-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Taille des icônes dans le rail */
.rail-btn .nav-icon,
.rail-btn .nav-icon--img,
.rail-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: currentColor;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.rail-btn img.nav-icon.nav-icon--img {
    filter: brightness(0) invert(1);
    opacity: 0.6;
    object-fit: contain;
}

.rail-btn.is-active img.nav-icon.nav-icon--img,
.rail-btn:hover img.nav-icon.nav-icon--img {
    opacity: 1;
}

/* Badge sur le bouton notifications */
.rail-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--btn-text-on-accent);
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--sidebar-bg);
    pointer-events: none;
    line-height: 1;
}

.rail-badge.is-hidden {
    display: none;
}

/* Indicateur actif : trait vertical à gauche du bouton */
.rail-btn::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 24px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: transform 0.2s ease;
}

.rail-btn.is-active::before {
    transform: translateY(-50%) scaleY(1);
}

/* Thème clair/sombre : rail (desktop) et nav (mobile) */
.rail-theme-toggle {
    flex-shrink: 0;
    margin-bottom: 0.4rem;
}

.rail-theme-toggle-icon {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.rail-theme-toggle-icon img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    display: block;
}

html[data-theme="light"] .rail-theme-toggle .rail-theme-toggle-icon--to-dark {
    display: flex;
}

html[data-theme="dark"] .rail-theme-toggle .rail-theme-toggle-icon--to-light {
    display: flex;
}

.nav-sidebar-btn.rail-theme-toggle {
    position: relative;
    margin-bottom: 0; /* annule .rail-theme-toggle (marge rail) pour aligner avec le bouton menu */
}

.nav-sidebar-btn.rail-theme-toggle .rail-theme-toggle-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Bouton toggle bas du rail */
.rail-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 0.25rem;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.rail-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--text);
    border-color: var(--sidebar-toggle-hover-border);
}

.rail-toggle-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    image-rendering: pixelated;
    /* Flèche du fichier SVG : pointe à droite quand panneau fermé */
    transform: rotate(0deg);
    transition: transform var(--sidebar-transition);
}

.rail-toggle img.rail-toggle-icon {
    filter: brightness(0) invert(1);
    opacity: 0.65;
    object-fit: contain;
}

.rail-toggle:hover img.rail-toggle-icon {
    opacity: 1;
}

/* Quand le panneau est ouvert : flèche inversée */
body.sidebar-panel-open .rail-toggle-icon {
    transform: rotate(180deg);
}

/* ================================================================
   Panneau coulissant
   right: 0 → le panneau est contre le bord droit du viewport.
   Le rail (à gauche du panneau) glisse pour lui laisser la place.
   ================================================================ */
.sidebar-panel {
    position: fixed;
    right: 0;
    top: 0;
    height: 100dvh;
    width: var(--panel-w);
    background: var(--sidebar-bg-panel);
    border-left: 1px solid var(--sidebar-border);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Fermé : glisse hors du viewport vers la droite */
    transform: translateX(100%);
    transition: transform var(--sidebar-transition);
    box-shadow: var(--sidebar-panel-shadow);
}

body.sidebar-panel-open .sidebar-panel {
    transform: translateX(0);
}

/* ================================================================
   Mobile tabs (visibles uniquement sur mobile/tablette)
   ================================================================ */
.sidebar-mobile-tabs {
    display: none;
    align-items: stretch;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.6rem 0.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: var(--font-medium);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    border-bottom: 2px solid transparent;
}

.sidebar-tab:hover {
    background: var(--sidebar-hover);
    color: var(--text);
}

.sidebar-tab.is-active,
.sidebar-tab[aria-selected="true"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sidebar-tab-icon,
.sidebar-tab .nav-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    image-rendering: pixelated;
}

.sidebar-tab img.nav-icon.nav-icon--img {
    filter: brightness(0) invert(1);
    opacity: 0.6;
}

.sidebar-tab.is-active img.nav-icon.nav-icon--img {
    opacity: 1;
}

/* ================================================================
   Sections du panneau
   ================================================================ */
.sidebar-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar-section[hidden] {
    display: none;
}

/* En-tête de section */
.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.7rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    gap: 0.5rem;
}

.sidebar-section-title {
    font-family: var(--font-title);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

/* Corps de section */
.sidebar-section-body {
    flex: 1;
    min-height: 0;
    padding: 0.75rem;
    overflow-y: auto;
}

.sidebar-section-body--scroll {
    overflow-y: auto;
    padding: 0;
}

/* Footer de section */
.sidebar-section-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-footer-link {
    display: block;
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-gold);
    text-decoration: none;
    padding: 0.4rem;
    border-radius: var(--radius);
    transition: background 0.15s ease;
}

.sidebar-footer-link:hover {
    background: var(--sidebar-gold-soft);
    text-decoration: none;
}

/* ================================================================
   Section : Recherche
   ================================================================ */
.sidebar-search-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-icon {
    position: absolute;
    left: 0.65rem;
    width: 14px;
    height: 14px;
    fill: var(--text-muted);
    pointer-events: none;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.sidebar-search-input-wrap img.sidebar-search-icon {
    filter: brightness(0) invert(1);
    opacity: 0.55;
    object-fit: contain;
}

.sidebar-search-input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.25rem;
    font-family: var(--font-light);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--sidebar-search-input-bg);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-search-input::placeholder {
    color: var(--text-muted);
}

.sidebar-search-input:focus {
    outline: none;
    border-color: var(--font-header);
    box-shadow: 0 0 0 2px var(--color-secondary-muted);
}

/* Résultats de recherche */
.sidebar-search-results {
    display: flex;
    flex-direction: column;
    margin-top: 0.5rem;
}

.sidebar-search-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.5rem;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius);
    transition: background 0.15s ease;
}

.sidebar-search-result:hover {
    background: var(--surface-muted);
    color: var(--color-secondary);
    text-decoration: none;
}

.sidebar-search-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-search-avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--btn-text-on-accent);
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--sidebar-border);
    flex-shrink: 0;
    text-transform: uppercase;
}

.sidebar-search-username {
    font-weight: 500;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.sidebar-search-empty {
    padding: 1rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

/* ================================================================
   Section : Notifications
   ================================================================ */
.sidebar-notifs-markall {
    background: none;
    border: none;
    padding: 0.2rem 0.4rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    white-space: nowrap;
    transition: background 0.15s ease;
}

.sidebar-notifs-markall:hover {
    background: var(--surface-muted);
}

.sidebar-notifs-list {
    display: flex;
    flex-direction: column;
}

.nav-notifs-scroll {
    max-height: min(50vh, 360px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-notifs-infinite-status {
    padding: 0.65rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Item de notification dans le sidebar */
.sidebar-notif-empty {
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
}

/* Items générés par notifications.js (sidebar ou dropdown nav) */
[data-notifications-list] .nav-notifs-item:not(.nav-notifs-item--empty) {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

[data-notifications-list] .nav-notifs-item {
    padding: 0.75rem 1rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--sidebar-border);
    transition: background 0.15s ease;
}

[data-notifications-list] .nav-notifs-item-icon-wrap {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--sidebar-gold-faint);
    border: 1px solid var(--sidebar-border);
}

[data-notifications-list] .nav-notifs-item-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    opacity: 0.88;
    filter: brightness(0) invert(1);
}

[data-notifications-list] .nav-notifs-item:hover .nav-notifs-item-icon {
    opacity: 1;
}

html[data-theme="light"] [data-notifications-list] .nav-notifs-item-icon {
    filter: brightness(0) saturate(100%);
    opacity: 0.72;
}

html[data-theme="light"] [data-notifications-list] .nav-notifs-item:hover .nav-notifs-item-icon {
    opacity: 0.95;
}

[data-notifications-list] .nav-notifs-item:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

[data-notifications-list] .nav-notifs-item.is-unread {
    border-left: 3px solid var(--color-gold);
    background: var(--sidebar-gold-faint);
    padding-left: calc(1rem - 1px);
}

[data-notifications-list] .nav-notifs-item-body {
    flex: 1;
    min-width: 0;
}

[data-notifications-list] .nav-notifs-item-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25;
}

[data-notifications-list] .nav-notifs-item-msg {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-notifications-list] .nav-notifs-item-ago {
    margin-top: 0.2rem;
    font-size: 0.72rem;
    color: var(--sidebar-notif-meta);
}

[data-notifications-list] .nav-notifs-item-dot {
    width: 7px;
    height: 7px;
    border-radius: 99px;
    background: var(--color-gold);
    flex-shrink: 0;
}

[data-notifications-list] .nav-notifs-item--empty {
    padding: 1.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
    border-bottom: none;
}

[data-notifications-list] .nav-notifs-item.notif-kind--deadline.is-unread { border-left-color: var(--btn-secondary-bg); }
[data-notifications-list] .nav-notifs-item.notif-kind--account.is-unread  { border-left-color: var(--accent); }

/* ================================================================
   Section : Profil
   ================================================================ */
.sidebar-profile-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--sidebar-profile-card-bg);
    border-radius: var(--radius);
}

.sidebar-profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-profile-avatar--placeholder {
    background: var(--accent);
    color: var(--btn-text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-profile-name {
    font-family: var(--font-medium);
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-profile-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-family: var(--font-medium);
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-profile-link:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
}

.sidebar-profile-link--danger {
    color: var(--color-danger);
    margin-top: 0.5rem;
}

.sidebar-profile-link--danger:hover {
    background: var(--sidebar-danger-hover-bg);
}

.sidebar-profile-link .nav-icon,
.sidebar-profile-link .nav-icon--img {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    image-rendering: pixelated;
}

.sidebar-profile-link img.nav-icon.nav-icon--img {
    filter: brightness(0) invert(1);
    opacity: 0.7;
}

.sidebar-profile-link:hover img.nav-icon.nav-icon--img {
    opacity: 1;
}

.sidebar-profile-link--danger img.nav-icon.nav-icon--img {
    filter: brightness(0) saturate(100%) invert(45%) sepia(80%) saturate(500%) hue-rotate(320deg);
}

/* ================================================================
   Section : Menu (navigation principale — mobile/tablette)
   ================================================================ */
.sidebar-menu-nav {
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0;
}

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.92rem;
    font-family: var(--font-medium);
    border-radius: var(--radius);
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-menu-link:hover {
    background: var(--sidebar-hover);
    color: var(--text);
    text-decoration: none;
}

.sidebar-menu-link--danger {
    color: var(--color-risk, #cc2020);
}

.sidebar-menu-link--danger:hover {
    background: var(--sidebar-danger-hover-bg);
    color: var(--color-risk, #cc2020);
}

.sidebar-menu-link .nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: currentColor;
    image-rendering: pixelated;
}

.sidebar-menu-link img.nav-icon.nav-icon--img {
    filter: brightness(0) invert(1);
    opacity: 0.7;
    object-fit: contain;
}

.sidebar-menu-link:hover img.nav-icon.nav-icon--img {
    opacity: 1;
}

html[data-theme="light"] .sidebar-menu-link img.nav-icon.nav-icon--img {
    filter: brightness(0) saturate(100%);
    opacity: 0.72;
}

html[data-theme="light"] .sidebar-menu-link:hover img.nav-icon.nav-icon--img {
    opacity: 0.95;
}

.sidebar-menu-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 0.3rem 1rem;
    flex-shrink: 0;
}

/* ================================================================
   Section : Administration (back-office)
   ================================================================ */
.sidebar-admin-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar-admin-link {
    display: block;
    padding: 0.65rem 0.75rem;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-family: var(--font-medium);
    border: 1px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-admin-link:hover {
    background: var(--sidebar-hover);
    border-color: var(--sidebar-admin-hover-border);
    color: var(--accent);
    text-decoration: none;
}

/* ================================================================
   Backdrop (mobile)
   ================================================================ */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--sidebar-backdrop-bg);
    z-index: 149;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    animation: backdropFadeIn 0.2s ease forwards;
}

.sidebar-backdrop.is-active {
    display: block;
}

/* ================================================================
   Bouton "ouvrir sidebar" dans la nav (mobile uniquement)
   ================================================================ */
.nav-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 8px;
    background: transparent;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.nav-sidebar-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.nav-sidebar-btn .nav-icon,
.nav-sidebar-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    image-rendering: pixelated;
}

.nav-sidebar-btn img.nav-icon.nav-icon--img {
    filter: brightness(0) invert(1);
    opacity: 0.88;
}

/* Badge mobile sur le bouton bell de la nav */
.nav-sidebar-btn-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    align-self: center;
}

.nav-sidebar-mobile-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--btn-text-on-accent);
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-dark);
    pointer-events: none;
}

.nav-sidebar-mobile-badge.is-hidden {
    display: none;
}

/* Cache les boutons sidebar de la nav sur desktop (le rail suffit) */
@media (min-width: 1024px) {
    .nav-sidebar-btn,
    .nav-sidebar-btn-wrap {
        display: none;
    }
}

/* ================================================================
   Mobile / tablette (<1024px)
   ================================================================ */
@media (max-width: 1023px) {
    /* ---- Body : pas de padding, scroll lock à l'ouverture ---- */
    body {
        padding-right: 0 !important;
    }

    body.sidebar-panel-open {
        overflow: hidden;
    }

    /*
     * L'aside devient un conteneur fixe qui couvre TOUT le viewport.
     * overflow:hidden garantit que le panneau ne peut jamais dépasser
     * les bords de l'écran, quelle que soit la position du scroll ou
     * les quirks du navigateur mobile.
     * pointer-events:none → les clics traversent vers le backdrop.
     */
    #sidebar.sidebar {
        position: fixed;
        inset: 0;
        overflow: hidden;
        background: none;
        border: none;
        pointer-events: none;
        z-index: 200;
        margin: 0;
        padding: 0;
    }

    /* ---- Rail masqué sur mobile ---- */
    .sidebar-rail {
        display: none;
    }

    /*
     * Panneau : position absolute à l'intérieur du conteneur fixe.
     * Transformé hors de l'aside (clippé par overflow:hidden) quand fermé.
     */
    .sidebar-panel {
        position: absolute !important;
        top: 0;
        right: 0;
        height: 100%;
        width: min(340px, 92vw);
        box-shadow: none;
        pointer-events: none;
        transform: translateX(100%);
        transition:
            transform var(--sidebar-transition),
            box-shadow var(--sidebar-transition);
    }

    /* ---- Panneau ouvert ---- */
    body.sidebar-panel-open .sidebar-panel {
        transform: translateX(0);
        box-shadow: var(--sidebar-panel-shadow-mobile);
        pointer-events: auto;
    }

    /* ---- Tabs mobiles visibles ---- */
    .sidebar-mobile-tabs {
        display: flex;
    }
}

/* ================================================================
   Tablette (768px–1023px) : panneau légèrement plus large
   ================================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar-panel {
        width: min(360px, 75vw);
    }
}
