/* Bootstrap's later .d-block utility must not undo QualiCube.UIComponents's flex centering. */
.modal.qc-ui-modal-overlay {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: .75rem;
}

.modal.qc-ui-modal-overlay > .modal-dialog {
    width: 100%;
    max-width: var(--bs-modal-width, 32rem);
    min-height: 0;
    height: auto;
    max-height: calc(100dvh - 1.5rem);
    margin: 0;
}

/* The file picker needs less room than the subsequent column mapping. */
.modal.qc-ui-modal-overlay > .modal-dialog:has(.modal-body > input[type="file"]) {
    max-width: 42rem;
}

.modal:not(.qc-ui-modal-overlay) > .modal-dialog {
    display: flex;
    align-items: center;
    height: auto;
    min-height: calc(100% - 1.5rem);
    margin: .75rem auto;
}

.modal .modal-dialog > .modal-content {
    flex: 0 1 auto;
    max-height: calc(100dvh - 1.5rem);
}

.modal .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.modal .modal-content > .modal-body,
.modal .modal-content > form > .modal-body {
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 575.98px) {
    .modal:not(.qc-ui-modal-overlay) > .modal-dialog {
        max-width: calc(100% - 1.5rem);
    }
}
