/* Sidebar theming.
 *
 * Every host used to carry its own copy of the sidebar background rule:
 * css/new_css/sidebar-custom.css (main host, #FFBA40), dm/css/dm.css,
 * ng/css/ng.css, obl/css/obl.css, section/narod/css/narod.css,
 * section/st/css/st.css, section/povo/css/povo.css — plus a duplicate of the
 * main-host block inline in the new_default base. That is one rule copied
 * seven times, changing only the colour, and the copies had drifted apart
 * (some also set a text/svg colour, some did not).
 *
 * Now the sidebar is styled once, here, from a single custom property. Each
 * host sets only --app-sidebar-bg (and optionally the foreground colours) on
 * the <html> element in its own base template. Anything left unset falls back
 * to the main-host values below.
 *
 * NOTE: loaded after AdminKit's app.css and sidebar-custom.css.
 */

:root {
    /* Main host default. A section base may override this on <html>. */
    --app-sidebar-bg: #FFBA40;
    /* Text/icons on the sidebar background. */
    --app-sidebar-fg: #212529;
    /* Hover / active states, derived but overridable per host. */
    --app-sidebar-hover-fg: #000000;
    --app-sidebar-hover-bg: rgba(0, 0, 0, 0.08);
    --app-sidebar-active-bg: rgba(0, 0, 0, 0.12);
}

/* Sidebar background - main containers */
.sidebar,
.sidebar-content {
    background: var(--app-sidebar-bg) !important;
}

/* Sidebar links and headers background */
.sidebar-link,
a.sidebar-link,
.sidebar-header,
.sidebar-brand {
    background: var(--app-sidebar-bg) !important;
    color: var(--app-sidebar-fg) !important;
}

/* All text in sidebar links */
.sidebar-link,
a.sidebar-link,
.sidebar-link span,
.sidebar-link .align-middle {
    color: var(--app-sidebar-fg) !important;
}

/* Font Awesome icons in sidebar (they use the color property) */
.sidebar i.fas,
.sidebar i.far,
.sidebar i.fab,
.sidebar i.fal,
.sidebar i.fad,
.sidebar .fa,
.sidebar-link i,
.sidebar-link .fa {
    color: var(--app-sidebar-fg) !important;
}

/* SVG icons (AdminKit draws some sidebar icons as inline svg) */
.sidebar-link svg {
    stroke: var(--app-sidebar-fg) !important;
    color: var(--app-sidebar-fg) !important;
}

/* Sidebar brand text */
.sidebar-brand,
.sidebar-brand span,
.sidebar-brand .align-middle {
    color: var(--app-sidebar-fg) !important;
}

/* Sidebar headers text */
.sidebar-header {
    color: var(--app-sidebar-fg) !important;
}

/* Links hover state */
.sidebar-link:hover,
a.sidebar-link:hover {
    color: var(--app-sidebar-hover-fg) !important;
    background-color: var(--app-sidebar-hover-bg) !important;
}

.sidebar-link:hover i,
a.sidebar-link:hover i {
    color: var(--app-sidebar-hover-fg) !important;
}

/* Active sidebar items */
.sidebar-item.active .sidebar-link,
.sidebar-link.active {
    color: var(--app-sidebar-hover-fg) !important;
    background-color: var(--app-sidebar-active-bg) !important;
}

.sidebar-item.active .sidebar-link i,
.sidebar-link.active i {
    color: var(--app-sidebar-hover-fg) !important;
}

/* Collapse/expand dropdown arrows */
.sidebar-header.dropdown-toggle::after {
    border-top-color: var(--app-sidebar-fg) !important;
}

/* Nested nav elements */
.sidebar-nav,
.sidebar-nav ul,
.sidebar-nav li {
    background: transparent !important;
}

.sidebar-nav .sidebar-link {
    background: var(--app-sidebar-bg) !important;
}

/* Breathing room at the bottom of the menu.
 *
 * When submenus are expanded the last link sat flush against the bottom edge
 * and was awkward to click.  Adding padding to the containers does not work:
 * AdminKit ships
 *
 *     .simplebar-content{display:flex;flex-direction:column;height:100vh;padding-bottom:0!important}
 *     .sidebar-nav{flex-grow:1}
 *
 * so .simplebar-content is exactly one viewport tall, and .sidebar-nav (which
 * has no flex-shrink:0) is *shrunk* to fit it instead of overflowing.  The
 * items get squashed into the edge and SimpleBar never sees a scrollHeight
 * greater than its clientHeight, so it shows no scrollbar at all.
 *
 * Letting the nav refuse to shrink makes the content taller than 100vh, so
 * SimpleBar registers the overflow and the menu scrolls normally; the spacer
 * below then guarantees the final item clears the bottom edge.
 */
.sidebar-nav {
    flex-shrink: 0;
}

/* The brand sits above the nav as the other direct flex child of
   .simplebar-content, so it must also refuse to shrink. */
.sidebar-content > .sidebar-brand {
    flex-shrink: 0;
}

.sidebar-nav::after {
    content: "";
    display: block;
    height: 3rem;
}

/* Belt and braces.  AdminKit forces
 * .simplebar-content{padding-bottom:0!important}, so padding on the scroll
 * container is a dead end; a margin on the last rendered item guarantees a
 * gap above the bottom edge even if the spacer above is ever removed. */
.sidebar-nav > li:last-of-type {
    margin-bottom: 1rem;
}

/* One menu item per line.
 *
 * The collapsible submenus are <ul class="nav collapse" id="...">, and
 * AdminKit's Bootstrap build ships `.nav{display:flex;flex-wrap:wrap}`.  That
 * makes each <li class="sidebar-item"> a flex item in a wrapping ROW, so short
 * labels fit several to a line (in English "History" and "Links" end up
 * side by side) and get squeezed narrower, which also shrinks their text.
 * Long Russian labels happen to fill the 260px width, which is why the
 * problem only shows up in English.
 *
 * Make every sub-list a column so each item occupies its own line, and stop
 * flex from squeezing the item's width.
 */
.sidebar-nav ul {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
}

.sidebar-nav ul > .sidebar-item,
.sidebar-nav > .sidebar-item {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
}
