.titlebox {
    margin-top: 1rem;
}

.titlebox .card-body {
    padding-top: 0.5rem;
}

/* Reduce top space for nested titleboxes, like "Basics" widget in "Ticket metadata" */
.titlebox .card-body:has(.titlebox) {
    padding-top: 0;
}

/* Reduce top space for table content that has extra space */
.titlebox .card-body:has(> :first-child > :first-child > :first-child > .table:first-child),
.titlebox .card-body:has(> :first-child > :first-child > .table:first-child),
.titlebox .card-body:has(> :first-child > .table:first-child),
.titlebox .card-body:has(> .table:first-child) {
    padding-top: 0.25rem;
}

/* Reduce top space for accordion content that has extra space */
.titlebox .card-body:has(> .accordion:first-child) {
    padding-top: 0.25rem;
}

/* Reduce top space for general content that has extra mt-2 space */
.titlebox .card-body:has(> :nth-child(1 of :not(.hidden):not([type=hidden])) > :nth-child(1 of :not(.hidden):not([type=hidden])) > :nth-child(1 of :not(.hidden):not([type=hidden])) > :nth-child(1 of :not(.hidden):not([type=hidden])) > div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden]))),
.titlebox .card-body:has(> :nth-child(1 of :not(.hidden):not([type=hidden])) > :nth-child(1 of :not(.hidden):not([type=hidden])) > :nth-child(1 of :not(.hidden):not([type=hidden])) > div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden]))),
.titlebox .card-body:has(> :nth-child(1 of :not(.hidden):not([type=hidden])) > :nth-child(1 of :not(.hidden):not([type=hidden])) > div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden]))),
.titlebox .card-body:has(> :nth-child(1 of :not(.hidden):not([type=hidden])) > div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden]))),
.titlebox .card-body:has(> div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden]))) {
    padding-top: 0;
}

.titlebox .titlebox-title {
    position: relative;
    padding-bottom: 0;
}

.titlebox .titlebox-title a {
    text-decoration: none;
}

.titlebox .titlebox-title a:hover {
    text-decoration: underline
}

/* Don't underline for any menu links in the righthand controls */
.titlebox .titlebox-title .dropdown-menu a:hover {
    text-decoration: none;
}

.titlebox .titlebox-title .left {
    font-weight: 500;
    padding: 0.5em 1.25em 0.25em 1.25em;
    line-height: 1.4em;
    font-size: 1.1em;
    border: none;
}

.titlebox .titlebox-title .right-empty {
    display: none
}

.titlebox .titlebox-title .right {
    position: absolute;
    right: 1rem;
    top: 0;
    font-size: 0.9em;
    padding-right: 0em;
    padding-left: 0.4em;
    padding-bottom: 0.2em;
    padding-top: 0.5em;
    -moz-border-radius-bottomleft: 0.25em;
    -webkit-border-bottom-left-radius: 0.25em;
    -moz-border-radius-topright: 0.25em;
    -webkit-border-top-right-radius: 0.25em;
    border-radius: 0 0.25em 0 0.25em;
}

.titlebox .titlebox-title .right-icon {
    position: absolute;
    right: 1rem;
}

.rt-inline-icon.border {
    padding: 0.25rem;
    display: inline-block;
    height: calc(0.5rem + 16px + 2*var(--bs-border-width));
    line-height: 1;
}

.rt-inline-icon svg {
    /* This actually makes svg appear in the middle */
    vertical-align: inherit;
}

div.results .titlebox .titlebox-content {
    border: none;
    -moz-border-radius: 0.5em;
    border-radius: 0.5em;
    -webkit-border-radius: 0.5em;
    padding-top: 0.5em;
    padding-bottom: 0.5em;
}

.results .titlebox-content ul {
    list-style-type: none;
    margin-top: 1em;
}

.results .titlebox-title {
    display: none
}

.results .card-body {
    padding: 0;
}

.titlebox .titlebox-content,
.titlebox .card-header {
    border: none;
}

.titlebox .card-header {
    font-size: larger;
}

/* Suppress bottom and side padding for results messages */
.titlebox .list-actions .card-body {
    padding: 0;
}

