/*
 * App specific styling on top of Tabler.
 *
 * Tabler (libs/tabler/tabler.min.css) provides the layout, cards, tables, forms and
 * buttons. Everything here is either app furniture Tabler has no component for
 * (the classification bars) or glue that makes a third party widget look native.
 */

/* ---------------------------------------------------------------------- *
 * Classification banners
 *
 * Named apart from Tabler's own .footer so the two never fight. The colour is
 * set inline from GlobalProperties.
 * ---------------------------------------------------------------------- */
:root {
    --classification-height: 1.5rem;
}

/* Tabler's "-darken" colours, used for the hover, focus and active states of the solid buttons, are the colour
   made 20% transparent, which over a white page is lighter, not darker: the primary button's hover and focus
   fell to 3.4:1 under its light text (WCAG 1.4.3). Darker for real, for the colours that carry light text. */
:root,
[data-bs-theme] {
    --tblr-primary-darken: color-mix(in oklab, var(--tblr-primary), black 15%);
    --tblr-secondary-darken: color-mix(in oklab, var(--tblr-secondary), black 15%);
    --tblr-success-darken: color-mix(in oklab, var(--tblr-success), black 15%);
    --tblr-info-darken: color-mix(in oklab, var(--tblr-info), black 15%);
    --tblr-danger-darken: color-mix(in oklab, var(--tblr-danger), black 15%);
}

.classification-bar {
    position: fixed;
    left: 0;
    width: 100%;
    height: var(--classification-height);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Fallback for when GlobalProperties supplies no banner colour; the inline
       style from the template wins whenever one is configured. */
    background-color: darkgreen;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    /* Above Tabler's fixed sidebar (1030), below modals. */
    z-index: 1045;
}

.classification-bar-top {
    top: 0;
}

.classification-bar-bottom {
    bottom: 0;
}

/* Not licensed (classification-banners): the layout renders no bars, so reserve no room. */
body.no-classification {
    --classification-height: 0px;
}

/* The bars are fixed, so the page reserves room for them. */
body {
    padding-top: var(--classification-height);
    padding-bottom: var(--classification-height);
}

/* Tabler pins the sidebar to the viewport edges; hold it between the bars. Tabler also gives it
   overflow-y: scroll, which draws an empty scrollbar track whenever the menu fits; a scrollbar only
   when the menu is taller than the window. */
@media (min-width: 992px) {
    .navbar-vertical.navbar-expand-lg {
        top: var(--classification-height);
        bottom: var(--classification-height);
        overflow-y: auto;
    }
}

/* ---------------------------------------------------------------------- *
 * Sidebar logo
 *
 * The mark is screened over the sidebar: screen keeps the white glyph opaque
 * while its anti-aliased edges fall back toward the sidebar colour, so it
 * reads as printed on the sidebar rather than pasted over it.
 *
 * Deliberately no `filter` here. Recolouring a dark logo with
 * brightness(0) invert(1) works, but a filtered element gets rasterised - at
 * CSS-pixel resolution, then scaled up on HiDPI/scaled displays, which looks
 * pixelated. The sidebar therefore loads artwork that is already white
 * (in-n-out-light.svg) and stays pure vector.
 * ---------------------------------------------------------------------- */
.navbar-brand-image {
    height: 2.5rem;
    width: auto;
    max-width: 100%;
    mix-blend-mode: screen;
}

.navbar-vertical .navbar-brand {
    padding: 0.75rem 0.5rem;
    width: 100%;
    justify-content: center;
}

.wrap-with-underscores {
    word-break: break-all;
    overflow-wrap: anywhere;
}

.fc-note {
    font-size: 0.75rem;
    color: var(--tblr-primary);
}

/* FullCalendar sits inside Tabler cards; drop its default heavy borders. */
.fc .fc-toolbar-title {
    font-size: 1.1rem;
}

/* ---------------------------------------------------------------------- *
 * Tabulator
 *
 * The bundled Tabulator theme is the library default (grey chrome, its own
 * type scale). These rules re-skin it with Tabler's tokens so the data tables
 * read as part of the same UI.
 * ---------------------------------------------------------------------- */
