/* ============================================================================
 * sidebar.css — Zone Sidebar gauche/droite (optionnelles)
 * Gère : affichage desktop, off-canvas mobile, push du contenu, overlay
 * Requiert : webcore.css, dark.css
 * Dépend de CB_WebCore.js pour les classes sidebar-left-open / sidebar-right-open
 * ==========================================================================*/

/* --- Base (desktop, intégrées au grid) --- */
.webcore-sidebar-left,
.webcore-sidebar-right {
    display: none;
    overflow-y: auto;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: var(--font-sm);
    transition: transform var(--wc-transition);
}
.webcore-sidebar-left  { grid-area: sidebar-left;  width: var(--wc-sidebar-left-w);  border-right: 1px solid var(--color-border); }
.webcore-sidebar-right { grid-area: sidebar-right; width: var(--wc-sidebar-right-w); border-left: 1px solid var(--color-border); }
.webcore-body.sidebar-left-enabled  .webcore-sidebar-left,
.webcore-sidebar-left:not([data-role="navigation"])         { display: flex; flex-direction: column; }
.webcore-body.sidebar-right-enabled .webcore-sidebar-right { display: flex; flex-direction: column; }

.webcore-sidebar-left::-webkit-scrollbar,
.webcore-sidebar-right::-webkit-scrollbar { width: 6px; }
.webcore-sidebar-left::-webkit-scrollbar-thumb,
.webcore-sidebar-right::-webkit-scrollbar-thumb {
    background: var(--color-border-input);
    border-radius: var(--radius-sm);
}

/* Overlay de fermeture (clic extérieur) */
.webcore-body-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--wc-overlay-bg);
    z-index: var(--wc-z-overlay);
}

/* --- En-tête sidebar : logo + bouton close --- */
/* .leftbar-header → renommé .sidebar-header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--wc-navbar-h);
    padding: 0 1.25rem;
    background: var(--color-elevated);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
/* .leftbar-logo → renommé .sidebar-logo */
.sidebar-logo {
    height: calc(var(--wc-navbar-h) - 0.75rem);
    width: auto;
    object-fit: contain;
}
/* .leftbar-title → renommé .sidebar-title */
.sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-accent);
}
/* .leftbar-close → renommé .sidebar-close */
.sidebar-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text);
    border-radius: var(--radius-sm);
    transition: background var(--wc-transition);
    flex-shrink: 0;
}
.sidebar-close:hover {
    background: var(--color-surface);
}
@media (max-width: 768px) {
    .sidebar-close {
        display: flex;
    }
}

/* --- Contenu sidebar --- */
/* .leftbar-body → renommé .sidebar-body */
.sidebar-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* --- Pied sidebar (optionnel) --- */
/* .leftbar-footer → renommé .sidebar-footer */
.sidebar-footer {
    flex-shrink: 0;
    padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--color-border);
    font-size: var(--font-xs);
    color: var(--color-text-muted);
}
.sidebar-profile {
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-border);
}

