/* Diabase.Ui - what the components need beyond the host's stylesheet. Every colour is one of the host's variables. */

/* Messages after an act (Toasts): bottom centre, newest lowest. They never take a click - sat over a dialog's Save
   button, a warning took the next click meant for Save - and while a dialog is open they sit at the top instead. */
.ui-toasts {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%);
    z-index: 1090;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: max-content;
    max-width: min(560px, 92vw);
    pointer-events: none;
}
body.modal-open .ui-toasts,
html:has(dialog[open]) .ui-toasts {
    bottom: auto;
    top: 2.5rem;
}
.ui-toast {
    padding: 0.875rem 1.5rem;
    border-radius: var(--bs-border-radius-sm, 2px);
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    color: var(--bs-white);
    background-color: var(--bs-dark);
    box-shadow: var(--bs-box-shadow);
    animation: ui-toast-in 0.15s ease-out;
}
.ui-toast-success { background-color: var(--bs-success); }
.ui-toast-danger { background-color: var(--bs-danger); }
.ui-toast-warning { background-color: var(--bs-warning); color: var(--bs-dark); }
@keyframes ui-toast-in {
    from { opacity: 0; transform: translateY(0.5rem); }
}
@media (prefers-reduced-motion: reduce) {
    .ui-toast { animation: none; }
}

/* The messages are a popover so they can be raised above an open dialog; these undo what a browser gives a popover.
   Not yet raised, or in a browser without popovers, they are drawn in the page all the same. */
.ui-toasts[popover] {
    inset: auto auto 1.5rem 50%;
    margin: 0;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
}
.ui-toasts[popover]:not(:popover-open) {
    display: flex;
}
body.modal-open .ui-toasts[popover],
html:has(dialog[open]) .ui-toasts[popover] {
    inset: 2.5rem auto auto 50%;
}

/* Bottom right instead (Placement BottomEnd), 1.5rem in from the edge, as Blazorise's SnackbarStack put Keystone's;
   at the top right while a dialog is open. A window narrower than 576px keeps them centred, as Blazorise did. */
@media (min-width: 576px) {
    .ui-toasts.ui-toasts-end {
        left: auto;
        right: 1.5rem;
        transform: none;
        align-items: flex-end;
    }
    .ui-toasts.ui-toasts-end[popover] {
        inset: auto 1.5rem 1.5rem auto;
    }
    body.modal-open .ui-toasts.ui-toasts-end[popover],
    html:has(dialog[open]) .ui-toasts.ui-toasts-end[popover] {
        inset: 2.5rem 1.5rem auto auto;
    }
}

/* A dialog (Dialog) is the browser's own, filling the window and clear, with Bootstrap's modal frame drawn inside
   it - which Bootstrap hides until its own script shows it. */
dialog.ui-dialog {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    overflow: hidden;
}
dialog.ui-dialog > .modal {
    display: block;
    position: absolute;
    inset: 0;
    z-index: auto;
}
/* Blazorise's stylesheet, while a host still loads it, animates any .modal without .show out of sight - a fade and a
   50px slide over 300ms. This frame never has .show (the browser's dialog decides whether it is seen), so every dialog
   faded and slid away as it opened and then snapped back: the ghost of the form the user saw. Its rules outrank a plain
   selector here, hence the !important. */
dialog.ui-dialog > .modal,
dialog.ui-dialog .modal-dialog {
    animation: none !important;
}
dialog.ui-dialog::backdrop {
    background: color-mix(in srgb, var(--bs-black) 50%, transparent);
}
dialog.ui-dialog:focus {
    outline: none;
}

/* An icon (Icon) sits in its own box, one line high, as Font Awesome's icons did beside Blazorise. */
.ui-icon {
    display: inline-block;
}

/* A box that grows with what is written in it (MemoEdit AutoSize), where the browser can size a field to its content. */
.ui-autosize {
    field-sizing: content;
}

/* The page frame (Layout and its parts): what Blazorise's stylesheet gave its Layout, under Diabase.Ui's names. Only
   the arrangement - the host paints the sider, the header and the content. */
.ui-layout {
    display: flex;
    flex: auto;
    flex-direction: column;
}
.ui-layout.ui-layout-root {
    height: 100vh;
}
.ui-layout,
.ui-layout * {
    box-sizing: border-box;
}
.ui-layout.ui-layout-has-sider {
    flex-direction: row;
    min-height: 0;
}
.ui-layout.ui-layout-has-sider .ui-layout {
    overflow-x: hidden;
}
.ui-layout.ui-layout-root.ui-layout-has-sider > .ui-layout-header-fixed,
.ui-layout.ui-layout-root.ui-layout-has-sider > .ui-layout > .ui-layout-header-fixed {
    position: sticky;
    top: 0;
    width: 100%;
    flex: 0;
}
.ui-layout-header-fixed {
    z-index: 1030;
}
.ui-layout-header .navbar {
    line-height: inherit;
}
.ui-layout-content {
    flex: 1;
}
.ui-layout-sider {
    display: flex;
    position: relative;
}
.ui-layout-sider-content {
    position: sticky;
    top: 0;
    z-index: 1031;
}

/* Tooltip: its wrapper takes the place Blazorise's took (a block, or inline-block); the note is Bootstrap's tooltip,
   placed by Tooltip.razor.js in the top layer, so the browser's own popover look is put back to Bootstrap's. */