.tabulator {
    background-color: var(--tblr-bg-surface);
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    font-size: 0.875rem;
    color: var(--tblr-body-color);
}

.tabulator .tabulator-header,
.tabulator .tabulator-footer {
    background-color: var(--tblr-bg-surface-secondary);
    border-color: var(--tblr-border-color);
    color: var(--tblr-secondary);
    font-weight: 600;
}

.tabulator .tabulator-header .tabulator-col {
    background-color: transparent;
    border-right: var(--tblr-border-width) solid var(--tblr-border-color);
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
    padding: 0.5rem 0.75rem;
}

.tabulator .tabulator-row {
    background-color: var(--tblr-bg-surface);
    border-bottom: var(--tblr-border-width) solid var(--tblr-border-color);
}

.tabulator .tabulator-row.tabulator-row-even {
    background-color: var(--tblr-bg-surface-tertiary);
}

.tabulator .tabulator-row:hover {
    background-color: var(--tblr-active-bg);
}

.tabulator .tabulator-row .tabulator-cell {
    padding: 0.5rem 0.75rem;
    border-right: none;
}

.tabulator .tabulator-footer .tabulator-page {
    border-radius: var(--tblr-border-radius);
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
    color: var(--tblr-body-color);
}

.tabulator .tabulator-footer .tabulator-page.active {
    background: var(--tblr-primary);
    border-color: var(--tblr-primary);
    color: #fff;
}

.tabulator .tabulator-header-filter input {
    border: var(--tblr-border-width) solid var(--tblr-border-color);
    border-radius: var(--tblr-border-radius);
    padding: 0.125rem 0.375rem;
}

/* Tables whose rows navigate somewhere on click. */
.tabulator.table-clickable .tabulator-row {
    cursor: pointer;
}

/* ---------------------------------------------------------------------- *
 * Collapsible hierarchies (groups page, org chart)
 *
 * Both trees emit the same markup, so these are scoped to the node structure
 * rather than to one page. The tree is nested rather than a flat list, so the
 * flush list-group rules (which use a direct-child selector) are restated here.
 * ---------------------------------------------------------------------- */
.group-node > .group-item {
    border-width: 0 0 var(--tblr-border-width) 0;
    border-radius: 0;
}

.group-node > .group-item:hover {
    background-color: var(--tblr-active-bg);
}

.group-node.d-none + .group-children {
    display: none;
}

/* Chevron points down when open, right when collapsed. */
.group-toggle .ti {
    transition: transform 0.15s ease;
}

.group-toggle.collapsed .ti {
    transform: rotate(-90deg);
}

/* Keeps leaf rows aligned with rows that have a toggle. */
.group-toggle-spacer {
    display: inline-block;
    width: 1.75rem;
}

.favorite-static {
    display: inline-block;
    width: 1.75rem;
    text-align: center;
}

/* ---------------------------------------------------------------------- *
 * Org hierarchy rows
 *
 * The org chart reuses the group hierarchy markup (.group-node / .group-item /
 * .group-children), so it inherits that styling; only the attendance figures
 * on the right need anything of their own. They sit in fixed-width columns so
 * the bars, ratios and percentages line up from row to row whatever the indent.
 * ---------------------------------------------------------------------- */
.org-ratio {
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 5.5rem;
    text-align: right;
}

/* The status bar: one segment per category, the same colours as the legend above the tree. */
.org-mix {
    flex: 0 0 9rem;
    width: 9rem;
}

