/* The trail of the page (partials/navbar/_navbar.html in the top bar and
   layouts/base.html in the one of the phones). In the top bar it is always
   one line: the steps that fit show their whole name; the ones that do
   not are cut with an ellipsis (the full name is in the tooltip). In the
   one of the phones, where it has the whole width, it wraps. */
.page-pretitle .breadcrumb-bullets {
    flex-wrap: nowrap;
}

.breadcrumb-bullets .breadcrumb-item {
    display: flex;
    align-items: baseline;
    min-width: 0;
}

/* The bullet that separates the steps keeps its room: it is a flex item
   now (the float of Tabler does not apply to them). */
.breadcrumb-bullets .breadcrumb-item + .breadcrumb-item::before {
    flex: 0 0 auto;
}

/* The words of the step. They are the only part that gives way when the
   trail is too long: the separator and the padding keep their room. */
.breadcrumb-bullets .breadcrumb-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* The steps before the last one keep their name as long as they can; the
   last one (the page the user is on) takes the room that is left and is
   the one that gets cut when the trail does not fit. */
.breadcrumb-bullets .breadcrumb-item:not(.active) {
    flex: 0 0 auto;
    max-width: 14rem;
}

.breadcrumb-bullets .breadcrumb-item.active {
    flex: 1 1 6rem;
    min-width: 6rem;
}

/* The name of the professional, linked to their speciality. Tabler kills
   the links of the current step (color: inherit; pointer-events: none) to
   keep it from being a link; this one is the way to the speciality, so it
   keeps its color and its click. The selector is more specific than
   Tabler's (.breadcrumb-item.active a) to win it. */
.breadcrumb-bullets .breadcrumb-item .breadcrumb-prefix {
    color: var(--tblr-link-color);
    pointer-events: auto;
    text-decoration: underline;
    text-underline-offset: .15em;
}

.breadcrumb-bullets .breadcrumb-item .breadcrumb-prefix:hover {
    text-decoration: none;
}

/* The trail and the clinic selector (with the bell and the user) share
   the bar: the trail takes the room that is left and the selector keeps
   its own, so a long trail never pushes it out of the bar. */
.navbar > .container-xl > .navbar-nav {
    flex-shrink: 0;
}

.navbar > .container-xl > .navbar-collapse,
.navbar > .container-xl > .navbar-collapse .page-pretitle {
    min-width: 0;
}

/* Unread count on the bell: a small pill anchored to the icon's corner, so
   two or three digits ("10", "99+") stay on the icon instead of spilling. */
.nav-link .badge-notification {
    top: .35rem;
    right: .15rem;
    left: auto;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 .3rem;
    font-size: .625rem;
    line-height: 1.15rem;
    transform: translate(35%, -25%);
}

/* Search of patients (partials/navbar/_patient_search.html, behaviour in
   dist/js/utils/patient-search.js). In the top bar it sits between the
   trail and the clinic selector with a width of its own; in the phone menu
   it takes the whole width. The list of results hangs under the input. */
.patient-search {
    position: relative;
    width: 100%;
}

.navbar > .container-xl > .navbar-collapse .patient-search {
    flex: 0 1 18rem;
    margin-inline: auto 1rem;
}

.navbar > .container-xl > .navbar-collapse .page-pretitle {
    flex: 1 1 auto;
}

.patient-search__input {
    padding-inline-end: 2.25rem;
}

/* The search's own clear button would sit under the hint of the shortcut. */
.patient-search__input::-webkit-search-cancel-button {
    display: none;
}

.patient-search__shortcut kbd {
    padding: .05rem .35rem;
    font-size: .75rem;
    color: var(--tblr-secondary);
    background: var(--tblr-bg-surface-secondary);
    border: 1px solid var(--tblr-border-color);
    box-shadow: none;
}

/* While the user types, the hint makes room for the text. */
.patient-search__input:focus ~ .patient-search__shortcut,
.patient-search__input:not(:placeholder-shown) ~ .patient-search__shortcut {
    display: none;
}