.ui-tooltip-inline {
    display: inline-block;
}
.tooltip.ui-tooltip-note {
    --bs-tooltip-max-width: 350px;   /* the width Blazorise's notes had; a long one reads as lines, not a column */
    position: fixed;
    inset: auto;
    margin: 0;
    border: 0;
    padding: 0;
    overflow: visible;
    background: transparent;
    pointer-events: none;
}
/* Closed, it is not drawn: Bootstrap's .tooltip says display: block, which overrides the browser's hiding of a closed
   popover - the note stayed on screen, at full strength, wherever it was last shown. */
.tooltip.ui-tooltip-note:not(:popover-open) {
    display: none;
}
.ui-tooltip-note .tooltip-arrow {
    position: absolute;   /* what Popper sets on Bootstrap's arrow; Tooltip.razor.js sets its left */
}

/* Menu: Bootstrap's dropdown, its list the browser's popover. Bootstrap hides a .dropdown-menu until it has .show and
   places it absolutely; here the browser's open state shows it and Menu.razor.js places it in the window. The
   browser's own popover look (centred, a border and padding of its own) is put back to Bootstrap's. */
.dropdown-menu.ui-menu-items {
    position: fixed;
    inset: auto;
    margin: 0;
    overflow: auto;
    max-height: calc(100vh - 8px);
}
.dropdown-menu.ui-menu-items:popover-open {
    display: block;
}
/* A menu's button is drawn without a border, as it was under Blazorise's stylesheet (which took it off every menu
   button), so it keeps its size beside the page; an outline button keeps the outline it is drawn by. */
.ui-menu > .btn.dropdown-toggle:not([class*="btn-outline-"]) {
    border: none;
}

/* A button that is only an icon, or an avatar, says it opens a menu by its name, not by the arrow. */
.ui-menu > .dropdown-toggle-hidden::after {
    display: none;
}

/* SidePanel: Bootstrap's offcanvas at the right, on the browser's dialog. Bootstrap draws an .offcanvas always
   (display: flex) and hides it by visibility until its script adds .show; here a closed one is not drawn, and an open
   one is. It slides in and, where the browser can hold a closing dialog on screen, out. */
dialog.ui-panel {
    inset: 0 0 0 auto;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border-width: 0 0 0 var(--bs-offcanvas-border-width);
    visibility: visible;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out, display 0.3s allow-discrete, overlay 0.3s allow-discrete;
}
dialog.ui-panel:not([open]) {
    display: none;
}
dialog.ui-panel[open] {
    transform: none;
}
@starting-style {
    dialog.ui-panel[open] {
        transform: translateX(100%);
    }
}
/* Its footer, as Blazorise's OffcanvasFooter was: the buttons in a row under the body, in the panel's own padding. */
.ui-panel-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
}
dialog.ui-panel::backdrop {
    background: color-mix(in srgb, var(--bs-black) 50%, transparent);
}
dialog.ui-panel:focus {
    outline: none;
}
@media (prefers-reduced-motion: reduce) {
    dialog.ui-panel {
        transition: none;
    }
}

/* Combobox: its suggestions under the box, at least as wide, scrolling when there are many. */
.ui-combobox {
    position: relative;
}
.ui-combobox > .dropdown-menu {
    top: 100%;
    left: 0;
    min-width: 100%;
    max-height: 20rem;
    overflow-y: auto;
}
.ui-combobox > .dropdown-menu > .dropdown-item {
    cursor: pointer;
}

/* A DataTable whose columns can be sized (Resizable): the edge to drag at each heading's right, as Blazorise's
   stylesheet drew it - blue while hovered or dragged. */
.ui-table-resizable { position: relative; }
.ui-table-resizable > thead > tr > th { position: relative; }
.ui-table-resizable .ui-table-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    cursor: col-resize;
    user-select: none;
    z-index: 1;
}
.ui-table-resizable .ui-table-resizer:hover,
.ui-table-resizable .ui-table-resizing {
    cursor: col-resize !important;
    border-right: 2px solid var(--b-theme-primary, blue);
}
/* A row the arrow keys move to takes the focus without the browser's ring, as Blazorise's did. */
tr.table-row-selectable:focus[tabindex="0"] { outline: none; }

/* A grouped DataTable's headings: a row to click, set apart from the rows under it (as Blazorise drew its groups). */
.ui-datatable tbody tr.table-group {
    cursor: pointer;
    background-color: var(--bs-light);
    font-weight: 700;
}

/* What Blazorise's stylesheets gave Bootstrap that these components still draw with, kept here now that they are
   gone (Nov 2026): the extra-small button (ButtonSize.Tiny), a field's space under it, a row of radio buttons sized
   to its buttons, and the pointer over what takes a click - a sortable heading, a row, a page number. */
.btn-xs, .btn-group-xs > .btn {
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.5;
    border-radius: 0.15rem;
}
.form-group {
    margin-bottom: 1rem;
}
.form-group:not(.row) .btn-group.btn-group-toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    width: max-content;
}
.form-group:not(.row) .btn-group.btn-group-toggle .btn {
    flex: 0 1 auto;
}
.btn-group.btn-group-toggle .btn.active.disabled {
    opacity: 1;
}
.cursor-pointer,
tr.table-row-selectable:hover,
.page-item:not(.disabled) .page-link {
    cursor: pointer;
}

/* A field that must be filled (FieldLabel Required): an asterisk after its label, as Blazorise's stylesheet put it. */
.form-label-required::after {
    content: " *";
    color: var(--bs-danger);
}

/* A tab (Tab) is a link without an address, which a browser gives no pointer; Blazorise's stylesheet gave its tabs one. */
.nav-link[role="tab"] {
    cursor: pointer;
}