.org-pct {
    min-width: 3.5rem;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

/* The directory's full value beside the row's own segment. */
.org-fullname {
    font-size: 0.75rem;
    font-weight: normal;
}

/* The summary strip's legend wraps; keep each category on one line. */
.org-legend .list-inline-item {
    white-space: nowrap;
    margin-right: 1rem;
}

/* The org name opens the member list, so it behaves as a control while reading as
   a plain row label - same weight and alignment as a group row's name. */
.group-item .org-open {
    cursor: pointer;
}

.group-item .org-open:hover {
    text-decoration: underline;
}

.group-item .org-open:focus-visible {
    outline: 2px solid var(--tblr-primary);
    outline-offset: 2px;
    border-radius: var(--tblr-border-radius);
}

/* Direct reports page: the daily attendance chart sizes to this box (Chart.js maintainAspectRatio: false). */
.team-daily-chart {
    position: relative;
    height: 16rem;
}

/* ---------------------------------------------------------------------------------------------------------------
 * Accessibility (WCAG 2.1 AA, checked by axe-core in CI: a11y/). Text colours at least 4.5:1 against their
 * background: Tabler's light badges (bg-*-lt) and coloured text use its mid-tone palette, which is 2.4 to 4.4:1 on
 * the tints; these are the same hues, darker. Links inside text are underlined, not told apart by colour alone.
 * --------------------------------------------------------------------------------------------------------------- */
.bg-green-lt, .text-green { color: #1d6f2b !important; }
.bg-blue-lt, .text-blue { color: #0559a8 !important; }
.bg-red-lt, .text-red, .text-danger { color: #a82424 !important; }
.bg-secondary-lt, .bg-muted-lt { color: #525866 !important; }
.bg-purple-lt, .text-purple { color: #82299a !important; }
.bg-orange-lt, .text-orange { color: #a84400 !important; }
.bg-yellow-lt, .text-yellow, .text-warning { color: #8a5a00 !important; }
.bg-cyan-lt, .text-cyan { color: #0f6b7a !important; }
.bg-teal-lt, .text-teal { color: #08694b !important; }
.bg-azure-lt, .text-azure { color: #1e64a8 !important; }
.bg-indigo-lt, .text-indigo { color: #2c45c0 !important; }
.bg-pink-lt, .text-pink { color: #a51f4f !important; }
.bg-lime-lt, .text-lime { color: #4a7a0b !important; }
.text-success { color: #1d6f2b !important; }

/* White text on green buttons: 5.4:1. */
.btn-success {
    --tblr-btn-bg: #1d7a30;
    --tblr-btn-border-color: #1d7a30;
    --tblr-btn-hover-bg: #186628;
    --tblr-btn-hover-border-color: #186628;
    --tblr-btn-active-bg: #145521;
    --tblr-btn-active-border-color: #145521;
}

/* Links in running text: underlined (WCAG 1.4.1). */
.page-body p a:not(.btn), .page-body .small a:not(.btn), .page-body .form-hint a:not(.btn),
.page-body .alert a:not(.btn), .page-body .text-secondary a:not(.btn) {
    text-decoration: underline;
}

/* The calendar's days of other months: readable, not faded to 1.5:1. */
.fc .fc-day-other .fc-daygrid-day-top { opacity: 1; }
.fc .fc-day-other .fc-daygrid-day-number { color: #525866; }

/* An empty table's message. */
.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents { color: #525866; }

/* Keyboard focus is always visible, including on scrollable regions made focusable by a11y.js. */
[data-a11y-scroll]:focus-visible { outline: 2px solid #0559a8; outline-offset: 2px; }

/* Outline danger buttons on the page's grey: 6:1. */
.btn-outline-danger { --tblr-btn-color: #a82424; --tblr-btn-border-color: #a82424; }
/* Table column titles, on their header and its hover and sorted shades. */
.tabulator .tabulator-header .tabulator-col .tabulator-col-title { color: #374151; }
/* A page link that leads nowhere (the first or last page): inactive, so exempt from contrast, but still legible. */
.page-item.disabled .page-link { color: #525866; }

/* Form fields and checkboxes: borders at 3:1 against the page, so a field can be found (WCAG 1.4.11). */
.form-control, .form-select, .form-check-input { border-color: #868e96; }
/* The skip link, shown when it has keyboard focus. */
.a11y-skip-link:focus {
    position: fixed !important; top: .5rem; left: .5rem; z-index: 2000;
    padding: .5rem 1rem; background: #fff; color: #0559a8; border: 2px solid #0559a8; border-radius: 4px;
}