/* --- Mobile : off-canvas + push du reste du layout --- */
@media (max-width: 768px) {
    /* En-tête sidebar masqué — le close est dans la navbar (hamburger swap) */
    .sidebar-header { display: none; }

    /* Off-canvas piloté par le hamburger — réservé au rôle navigation */
    .webcore-sidebar-left[data-role="navigation"],
    .webcore-sidebar-right[data-role="navigation"] {
        display: flex;
        flex-direction: column;
        position: fixed;
        /* top: 0; — [remplacé] leftbar part du bas de la navbar, pas du haut de l'écran */
        top: var(--wc-navbar-h);
        bottom: 0;
        z-index: var(--wc-z-sidebar);
        width: 100%;
    }
    .webcore-sidebar-left[data-role="navigation"]  { left: 0;  transform: translateX(-100%); }
    .webcore-sidebar-right[data-role="navigation"] { right: 0; transform: translateX(100%); }

    /* Toute sidebar hors rôle navigation : off en mobile pour éviter le conflit avec le hamburger */
    .webcore-sidebar-left:not([data-role="navigation"]),
    .webcore-sidebar-right:not([data-role="navigation"]) {
        display: none;
    }

    .webcore-body.sidebar-left-open  .webcore-sidebar-left[data-role="navigation"]  { transform: translateX(0); }
    .webcore-body.sidebar-right-open .webcore-sidebar-right[data-role="navigation"] { transform: translateX(0); }

    /* [remplacé] .webcore-navbar n'est plus poussée — navbar toujours visible */
    /*.webcore-body.sidebar-left-open .webcore-navbar,*/
    .webcore-body.sidebar-left-open .webcore-body-content,
    .webcore-body.sidebar-left-open .webcore-footer {
        transform: translateX(var(--wc-sidebar-left-w));
    }
    /*.webcore-body.sidebar-right-open .webcore-navbar,*/
    .webcore-body.sidebar-right-open .webcore-body-content,
    .webcore-body.sidebar-right-open .webcore-footer {
        transform: translateX(calc(-1 * var(--wc-sidebar-right-w)));
    }
    /*.webcore-body.sidebar-left-open.sidebar-right-open .webcore-navbar,*/
    .webcore-body.sidebar-left-open.sidebar-right-open .webcore-body-content,
    .webcore-body.sidebar-left-open.sidebar-right-open .webcore-footer {
        transform: translateX(calc(var(--wc-sidebar-left-w) - var(--wc-sidebar-right-w)));
    }

    .webcore-body.sidebar-left-open .webcore-body-overlay,
    .webcore-body.sidebar-right-open .webcore-body-overlay {
        display: block;
    }
    .webcore-body.sidebar-left-open,
    .webcore-body.sidebar-right-open {
        overflow: hidden;
    }
}

/* --- Sidebar footer : boutons pleine largeur --- */
.sidebar-footer { display: flex; gap: 0.5rem; }
.sidebar-footer .btn { flex: 1; }

/* --- Conteneur de boutons côte à côte --- */
.btns-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

/* --- Section de panneau latéral --- */
.sidebar-section {
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-subtle);
    margin-bottom: 0.5rem;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-subtle);
    margin: 0 0 0.5rem;
}

.sidebar-section > .sidebar-section-h2:first-child { margin-top: 0; }

.sidebar-section-h2 {
    display: block;
    margin: 30px 2px 0.5rem;
    padding: 0.3rem 0.5rem;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    text-align: center;
    color: var(--color-warning, #f59e0b);
    background: color-mix(in srgb, var(--color-border) 35%, var(--color-surface));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* --- Champs de panneau latéral --- */
.sidebar-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 0.5rem;
}

.sidebar-field + .sidebar-field { margin-top: 20px; }

.sidebar-label {
    font-size: 11px;
    color: var(--color-text-subtle);
}

/* --- Grille de widgets --- */
/* Une seule colonne : chaque item tient sur sa propre ligne, sans jamais
   avoir à retourner à la ligne quel que soit la longueur du libellé. */
.sidebar-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-subtle);
    cursor: grab;
    font-size: var(--font-sm);
    user-select: none;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.sidebar-item-icone {
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-item-label {
    flex: 1;
    min-width: 0;
}

.sidebar-item:active { cursor: grabbing; }

.sidebar-item:hover {
    background-color: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg));
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* --- Item de menu admin (sidebar admin_menu) : flèche épingle + lien --- */
.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.sidebar-menu-item .nav-link {
    flex: 1;
    min-width: 0;
}

.sidebar-menu-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-subtle);
    border-radius: var(--radius-sm);
    transition: background-color 0.12s, color 0.12s;
}

.sidebar-menu-pin:hover {
    background-color: color-mix(in srgb, var(--color-accent) 10%, var(--color-bg));
    color: var(--color-accent);
}

/* --- Filtres pleine largeur dans une sidebar (ex: emails) --- */
.sidebar-body .data-filters {
    flex-direction: column;
    align-items: stretch;
}
.sidebar-body .filter-select {
    width: 100%;
}