.titlebox.card.ticket-info-basics,
.titlebox.card.ticket-info-description,
.titlebox.card.ticket-info-times,
.titlebox.card.asset-basics {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-reminders {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-people,
.titlebox.card.ticket-info-requestor,
.titlebox.card.ticket-info-squelch,
.titlebox.card.ticket-info-recipients,
.titlebox.card.ticket-info-preview-scrips,
.titlebox.card.asset-people {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-dates,
.titlebox.card.asset-dates {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-attachments {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-links,
.titlebox.card.ticket-assets,
.titlebox.card.asset-links {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-merge {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-cfs,
.titlebox.card.asset-info-cfs {
    border-top: 3px solid;
}

.titlebox.card.ticket-info-article {
    border-top: 3px solid;
}

#comp-Admin-Queues-DefaultValues .titlebox.card.ticket-info-cfs {
    border-top: 1px solid;
}

.show-custom-fields {
    columns: 150px 3;
    column-gap: 1rem;
}

.show-custom-fields > * {
    break-inside: avoid;
}

.show-custom-fields > div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden])) {
    margin-top: 0 !important;
}

.unset-fields-hidden .show-custom-fields > div.mt-2:nth-child(1 of :not(.hidden):not([type=hidden]):not(.unset-field)) {
    margin-top: 0 !important;
}

.show-custom-fields.cf-columns-xs { columns: 100px 5; }
.show-custom-fields.cf-columns-sm { columns: 130px 4; }
/* Default (no class) is 150px 3 */
.show-custom-fields.cf-columns-lg { columns: 200px 2; }
.show-custom-fields.cf-columns-xl { columns: 1; }

.titlebox.card.messagedetails {
    border-top: 3px solid;
}

.titlebox .card-header span.toggle:hover {
    cursor: pointer;
}

.titlebox .card-header span.toggle:before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    border: solid;
    border-width: 0 2px 2px 0;
    -webkit-transform: rotate(-135deg);
    -ms-transform: rotate(-135deg);
    transform: rotate(-135deg);
    transition: transform .25s;
    position: absolute;
    top: 1.2rem;
}

.titlebox .card-header span.toggle.collapsed:before {
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}

.titlebox .card-header.title-sm {
    font-size: 0.8rem;
}

.titlebox .card-header.title-sm span.toggle.collapsed:before {
    top: 0.8rem;
}

.titlebox .card-header.title-sm span.toggle:not(.collapsed):before {
    top: 1rem;
}

.max-width-xl {
    max-width: 1200px;
}

.max-width-lg {
    max-width: 992px;
}

.max-width-md {
    max-width: 768px;
}

.max-width-sm {
    max-width: 576px;
}

.width-xl {
    width: 1200px;
}

.width-lg {
    width: 992px;
}

.width-md {
    width: 768px;
}

.width-sm {
    width: 576px;
}

.titlebox-outer-div {
    display: flex;
    flex-direction: column;
}

/* Ticket display page colored top borders */
/* Keep in sync with transaction colors in history.css */
/* material.io reference: https://material.io/design/color/#tools-for-picking-colors */

.titlebox.card.ticket-info-basics,
.titlebox.card.ticket-info-times,
.titlebox.card.asset-basics {
    border-top-color: #D32F2F;
}

.titlebox.card.ticket-info-reminders {
    border-top-color: #0277BD;
}

.titlebox.card.ticket-info-people,
.titlebox.card.ticket-info-requestor,
.titlebox.card.ticket-info-squelch,
.titlebox.card.ticket-info-recipients,
.titlebox.card.ticket-info-preview-scrips,
.titlebox.card.asset-people {
    border-top-color: #0288D1;
}

.titlebox.card.ticket-info-dates,
.titlebox.card.asset-dates {
    border-top-color: #7B1FA2;
}

.titlebox.card.ticket-info-attachments {
    border-top-color: #EF6C00;
}

.titlebox.card.ticket-info-links,
.titlebox.card.ticket-assets,
.titlebox.card.asset-links {
    border-top-color: #388E3C;
}

.titlebox.card.ticket-info-merge {
    border-top-color: #5D4037;
}

.titlebox.card.ticket-info-cfs,
.titlebox.card.asset-info-cfs {
    border-top-color: #D32F2F;
}

.titlebox.card.ticket-info-description {
    border-top-color: #00BFA5;
}

.titlebox.card.ticket-info-article {
    border-top-color: #E58F45;
}

/* reset to default border for .card-body */
#comp-Admin-Queues-DefaultValues .titlebox.card.ticket-info-cfs {
    border-top-color: #dde4eb;
}

.titlebox.card.messagedetails {
    border-top-color: #1976D2;
}

[data-bs-theme=light] {
    .titlebox .titlebox-title {
        background-color: transparent;
    }

    .titlebox .titlebox-title a {
        color: black;
    }

    .titlebox .titlebox-title .left {
        background-color: transparent;
    }

    .titlebox .titlebox-title .left,
    .titlebox .titlebox-title .left a {
        color: var(--bs-primary);
    }

    .titlebox-inner-heading {
        color: var(--bs-primary);
    }

    .titlebox:hover .titlebox-title .right a,
    .titlebox:active .titlebox-title .right a {
        color: #000;
    }

    .titlebox .card-header span.toggle:before {
        border-color: #B0B3BC;
    }
}

[data-bs-theme=dark] {
    .card {
        border-color: #515151;
    }

    .card-header {
        background-color: var(--bs-body-bg);
    }

    .titlebox .card-header {
        padding-bottom: inherit;
    }
}
