/* Shared usability and accessibility rules for staff and customer templates. */
html,
body {
    max-width: 100%;
    overflow-x: clip;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

.row > *,
.d-flex > *,
.operations-content,
.directory-content,
main {
    min-width: 0;
}

:where(button, .btn, .nav-link, .list-group-item, .dropdown-item) {
    overflow-wrap: anywhere;
}

:where(pre, code) {
    max-width: 100%;
}

pre {
    overflow-x: auto;
}

.accessibility-panel {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 7000;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: calc(100vw - 28px);
    font-family: Arial, sans-serif;
}

.accessibility-launcher,
.accessibility-controls button {
    min-height: 44px;
    padding: 9px 13px;
    border: 2px solid #111827;
    border-radius: 10px;
    background: #fff;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .15);
}

.accessibility-launcher {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.accessibility-controls {
    order: -1;
    display: none;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 7px;
    padding: 10px;
    border: 2px solid #111827;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 32px rgba(15, 23, 42, .2);
}

.accessibility-panel[data-a11y-open="true"] .accessibility-controls {
    display: flex;
}

.accessibility-caption {
    color: #111827;
    font-size: 14px;
    font-weight: 800;
}

.accessibility-controls button[aria-pressed="true"],
.accessibility-controls button.is-active {
    background: #111827;
    color: #fff;
}

html[data-a11y-enabled="true"][data-a11y-scale="120"] :where(
    p, li, td, th, label, input, select, textarea,
    .form-text, .helptext, .small, small
) {
    font-size: max(1em, 17px) !important;
}

html[data-a11y-enabled="true"][data-a11y-scale="140"] :where(
    p, li, td, th, label, input, select, textarea,
    .form-text, .helptext, .small, small
) {
    font-size: max(1em, 19px) !important;
}

html[data-a11y-enabled="true"] :where(
    p, li, td, th, label, input, select, textarea,
    .form-text, .helptext, .small, small
) {
    line-height: 1.5 !important;
}

html[data-a11y-enabled="true"][data-a11y-scale="120"] :where(h1, .h1) { font-size: clamp(2rem, 4vw, 2.5rem) !important; }
html[data-a11y-enabled="true"][data-a11y-scale="120"] :where(h2, .h2) { font-size: clamp(1.6rem, 3vw, 2rem) !important; }
html[data-a11y-enabled="true"][data-a11y-scale="140"] :where(h1, .h1) { font-size: clamp(2.2rem, 4vw, 2.8rem) !important; }
html[data-a11y-enabled="true"][data-a11y-scale="140"] :where(h2, .h2) { font-size: clamp(1.8rem, 3vw, 2.2rem) !important; }

html[data-a11y-enabled="true"] :where(input, select, textarea) {
    border-width: 2px !important;
}

html[data-a11y-enabled="true"] :where(.text-muted, .form-text, .helptext) {
    color: #4b5563 !important;
}

html[data-a11y-contrast="true"] body,
html[data-a11y-contrast="true"] :where(.card, .modal-content, .dropdown-menu, .list-group-item, .site-header, .site-footer) {
    background: #fff !important;
    color: #000 !important;
}

html[data-a11y-contrast="true"] :where(p, span, div, label, h1, h2, h3, h4, h5, h6, td, th, small) {
    color: inherit;
}

html[data-a11y-contrast="true"] :where(a, .btn-link) {
    color: #0000b8 !important;
    text-decoration: underline !important;
}

html[data-a11y-contrast="true"] :where(button, .btn, input, select, textarea, .card, table, th, td) {
    border-color: #000 !important;
}

html[data-a11y-contrast="true"] :where(.btn-primary, .btn-success, .active, [aria-current="page"]) {
    background: #000 !important;
    color: #fff !important;
}

.skip-link {
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 10000;
    padding: .65rem 1rem;
    border-radius: .5rem;
    background: #111827;
    color: #fff;
    font-weight: 700;
    transform: translateY(-150%);
    transition: transform .15s ease;
}

.skip-link:focus {
    color: #fff;
    transform: translateY(0);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > table {
    margin-bottom: 0;
}

.table-responsive:focus-visible {
    border-radius: .5rem;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .35);
    outline: none;
}

.form-label,
form label:not(.form-check-label) {
    font-weight: 600;
}

.helptext,
.form-text {
    color: #64748b;
}

.errorlist {
    margin: .35rem 0 0;
    padding-left: 1.1rem;
    color: #b91c1c;
    font-size: .875rem;
}

.btn-toolbar,
.page-actions,
.card-header .d-flex,
.modal-footer {
    flex-wrap: wrap;
    gap: .5rem;
}

[aria-busy="true"] {
    cursor: wait;
    opacity: .72;
}

@media (max-width: 767.98px) {
    .accessibility-panel {
        top: auto;
        right: auto;
        left: 10px;
        bottom: 10px;
        align-items: flex-start;
    }

    .accessibility-launcher {
        max-width: 210px;
    }

    .accessibility-controls {
        max-width: min(360px, calc(100vw - 20px));
    }

    .content-wrap,
    .page-content {
        padding-inline: .75rem;
    }

    .card {
        border-radius: 12px;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive > table {
        font-size: .9rem;
    }

    .table-responsive-wide > table {
        min-width: 680px;
    }

    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    .btn:not(.btn-sm),
    button:not(.btn-sm),
    input[type="submit"] {
        min-height: 44px;
    }

    .modal-dialog {
        width: auto;
        max-width: calc(100vw - 20px);
        margin: 10px auto;
    }

    .page-actions,
    .card-header > .d-flex,
    main > .d-flex:first-child {
        align-items: stretch !important;
        flex-direction: column;
    }

    .page-actions > *,
    .card-header > .d-flex > * {
        width: 100%;
    }

    :where(.btn, button, input[type="submit"]) {
        white-space: normal !important;
    }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
    .container,
    .container-lg,
    .container-xl {
        max-width: calc(100% - 24px);
    }

    .content-wrap {
        padding-inline: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (prefers-contrast: more) {
    :where(a, button, input, select, textarea, .card, table) {
        border-color: currentColor !important;
    }

    :where(a, button, input, select, textarea):focus-visible {
        outline-width: 4px;
    }
}

@media (forced-colors: active) {
    :where(a, button, input, select, textarea):focus-visible {
        outline: 3px solid CanvasText;
    }
}