.patient-search__results {
    top: calc(100% + .25rem);
    left: 0;
    width: 100%;
    min-width: 16rem;
    max-height: min(24rem, 60vh);
    margin: 0;
    overflow-y: auto;
}

.patient-search__option {
    cursor: pointer;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* The option under the arrows: primary darkened on the light surface and
   lightened on the dark one (Tabler's active item stays near 3:1 there). */
.patient-search__results .patient-search__option.active {
    color: light-dark(
        color-mix(in oklab, var(--tblr-primary) 78%, var(--tblr-black)),
        color-mix(in oklab, var(--tblr-primary) 45%, var(--tblr-white))
    );
}

/* The way to the directory closes the list, apart from the patients. */
.patient-search__all {
    border-top: 1px solid var(--tblr-border-color);
    color: var(--tblr-link-color);
}

.patient-search__message {
    white-space: normal;
}

/* In the phone menu (the sidebar), above the sections. */
.navbar-vertical .patient-search-menu {
    padding: .75rem var(--tblr-navbar-padding-x, 1rem) .25rem;
}

/* Tabler hides the dropdowns of the sidebar and lays them out static: in
   the phone menu the results open in the flow, pushing the sections down
   (an overlay would be cut by the scroll of the menu). */
.navbar-vertical .patient-search-menu .patient-search__results {
    position: static;
    margin-top: .25rem;
    padding: .25rem 0;
    border: 1px solid var(--tblr-border-color);
    box-shadow: none;
}

.navbar-vertical .patient-search-menu .patient-search__option,
.navbar-vertical .patient-search-menu .patient-search__message {
    padding: .5rem .75rem;
}

/* !important: Tabler's rule of the folded sidebar (html[data-bs-sidebar^=folded]
   .navbar-vertical .dropdown-menu.show:not(...)) hides every open dropdown of
   the sidebar with a higher specificity, and the phone menu keeps that
   attribute. Only this list, only in the phone menu. */
.navbar-vertical .patient-search-menu .patient-search__results.show {
    display: block !important;
}

/* Without the permission the include draws nothing: no empty gap either. */
.navbar-vertical .patient-search-menu:not(:has(.patient-search)) {
    display: none;
}

/* Sidebar brand (partials/sidebar/_navbar_logo.html): logos come in any
   shape, so the image is fitted inside a fixed box instead of taking its
   natural width. Folded (icon rail, 4rem): only the logo, centered in the
   rail; the short name shows again when the sidebar unfolds on hover. */
.sidebar-brand {
    min-width: 0;
}

.sidebar-brand-logo {
    flex-shrink: 0;
    width: auto;
    max-width: 6rem;
    height: 2rem;
    object-fit: contain;
}

.sidebar-brand-name {
    max-width: 9rem;
}

/* The brand link is a flex child of the bar: without min-width it can't
   shrink, and a long clinic name pushes the icons instead of truncating. */
.navbar-vertical .navbar-brand {
    min-width: 0;
}

/* Phones (<sm): the bar holds the toggler, the brand and the utility row in
   ~360px. The product logo already carries the "Orgaepsi" wordmark baked in,
   so the text next to it only duplicates it: hide it. A clinic keeps logo +
   name, both capped so they truncate instead of overlapping. */
@media (max-width: 575.98px) {
    .navbar-vertical .sidebar-brand-logo {
        max-width: 4.5rem;
        height: 1.75rem;
    }

    .navbar-vertical .navbar-brand-autodark .sidebar-brand-name {
        display: none;
    }

    .navbar-vertical .sidebar-brand-name {
        max-width: calc(100vw - 12rem);
    }
}

/* Utility row under the brand (theme, clinic, bell, user, below lg):
   vertically centered with breathing room instead of hugging the top. */
@media (max-width: 991.98px) {
    .navbar-vertical .navbar-footer .navbar-nav {
        align-items: center;
        gap: .25rem;
        padding: .25rem 0;
    }
}

@media (min-width: 992px) {
    html[data-bs-sidebar=folded] .navbar-vertical.navbar-expand-lg .navbar-brand,
    html[data-bs-sidebar=folded-hover] .navbar-vertical.navbar-expand-lg:not(:hover):not(:has(:focus-visible)) .navbar-brand {
        --tblr-sidebar-brand-padding-x: .5rem;
        justify-content: center;
    }

    html[data-bs-sidebar=folded] .navbar-vertical.navbar-expand-lg .sidebar-brand-logo,
    html[data-bs-sidebar=folded-hover] .navbar-vertical.navbar-expand-lg:not(:hover):not(:has(:focus-visible)) .sidebar-brand-logo {
        max-width: calc(var(--tblr-sidebar-folded-width) - 1rem);
    }

    html[data-bs-sidebar=folded] .navbar-vertical.navbar-expand-lg .sidebar-brand-name,
    html[data-bs-sidebar=folded-hover] .navbar-vertical.navbar-expand-lg:not(:hover):not(:has(:focus-visible)) .sidebar-brand-name {
        display: none;
    }
}

/* The button that keeps the sidebar open or folds it to the icon rail
   (partials/sidebar/_sidebar.html, behaviour in dist/js/utils/theme-init.js).
   It sits at the foot of the sidebar, apart from the places of the menu, and
   looks like one of its entries. Its icon tells what a click does: open the
   rail while it is folded, fold it while it is pinned open. The menu is
   taller than a laptop screen, so the button sticks to the foot of the
   sidebar instead of waiting at the end of the list. */
.navbar-vertical .navbar-nav.sidebar-pin {
    position: sticky;
    bottom: 0;
    z-index: 1;
    /* Tabler grows every .navbar-nav of the sidebar: this one keeps its
       size, so a short menu (the patient's) leaves it at the foot. */
    flex-grow: 0;
    margin-top: auto;
    padding-top: .5rem;
    padding-bottom: .5rem;
    border-top: 1px solid var(--tblr-border-color);
    background: var(--tblr-navbar-bg, var(--tblr-bg-surface));
}

.navbar-vertical .sidebar-pin__button {
    width: 100%;
    background: none;
    border: 0;
    text-align: start;
}

.sidebar-pin__icon {
    display: inline-flex;
}

html:not([data-bs-sidebar]) .sidebar-pin__icon--expand,
html[data-bs-sidebar] .sidebar-pin__icon--collapse {
    display: none;
}

/* Sidebar section headings (partials/sidebar/_sidebar.html): small muted
   labels between groups. Folded (icon rail): the label would be cut, so only
   a thin rule separates the groups until the sidebar unfolds. Pinned open
   (no data-bs-sidebar), the labels are always there. */
.navbar-vertical .nav-section-title {
    padding: 1rem var(--tblr-navbar-padding-x, 1rem) .25rem;
    font-size: .6875rem;
    font-weight: var(--tblr-font-weight-bold, 600);
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--tblr-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-vertical .navbar-nav > .nav-section-title:first-child {
    padding-top: .25rem;
}

@media (min-width: 992px) {
    html[data-bs-sidebar=folded] .navbar-vertical.navbar-expand-lg .nav-section-title,
    html[data-bs-sidebar=folded-hover] .navbar-vertical.navbar-expand-lg:not(:hover):not(:has(:focus-visible)) .nav-section-title {
        height: 0;
        margin: .5rem .75rem;
        padding: 0;
        border-top: 1px solid var(--tblr-border-color);
        color: transparent;
    }

    html[data-bs-sidebar=folded] .navbar-vertical.navbar-expand-lg .navbar-nav > .nav-section-title:first-child,
    html[data-bs-sidebar=folded-hover] .navbar-vertical.navbar-expand-lg:not(:hover):not(:has(:focus-visible)) .navbar-nav > .nav-section-title:first-child {
        border-top: 0;
    }
}
