/* Shared close control for static and dynamically loaded Bootstrap modals. */
body .modal .modal-dialog {
    --nc-modal-gutter: 16px;
    max-height: calc(100vh - 2 * var(--nc-modal-gutter));
    max-height: calc(100dvh - 2 * var(--nc-modal-gutter));
    margin-top: var(--nc-modal-gutter);
    margin-bottom: var(--nc-modal-gutter);
}
body .modal .modal-dialog.modal-dialog-centered {
    min-height: calc(100vh - 2 * var(--nc-modal-gutter));
    min-height: calc(100dvh - 2 * var(--nc-modal-gutter));
}
body .modal .modal-dialog .modal-content {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 2 * var(--nc-modal-gutter));
    max-height: calc(100dvh - 2 * var(--nc-modal-gutter));
    overflow: hidden;
}
body .modal .modal-dialog .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: inherit;
}
body .modal .modal-dialog .modal-content .modal-header,
body .modal .modal-dialog .modal-content .modal-footer {
    flex: 0 0 auto;
}
body .modal .modal-dialog .modal-content .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scroll-padding-block: 16px;
}
@media (max-width: 575.98px) {
    body .modal .modal-dialog {
        --nc-modal-gutter: 8px;
        max-height: calc(100dvh - 2 * var(--nc-modal-gutter) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        margin-top: calc(var(--nc-modal-gutter) + env(safe-area-inset-top));
        margin-bottom: calc(var(--nc-modal-gutter) + env(safe-area-inset-bottom));
    }
    body .modal .modal-dialog.modal-dialog-centered {
        min-height: calc(100dvh - 2 * var(--nc-modal-gutter) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
    body .modal .modal-dialog .modal-content {
        max-height: calc(100dvh - 2 * var(--nc-modal-gutter) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}
body .modal .modal-dialog .modal-content .modal-header button.close {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    margin: 0 0 0 16px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--nd-bad-bg, #fff1f2);
    color: var(--nd-bad-text, #be123c);
    opacity: 1;
    text-shadow: none;
    cursor: pointer;
    transition: background-color .18s, border-color .18s, box-shadow .18s;
}
body .modal .modal-dialog .modal-content .modal-header button.close > * { display: none; }
body .modal .modal-dialog .modal-content .modal-header button.close::before,
body .modal .modal-dialog .modal-content .modal-header button.close::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform: rotate(45deg);
    pointer-events: none;
}
body .modal .modal-dialog .modal-content .modal-header button.close::after { transform: rotate(-45deg); }
body .modal .modal-dialog .modal-content .modal-header button.close:hover {
    border-color: currentColor;
    color: var(--nd-bad-text, #be123c);
    background: var(--nd-bad-bg, #fff1f2);
    opacity: 1;
}
body .modal .modal-dialog .modal-content .modal-header button.close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}
@media (pointer: coarse) {
    body .modal .modal-dialog .modal-content .modal-header button.close {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
    }
}
@media (prefers-reduced-motion: reduce) {
    body .modal .modal-dialog .modal-content .modal-header button.close { transition: none; }
}
