/* =========================================================
   Восстановление корректного положения всплывающих окон
   Поведение как в рабочей версии: overlay на весь экран,
   окно по центру, большие окна прокручиваются внутри.
   ========================================================= */

.login-overlay,
.modal-overlay {
    position: fixed !important;
    inset: 0 !important;

    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;

    align-items: center !important;
    justify-content: center !important;

    padding: 16px !important;
    overflow: auto !important;

    z-index: 2147483000 !important;
}

#loginOverlay {
    display: flex !important;
}

#loginOverlay[style*="display: none"],
#loginOverlay[style*="display:none"] {
    display: none !important;
}

.modal-overlay:not(#loginOverlay) {
    display: none;
}

.modal-overlay[style*="flex"],
.modal-overlay[style*="display: flex"],
.login-overlay[style*="flex"],
.login-overlay[style*="display: flex"] {
    display: flex !important;
}

.login-box,
.modal-box {
    position: relative !important;

    margin: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;

    max-height: calc(100vh - 32px) !important;
    max-height: calc(100dvh - 32px) !important;
    overflow-y: auto !important;

    z-index: 2147483001 !important;
}

.builders-info-modal-box,
.builder-detail-modal-box,
.all-closed-modal-box,
.report-modal-box,
.admin-comments-box,
.client-info-modal-box,
.full-comment-modal-box {
    max-height: calc(100vh - 32px) !important;
    max-height: calc(100dvh - 32px) !important;
    overflow-y: auto !important;
}

.builders-info-table-wrap {
    max-height: calc(100vh - 300px) !important;
    max-height: calc(100dvh - 300px) !important;
    min-height: 180px !important;
    overflow: auto !important;
}

@media (max-height: 760px) {
    .login-overlay,
    .modal-overlay {
        padding: 10px !important;
    }

    .login-box,
    .modal-box,
    .builders-info-modal-box,
    .builder-detail-modal-box,
    .all-closed-modal-box,
    .report-modal-box,
    .admin-comments-box,
    .client-info-modal-box,
    .full-comment-modal-box {
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
    }

    .builders-info-table-wrap {
        max-height: calc(100vh - 240px) !important;
        max-height: calc(100dvh - 240px) !important;
        min-height: 140px !important;
    }
}

@media (max-width: 950px) {
    .login-overlay,
    .modal-overlay {
        align-items: center !important;
        justify-content: center !important;
        padding: 10px !important;
        overflow: auto !important;
    }

    .login-box,
    .modal-box,
    .builders-info-modal-box,
    .builder-detail-modal-box,
    .all-closed-modal-box,
    .report-modal-box,
    .admin-comments-box,
    .client-info-modal-box,
    .full-comment-modal-box {
        width: 100% !important;
        max-width: 100% !important;
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
        margin: auto !important;
        overflow-y: auto !important;
    }

    .builders-info-table-wrap {
        max-height: calc(100vh - 260px) !important;
        max-height: calc(100dvh - 260px) !important;
        min-height: 150px !important;
    }
}
