/* One role-based management menu, shared by normal and Sunday navigation.
   Scoped resets deliberately override the older !important card rules in Layout.css. */
body .navbar.custom-navbar {
    --tk-management-surface:#fffcf7;
    --tk-management-text:#483528;
    --tk-management-border:#ded5c7;
    --tk-management-hover:#eee5d6;
    --tk-management-accent:#795738;
    direction:ltr;
}
body.sb-dark .navbar.custom-navbar {
    --tk-management-surface:#242724;
    --tk-management-text:#f5f2eb;
    --tk-management-border:#555a50;
    --tk-management-hover:#373c34;
    --tk-management-accent:#d7bb8d;
}
.custom-navbar .tk-management > button.nav-link {
    appearance:none;border:0;background:transparent;cursor:pointer;font:inherit;
    display:flex;align-items:center;gap:8px;
}
body .navbar.custom-navbar #beheerMenu {
    width:260px!important;min-width:230px!important;
    max-width:calc(100vw - 40px)!important;
    margin-top:8px!important;padding:8px!important;
    background:var(--tk-management-surface)!important;
    border:1px solid var(--tk-management-border)!important;border-radius:14px!important;
    box-shadow:0 12px 32px #302d2824!important;
    max-height:calc(100vh - 112px);max-height:calc(100dvh - 112px);
    overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain;
}
body .navbar.custom-navbar #beheerMenu::before,
body .navbar.custom-navbar #beheerMenu::after {content:none!important;display:none!important;}
body .navbar.custom-navbar #beheerMenu .dropdown-item {
    display:block;min-height:44px;margin:0!important;padding:10px 12px!important;
    border:0!important;border-radius:8px!important;background:transparent!important;
    color:var(--tk-management-text)!important;box-shadow:none!important;
    white-space:normal;overflow-wrap:anywhere;font:500 14px/1.5 system-ui,sans-serif;
    text-align:start;text-decoration:none;transform:none!important;
}
body .navbar.custom-navbar #beheerMenu .dropdown-item:hover,
body .navbar.custom-navbar #beheerMenu .dropdown-item:focus-visible {
    background:var(--tk-management-hover)!important;
}
body .navbar.custom-navbar #beheerMenu .dropdown-item:focus-visible {
    outline:2px solid var(--tk-management-accent)!important;outline-offset:-2px;
}
body .navbar.custom-navbar.sunday-nav .tk-management-nav {
    display:flex;flex:0 0 auto;width:auto;margin:0;padding:0;list-style:none;
}
body .navbar.custom-navbar.sunday-nav .tk-management > button.nav-link {
    min-height:44px;margin:0;padding:10px 0!important;
    color:var(--tk-management-text)!important;background:transparent!important;border:0!important;
    font:500 14px/1.4 system-ui,sans-serif;text-align:start;
}
body .navbar.custom-navbar.sunday-nav #beheerMenu {
    position:absolute;inset:100% 0 auto auto;z-index:1100;
}
.custom-navbar .tk-management-caret {
    display:inline-block;flex:0 0 6px;width:6px;height:6px;
    border:solid currentColor;border-width:0 1.5px 1.5px 0;
    transform:translateY(-2px) rotate(45deg);
}
@media (max-width:991px) {
    body .navbar.custom-navbar.sunday-nav .tk-management-nav,
    body .navbar.custom-navbar.sunday-nav .tk-management {width:100%;min-width:0;}
    body .navbar.custom-navbar.sunday-nav .tk-management > button.nav-link {
        width:100%;padding:12px 6px!important;min-height:48px;
    }
    body .navbar.custom-navbar #beheerMenu {
        position:static!important;transform:none!important;inset:auto!important;
        width:100%!important;min-width:0!important;max-width:100%!important;
        max-height:none;overflow:visible!important;
        margin:4px 0 8px!important;padding:6px!important;box-shadow:none!important;
    }
}
/* Physical control order stays the same; Hebrew labels keep their reading direction. */
html[dir=rtl] .custom-navbar .nav-link,
html[dir=rtl] .custom-navbar .sunday-nav-links > a,
html[dir=rtl] body .navbar.custom-navbar #beheerMenu .dropdown-item {
    direction:rtl;text-align:right;
}

/* Desktop: navigation starts directly after the brand. Language/account controls
   keep their own right-hand columns, so translations cannot push over the menu. */
@media (min-width:992px) {
    body .navbar.custom-navbar:not(.sunday-nav) > .container-fluid {min-width:0;}
    body .navbar.custom-navbar:not(.sunday-nav) #navbarNav {
        display:grid!important;grid-template-columns:minmax(0,1fr) auto auto;
        align-items:center;gap:12px;min-width:0;flex:1 1 auto;
    }
    body .navbar.custom-navbar:not(.sunday-nav) #navbarNav > .navbar-nav {
        grid-column:1;grid-row:1;display:flex;flex:1 1 auto!important;width:100%!important;min-width:0;
        margin:0!important;flex-wrap:wrap;justify-content:flex-start!important;align-items:center;row-gap:0;
    }
    body .navbar.custom-navbar:not(.sunday-nav) #navbarNav > .tk-language-picker {
        grid-column:2;grid-row:1;justify-self:end;flex:0 0 auto;margin:0!important;
    }
    body .navbar.custom-navbar:not(.sunday-nav) #navbarNav > .d-lg-flex {
        grid-column:3;grid-row:1;justify-self:end;flex:0 0 auto;margin:0!important;
    }
}

/* Keep the psalm reading toolbar below the real (possibly two-line) header. */
body.songbook-page:not(.sunday-mode) {padding-top:calc(var(--tk-nav-offset,66px) + 12px);}
body.songbook-page.songbook-reader:not(.sunday-mode) .sb-reader-dock {
    top:calc(var(--tk-nav-offset,66px) + 12px);
}
