/* Shared overflow handling for tables rendered inside FastAdmin iframe dialogs. */
html,
body {
    overscroll-behavior: contain;
}

/*
 * A dialog page is rendered inside a Layer iframe.  Give its content a real
 * height and one scroll owner, so nested selectors, forms and date pickers
 * can always be reached with a mouse wheel or touch scroll.
 */
body.is-dialog {
    overflow: hidden;
}

body.is-dialog #main,
body.is-dialog #main > .tab-content,
body.is-dialog #content,
body.is-dialog #content > .row,
body.is-dialog #content > .row > [class*='col-'] {
    height: 100%;
    min-height: 0;
}

body.is-dialog #main .content {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Layer iframe dialogs, including dialogs opened from another dialog. */
.layui-layer.layui-layer-iframe {
    max-height: calc(100vh - 16px) !important;
    overflow: hidden !important;
}

.layui-layer.layui-layer-iframe .layui-layer-content {
    max-height: calc(100vh - 61px) !important;
    overflow: hidden !important;
}

.layui-layer.layui-layer-iframe .layui-layer-content > iframe {
    display: block;
    width: 100%;
    height: 100% !important;
}

/* Content-style Layer popups use their body as the vertical scroll region. */
.layui-layer.layui-layer-page .layui-layer-content {
    max-height: calc(100vh - 110px) !important;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Vue dialogs used by newer backend pages. */
.el-overlay {
    overflow: auto;
    padding: 8px;
    box-sizing: border-box;
}

.el-overlay .el-dialog {
    display: flex;
    max-height: calc(100vh - 16px);
    margin: 0 auto !important;
    flex-direction: column;
}

.el-overlay .el-dialog__body {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Bootstrap dialogs still used by legacy backend tools. */
.modal {
    overflow-y: auto !important;
}

.modal-dialog {
    display: flex;
    max-height: calc(100vh - 16px);
    margin-top: 8px;
    margin-bottom: 8px;
    flex-direction: column;
}

.modal-dialog .modal-content {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.modal-dialog .modal-body {
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

body.is-dialog .fixed-table-container {
    max-width: 100%;
}

body.is-dialog .fixed-table-body {
    max-width: 100%;
    overflow-x: scroll !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable both-edges;
    touch-action: pan-x pan-y;
}

body.is-dialog .fixed-table-body::-webkit-scrollbar {
    width: 10px;
    height: 12px;
}

body.is-dialog .fixed-table-body::-webkit-scrollbar-track {
    background: rgba(223, 230, 239, .8);
}

body.is-dialog .fixed-table-body::-webkit-scrollbar-thumb {
    min-width: 48px;
    border: 3px solid transparent;
    border-radius: 8px;
    background: rgba(99, 120, 151, .7);
    background-clip: padding-box;
}
