/* NI Office v3.0.73 – one viewport-centered placement for portal dialogs.
   The portal app is a fixed, clipped window with its own scrolling context.
   Relying on dialog { inset: 0; margin: auto } can anchor horizontal positioning
   incorrectly in WordPress themes / nested portal containers.
   Position the popup explicitly relative to the visible browser viewport. */
html body.tke-op-page dialog[open] {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
    box-sizing: border-box !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
}
/* Explicit safeguard for nickname, which previously appeared on the far left.
   The generic selector also applies to the other native NI Office dialogs. */
html body.tke-op-page #tke-v371-nickname-dialog[open] {
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    margin: 0 !important;
    transform: translate(-50%, -50%) !important;
}
/* Non-native overlays already use flexbox. Preserve that behavior while
   ensuring the visible cards are centered and can scroll on smaller screens. */
html body.tke-op-page .tke-modal,
html body.tke-op-page .tke-lmra-modal:not([hidden]),
html body.tke-op-page .tke-service-handover-modal:not([hidden]),
html body.tke-op-page .tke-status-comment-popup.is-open {
    align-items: center !important;
    justify-content: center !important;
}
html body.tke-op-page .tke-customer-info-layer:not([hidden]) {
    align-items: center !important;
    justify-content: center !important;
}
/* Avoid large popup content escaping the screen, including touch devices.
   Do not override component-specific overflow and flex column layouts. */
@media (max-width: 600px) {
    html body.tke-op-page dialog[open] {
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100dvh - 16px) !important;
    }
}
/* A screen-only alignment fix: printed reports keep their native layout. */
@media print {
    html body.tke-op-page dialog[open] {
        transform: none !important;
        position: static !important;
        max-height: none !important;
    }
}
