:root {
    --term-flag-width: 2.25rem;
}

body {
    background-color: var(--bs-tertiary-bg);
}

/* ux-table */
.ux-table-head-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.ux-table-head-sort .sort::after {
    content: '\2195';
    opacity: 0.35;
}

.ux-table-head-sort .sort-asc::after {
    content: '\2191';
    opacity: 1;
}

.ux-table-head-sort .sort-desc::after {
    content: '\2193';
    opacity: 1;
}

turbo-frame[busy] {
    opacity: 0.6;
}

/* Taxonomy editor */
.fill-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

/*
 * Pages marked with body.page-fill (the taxonomy editor) fill the window: the columns take all the height
 * that is left under the heading and scroll inside themselves. On small screens they stack and scroll normally.
 */
@media (min-width: 992px) {
    body.page-fill {
        display: flex;
        flex-direction: column;
        height: 100vh;
    }

    body.page-fill > main {
        padding-bottom: 1rem !important;
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    /* Bootstrap rows wrap, and a wrapped line is as tall as its content; without wrapping the columns stretch to the row. */
    body.page-fill .fill-row {
        flex: 1 1 auto;
        flex-wrap: nowrap;
        min-height: 0;
    }

    body.page-fill .fill-col {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    body.page-fill turbo-frame#taxonomy-editor {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    body.page-fill .term-tree {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    body.page-fill .fill-scroll {
        flex: 1 1 auto;
        max-height: none;
        min-height: 0;
    }
}

.term-flag-headings,
.term-flags {
    display: flex;
    flex: none;
}

.term-flag-headings > span {
    width: var(--term-flag-width);
    height: 7rem;
    /* In a vertical writing mode the line box is as wide as the line-height, so this centres the text over its checkbox column. */
    line-height: var(--term-flag-width);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    font-size: 0.8rem;
    text-align: left;
}

.term-flags > label {
    width: var(--term-flag-width);
    text-align: center;
}

.term-list {
    list-style: none;
    margin: 0 0 0 1.5rem;
    padding: 0;
}

.term-tree .fill-scroll > .term-list {
    margin-left: 0;
}

.term-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.125rem 0;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}

.term-row .term-name {
    flex: 1 1 auto;
    min-width: 8rem;
}

.term-handle {
    cursor: grab;
    color: var(--bs-secondary-color);
    user-select: none;
}

.term.collapsed > .term-list {
    display: none;
}

/* The expand / collapse arrow shows for any term that has children, however they got there. */
.term:not(:has(> .term-list > .term)) > .term-row .term-toggle {
    visibility: hidden;
}

.term.collapsed > .term-row .term-toggle::before {
    content: '\25B8';
}

.term:not(.collapsed) > .term-row .term-toggle::before {
    content: '\25BE';
}

.term-tree.is-dragging .sortable-ghost {
    opacity: 0.4;
}

.term-actions {
    width: 4.5rem;
    flex: none;
}

/* The copy of the term that follows the pointer while dragging: it is attached to <body>, so it needs its own look. */
.sortable-fallback {
    list-style: none;
    background: var(--bs-body-bg);
    border-radius: 0.25rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.18);
}

/* The edit and delete buttons of the chosen taxonomy sit on the blue "active" row, where the outline buttons would vanish. */
.list-group-item.active .btn {
    background-color: var(--bs-white);
    border-color: var(--bs-white);
}

.list-group-item.active .btn-outline-secondary {
    color: var(--bs-body-color);
}

.list-group-item.active .btn-outline-danger {
    color: var(--bs-danger);
}

/* "Enable" and "Disable" take the same room, so the action buttons line up down the instance list whichever one shows. */
.btn-status {
    min-width: 4.125rem;
}

/*
 * The EULA editor: the form is a column of version, editor and buttons, so the editor takes whatever height is left and
 * the buttons sit at the bottom of the window. These only stretch on wide screens; narrower ones scroll normally.
 */
.eula-editor .ql-container {
    min-height: 16rem;
}

.eula-editor .ql-editor {
    min-height: 14rem;
}

@media (min-width: 992px) {
    body.page-fill .fill-form,
    body.page-fill .fill-card,
    body.page-fill .fill-card-body {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    body.page-fill .eula-editor .quill-container,
    body.page-fill .eula-editor .quill-container > div[data-live-ignore] {
        display: flex;
        flex: 1 1 auto;
        flex-direction: column;
        min-height: 0;
    }

    body.page-fill .eula-editor .ql-container {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    body.page-fill .eula-editor .ql-editor {
        height: 100%;
        min-height: 0;
        overflow-y: auto;
    }

    body.page-fill .fill-card-body > .flex-none {
        flex: none;
    }
}

/* A published EULA is shown in a panel as tall as the window: its heading stays put and the text scrolls inside the panel. */
.eula-content {
    overflow-wrap: anywhere;
}

.eula-content img,
.eula-content table,
.eula-content video {
    max-width: 100%;
}

.eula-content img {
    height: auto;
}

/* A divider in the main menu, between the content screens and the operational ones (Documents | Instances). */
.navbar .nav-divider {
    margin: 0.25rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
}

@media (min-width: 992px) {
    .navbar .nav-divider {
        align-self: stretch;
        margin: 0.5rem 0.5rem;
        border-top: 0;
        border-left: 1px solid rgba(255, 255, 255, 0.35);
    }
}

/*
 * Quill's block mover (the up / drag / down / copy / delete panel beside the block being edited) sits outside the editor's left edge,
 * which in a dialog is further out than the dialog's body, so the dialog cuts it off. Keep it inside the editor instead, with room for it.
 */
.modal-body .ql-editor {
    padding-left: 2.5rem;
}

.modal-body .ql-node-mover-toolbar {
    left: .375rem !important;
}
