/* ============================================================
   Layout commun pour toutes les pages avec sidebar
   ============================================================ */

/* ---------- Sidebar ---------- */
.sidebar {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-right: 1px solid var(--border-default);
    height: 100vh;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    color: var(--text-primary);
    transition: background-color 0.15s ease;
}
.sidebar-item:hover { background-color: var(--bg-hover); }
.sidebar-item.active {
    background-color: var(--accent-green);
    color: white;
    font-weight: 600;
}

.sidebar-section-title { color: var(--text-muted); }
.sidebar-logo-text { color: var(--text-secondary); }

.sidebar-close-btn {
    color: var(--text-primary);
    transition: background-color 0.15s ease;
}
.sidebar-close-btn:hover { background-color: var(--bg-hover); }

/* ---------- Sidebar mobile ---------- */
.sidebar-mobile {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
}
.sidebar-mobile.open { transform: translateX(0); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
}
.sidebar-overlay.open { display: block; }

/* ---------- Topbar ---------- */
.app-topbar {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-default);
}
.app-topbar-item { color: var(--accent-green); }
.app-topbar-item:hover {
    color: var(--accent-green-dark);
    background-color: var(--bg-hover);
}
.app-topbar-username { color: var(--accent-green); }

/* ---------- Dropdowns ---------- */
.app-dropdown {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}
.app-dropdown-header { border-bottom: 1px solid var(--border-default); }
.app-dropdown-footer { border-top: 1px solid var(--border-default); }

.app-dropdown-item { color: var(--text-primary); }
.app-dropdown-item:hover { background-color: var(--bg-hover); }
.app-dropdown-item-unread { background-color: rgba(17, 24, 39, 0.3); }
[data-theme="light"] .app-dropdown-item-unread {
    background-color: rgba(59, 130, 246, 0.05);
}

/* ---------- Main ---------- */
.app-main-sidebar {
    background-color: var(--bg-page);
    color: var(--text-primary);
}

/* ---------- Toggle thème ---------- */
[data-theme-toggle] { cursor: pointer; }

#topbar-title {
    transition: opacity 0.2s ease;
}
#topbar-title.updating {
    opacity: 0;
}

/* ══════════════════════════════════════════════════════════════
   FORCE LA SIDEBAR DESKTOP EN FLEX-COLUMN
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
    .sidebar {
        display: flex !important;
        flex-direction: column !important;
        height: 100vh !important;
    }
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR COLLAPSE — Bouton toggle (style Google Maps)
   ══════════════════════════════════════════════════════════════ */

/* Transition douce du glissement */
.sidebar {
    transition: margin-left 0.25s ease;
    will-change: margin-left;
}

/* État replié : la sidebar sort à gauche, le contenu prend sa place */
body.sidebar-is-collapsed .sidebar {
    margin-left: -18rem; /* = w-72 */
}

/* État replié : la sidebar sort à gauche, le contenu prend sa place */
body.app-topbar-is-hidden .app-topbar {
    transform: translateY(-100%) !important;
    display: none !important; /* Masque la barre supérieure */
}

/* ──────────────────────────────────────────────────────────
   Bouton — sticky, sidebar
   ────────────────────────────────────────────────────────── */
.sidebar-toggle-btn {
    position: sticky;
    top: 1.6rem;
    left: 0;

    z-index: 30;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 48px;

    /* collé au bord gauche */
    margin: 0.5rem 0 -64px 0;

    /* Google Maps style */
    border-radius: 0 16px 16px 0;

    background: var(--bg-page);
    border: 1px solid var(--border-default);
    border-left: none;

    color: var(--text-secondary);

    opacity: 0.5;
    cursor: pointer;

    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.12);

    transition:
        background-color 0.2s ease,
        transform 0.15s ease,
        opacity 0.2s ease;
}
.sidebar-toggle-btn i {
    font-size: 0.9rem;
    transition: transform 0.25s ease;
}
.sidebar-toggle-btn:hover {
    background: var(--bg-hover);
    opacity: 1;
}

.sidebar-toggle-btn::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--border-default);
}

/* Chevron inversé quand la sidebar est repliée */
body.sidebar-is-collapsed .sidebar-toggle-btn {
    opacity: 0.5;
}
body.sidebar-is-collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}
/* ──────────────────────────────────────────────────────────
   Thème sombre
   ────────────────────────────────────────────────────────── */
[data-theme="dark"] .sidebar-toggle-btn {
    background: rgba(30, 41, 59, 0.9);
    border-color: #334155;
    color: #94a3b8;
}
[data-theme="dark"] .sidebar-toggle-btn:hover {
    background: rgba(51, 65, 85, 0.9);
    color: #e2e8f0;
}

/* ──────────────────────────────────────────────────────────
   Mobile : masqué (le drawer mobile a son propre contrôle)
   ────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    .sidebar-toggle-btn {
        display: none;
    }
}
/* ──────────────────────────────────────────────────────────
   Bouton — sticky, Topbar
   ────────────────────────────────────────────────────────── */
.topbar-toggle-btn {
    position: sticky;
    top: 0rem;
    left: 0rem;
    /* transform: translateX(-50%); */

    z-index: 40;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 48px;
    height: 28px;

    background: var(--bg-page);
    border: 1px solid var(--border-default);
    border-top: none;

    /* version horizontale du toggle sidebar */
    border-radius: 0 0 16px 16px;

    color: var(--text-secondary);

    opacity: 0.5;
    cursor: pointer;

    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);

    transition:
        background-color 0.2s ease,
        opacity 0.2s ease,
        transform 0.15s ease;
}

.topbar-toggle-btn:hover {
    background: var(--bg-hover);
    opacity: 1;
}

.topbar-toggle-btn i {
    font-size: 0.9rem;
    transition: transform 0.25s ease;
}
.topbar-toggle-btn::before {
    content: "";
    position: absolute;

    top: 0;
    left: 6px;
    right: 6px;

    height: 1px;
    background: var(--border-default);
}
/* Chevron inversé quand la topbar est repliée */
body.app-topbar-is-hidden .topbar-toggle-btn {
    opacity: 0.5;
}
body.app-topbar-is-hidden .topbar-toggle-btn i {
    transform: rotate(180deg);
}
/* ──────────────────────────────────────────────────────────
   Thème sombre pour le topbar
   ────────────────────────────────────────────────────────── */
[data-theme="dark"] .topbar-toggle-btn {
    background: rgba(30, 41, 59, 0.9);
    border-color: #334155;
    color: #94a3b8;
}
[data-theme="dark"] .topbar-toggle-btn:hover {
    background: rgba(51, 65, 85, 0.9);
    color: #e2e8f0;
}