[data-admin-font-size] {
    --admin-font-scale: 1;
}

[data-admin-font-size="10"] {
    --admin-font-scale: .9375;
}

[data-admin-font-size="30"] {
    --admin-font-scale: 1.125;
}

/* Base text weight from the appearance settings; bold elements keep their own weight. */
[data-admin-font-weight] { --admin-font-weight: 400; }
[data-admin-font-weight="300"] { --admin-font-weight: 300; }
[data-admin-font-weight="600"] { --admin-font-weight: 600; }
[data-admin-font-weight="700"] { --admin-font-weight: 700; }

body[data-admin-font-weight] {
    --bs-body-font-weight: var(--admin-font-weight);
    font-weight: var(--admin-font-weight);
}

:where(body[data-admin-font-weight]) :is(.form-control, .form-select, .input-group-text, .dropdown-item, .page-link, .nav-link, .table) {
    font-weight: var(--admin-font-weight);
}

/* Bootstrap and AdminLTE set some sizes directly instead of inheriting from body. */
body[data-admin-font-size]:not([data-admin-font-size="20"]) {
    font-size: calc(var(--bs-body-font-size, 1rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h1,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h1 {
    font-size: calc((1.375rem + 1.5vw) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h2,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h2 {
    font-size: calc((1.325rem + .9vw) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h3,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h3 {
    font-size: calc((1.3rem + .6vw) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h4,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h4,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) legend {
    font-size: calc((1.275rem + .3vw) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h5,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h5,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .lead,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .blockquote,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .sidebar-brand {
    font-size: calc(1.25rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h6,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h6,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .accordion-button,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .dropdown-item-title,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) :is(.form-control, .form-select, .input-group-text),
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .select2-container--bootstrap-5 :is(.select2-selection, .select2-dropdown) {
    font-size: calc(1rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .btn {
    font-size: calc(var(--bs-btn-font-size, 1rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) :is(.form-control-lg, .form-select-lg, .col-form-label-lg),
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .input-group-lg > :is(.btn, .form-control, .form-select, .input-group-text) {
    font-size: calc(1.25rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) :is(.form-control-sm, .form-select-sm, .col-form-label-sm, .valid-tooltip, .invalid-tooltip, .dropdown-header, .dropdown-footer, .btn-tool, .direct-chat-infos, .contacts-list-status),
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .input-group-sm > :is(.btn, .form-control, .form-select, .input-group-text) {
    font-size: calc(.875rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .dropdown-menu {
    font-size: calc(var(--bs-dropdown-font-size, 1rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .navbar-brand {
    font-size: calc(var(--bs-navbar-brand-font-size, 1.25rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .navbar-toggler {
    font-size: calc(var(--bs-navbar-toggler-font-size, 1.25rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .page-link {
    font-size: calc(var(--bs-pagination-font-size, 1rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) :is(.progress, .progress-stacked) {
    font-size: calc(var(--bs-progress-font-size, .75rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .toast {
    font-size: calc(var(--bs-toast-font-size, .875rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .tooltip {
    font-size: calc(var(--bs-tooltip-font-size, .875rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .popover {
    font-size: calc(var(--bs-popover-font-size, .875rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .popover-header {
    font-size: calc(var(--bs-popover-header-font-size, 1rem) * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .card-title {
    font-size: calc(1.1rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .sidebar-menu .nav-header {
    font-size: calc(.9rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .navbar-badge {
    font-size: calc(.6rem * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .timeline > div > .timeline-item > .time {
    font-size: calc(12px * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .timeline > div > .timeline-item > .timeline-header {
    font-size: calc(16px * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .daterangepicker .calendar-table :is(th, td),
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .daterangepicker select:is(.monthselect, .yearselect, .hourselect, .minuteselect, .secondselect, .ampmselect),
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .daterangepicker .drp-selected,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .daterangepicker .drp-buttons .btn,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .daterangepicker .ranges li {
    font-size: calc(13px * var(--admin-font-scale));
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .daterangepicker :is(th.week, td.week) {
    font-size: 80%;
}

/* Match the priority and responsive sizes of Bootstrap's font-size utilities. */
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-1 {
    font-size: calc((1.375rem + 1.5vw) * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-2 {
    font-size: calc((1.325rem + .9vw) * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-3 {
    font-size: calc((1.3rem + .6vw) * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-4 {
    font-size: calc((1.275rem + .3vw) * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-5 {
    font-size: calc(1.25rem * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-6 {
    font-size: calc(1rem * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-7,
:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-7 .dropdown-menu {
    font-size: calc(.875rem * var(--admin-font-scale)) !important;
}

:where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-8 {
    font-size: calc(.75rem * var(--admin-font-scale)) !important;
}

@media (min-width: 1200px) {
    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h1,
    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h1 {
        font-size: calc(2.5rem * var(--admin-font-scale));
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h2,
    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h2 {
        font-size: calc(2rem * var(--admin-font-scale));
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h3,
    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h3 {
        font-size: calc(1.75rem * var(--admin-font-scale));
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) h4,
    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .h4,
    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) legend {
        font-size: calc(1.5rem * var(--admin-font-scale));
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-1 {
        font-size: calc(2.5rem * var(--admin-font-scale)) !important;
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-2 {
        font-size: calc(2rem * var(--admin-font-scale)) !important;
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-3 {
        font-size: calc(1.75rem * var(--admin-font-scale)) !important;
    }

    :where(body[data-admin-font-size]:not([data-admin-font-size="20"])) .fs-4 {
        font-size: calc(1.5rem * var(--admin-font-scale)) !important;
    }
}

/* Remote widgets and menus share the same text scale as their parent screen. */
.admin-shell .app-main, .admin-shell .app-content { min-width: 0; }
.admin-shell .admin-widget-chart {
    position: relative;
    min-width: 0;
    height: clamp(14rem, 38vh, calc(19rem * var(--admin-font-scale, 1)));
}
.admin-shell .admin-widget-chart canvas { display: block; max-width: 100%; }
.admin-shell .admin-widget-table:focus-visible { outline: 3px solid var(--admin-accent); outline-offset: -3px; }
.admin-shell .admin-widget-table :is(td, th) { overflow-wrap: anywhere; }
.admin-shell .admin-widget-table .table { min-width: 16rem; }
.admin-shell .select2-container { min-width: 0; max-width: 100%; }
.admin-shell .select2-container .select2-selection--single { height: auto; min-height: 2.25rem; }
.admin-shell .select2-container .select2-selection__rendered { max-width: 100%; }
.admin-shell .daterangepicker {
    max-width: calc(100vw - 1.125rem);
    border-radius: .75rem;
}
.admin-shell .daterangepicker .drp-buttons { white-space: normal; }

:where(.admin-shell) .select2-container .select2-selection,
:where(.admin-shell) .select2-container .select2-results__option,
:where(.admin-shell) .select2-container .select2-search__field {
    font-size: calc(.9375rem * var(--admin-font-scale, 1));
}

@media (max-width: 359px) {
    .admin-shell .daterangepicker .drp-calendar { max-width: 100%; }
    .admin-shell .daterangepicker .calendar-table :is(th, td) { min-width: 0; }
}

.admin-shell .home-widget-status {
    margin: .75rem;
    padding: .5rem .625rem;
    color: var(--admin-secondary);
    background: var(--admin-inset);
    border-radius: .625rem;
    font-size: calc(.8125rem * var(--admin-font-scale, 1));
}
.admin-shell .home-widget-status--error {
    color: var(--admin-danger);
    background: var(--admin-danger-bg);
}
.admin-shell .home-widget-status .btn {
    margin-inline-start: .25rem;
    min-height: 2.25rem;
}

.admin-shell .admin-preloader {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--admin-surface) 75%, transparent);
}

.admin-shell .app-header :is(a, button):focus-visible {
    outline: 2px solid var(--admin-accent);
    outline-offset: -2px;
}

.admin-sidebar-icon {
    display: inline-block;
    width: 1em;
    height: .75em;
    border-block: 1.5px solid currentColor;
    background: linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat;
    vertical-align: .05em;
}

.admin-notification-icon {
    display: inline-block;
    position: relative;
    width: .75em;
    height: .75em;
    border: 1.5px solid currentColor;
    border-radius: 50% 50% 20% 20%;
}

.admin-notification-icon::after {
    content: '';
    position: absolute;
    inset: 100% 30% auto;
    border-bottom: 1.5px solid currentColor;
    margin-top: .15em;
}

.admin-shell .select2-container--bootstrap-5 :is(.select2-selection, .select2-dropdown, .select2-search__field) {
    color: var(--admin-text);
    background-color: var(--admin-surface);
    border-color: var(--admin-border);
}

.admin-shell .select2-container--bootstrap-5 .select2-selection .select2-selection__rendered {
    color: var(--admin-text);
}

.admin-shell .select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    color: var(--admin-text);
    background: var(--admin-selected);
}
