body {
    font-family: var(--font-family-base);
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
}

/* Layout principal */
#mainContent {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 1rem;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ #mainContent {
    margin-left: var(--sidebar-collapsed-width);
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

.sidebar-overlay {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100% - var(--header-height));
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    display: none;
}

@media (max-width: 768px) {
    #mainContent {
        margin-left: 0;
    }
    
    .sidebar.show ~ .sidebar-overlay {
        display: block;
    }
}

.theme-transitions * {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ── Unified page-level toast container ─────────────────────────────────────
   All JS alerts (showPageAlert) and Django server messages render here.
   Fixed just below the header so it is always visible regardless of scroll.
   ─────────────────────────────────────────────────────────────────────────── */
#page-toasts {
    position: fixed;
    top: calc(var(--header-height) + 0.5rem);
    right: 1rem;
    z-index: 1090;          /* above Bootstrap modals and aligned with Bootstrap toasts (~1090) */
    width: min(420px, calc(100vw - 2rem));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;   /* let clicks pass through the empty area */
}

#page-toasts .page-toast {
    pointer-events: all;    /* but the alerts themselves are clickable */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius);
    font-family: var(--font-family-base);
    font-size: 0.9rem;
    margin: 0;              /* gap on the flex container handles spacing */
    word-break: break-word;
}

@media (max-width: 576px) {
    #page-toasts {
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
    }
}
