/* Edit panel (redesign): the Narrow and Form popup categories dock to the right edge of the
   window as a full-height side panel instead of a centred dialog. Confirm stays a small centred
   dialog; Wide, Data and Full stay centred dialogs (pickers over large tables, composers).
   The rule and its reasons: docs/dev/guides/design-system.md, "Responsive layout conventions".

   Nothing is set per page. A DxPopup's Width parameter reaches the browser twice on the dialog
   element (<dxbl-modal-dialog class="dxbl-popup">): as its `width` attribute, and as the inline
   `width: …` the DevExpress script writes into style.cssText. Either one identifies the category,
   so the selectors below match the PopupWidth.Narrow / PopupWidth.Form values (560px / 760px).
   A grid's PopupEditForm carries the same category as a class (PopupWidth.Css), on the dialog or
   on the modal root. PopupLayoutRules pins that these selectors name exactly those two
   categories, so a changed constant fails a test instead of silently centring every form again.

   DevExpress keeps owning everything else: header, close button, Esc, focus trap, footer.
   Positioning goes through the theme's own variables (--dxbl-popup-justify-self/-align-self,
   which the theme applies with !important), never by moving the element by hand. This file loads
   after shell.css and before workspace.css; every rule here outranks both by specificity. */

/* The panel: right edge, full height, flush. Its width stays the category width. */
.dxbl-modal > .dxbl-modal-root > .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form),
.dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) > .dxbl-modal-root > .dxbl-popup {
    --dxbl-popup-margin: 0;
    --dxbl-popup-justify-self: end;
    --dxbl-popup-align-self: stretch;
    --dxbl-popup-border-radius: 0;
    height: 100vh;
    height: 100dvh;
    /* shell.css keeps a gutter round a centred dialog with !important; a panel touches the edge.
       100% of the modal root, not 100vw, which would count a page scrollbar too. */
    max-width: 100% !important;
    animation: bz-panel-in var(--bz-duration-slow) var(--bz-ease-drawer);
}

/* Header on top, body scrolls (shell.css already makes .dxbl-modal-body the scroller), footer
   stays at the bottom: the content column simply fills the panel's height. */
.dxbl-modal > .dxbl-modal-root > .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form) > .dxbl-modal-content,
.dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) > .dxbl-modal-root > .dxbl-popup > .dxbl-modal-content {
    height: 100%;
    max-height: none;
    border-block-width: 0;
    border-inline-end-width: 0;
    /* workspace.css lifts a centred dialog's content; the panel slides as a whole instead. */
    animation: none;
}

/* The modal root scrolls a centred dialog. A panel scrolls its own body, and the root must not
   flash a horizontal scrollbar while the panel slides in from beyond the edge. */
.dxbl-modal > .dxbl-modal-root:has(> .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form)),
.dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) > .dxbl-modal-root {
    overflow: hidden;
}

/* The page stays readable beside a panel: a lighter backdrop, derived from the shared one. */
.dxbl-modal:has(> .dxbl-modal-root > .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form)),
.dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) {
    --dxbl-popup-back-bg: color-mix(in srgb, var(--dxbl-popups-backdrop-bg) 65%, transparent);
}

/* Phone: the panel is the whole screen. The inline width DevExpress writes is a normal
   declaration, so !important is what replaces it. */
@media (max-width: 760px) {
    .dxbl-modal > .dxbl-modal-root > .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form),
    .dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) > .dxbl-modal-root > .dxbl-popup {
        width: 100% !important;
        box-shadow: none;
    }

    .dxbl-modal > .dxbl-modal-root > .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form) > .dxbl-modal-content,
    .dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) > .dxbl-modal-root > .dxbl-popup > .dxbl-modal-content {
        border-inline-start-width: 0;
        padding-block: env(safe-area-inset-top, 0px) env(safe-area-inset-bottom, 0px);
    }
}

/* Reduced motion: no slide, a short fade (tokens.css shortens --bz-duration-slow there). */
@media (prefers-reduced-motion: reduce) {
    .dxbl-modal > .dxbl-modal-root > .dxbl-popup:is([width="560px"], [width="760px"], [style*="width: 560px"], [style*="width: 760px"], .bz-dxgrid-popup-form.bz-popup-narrow, .bz-dxgrid-popup-form.bz-popup-form),
    .dxbl-modal.bz-dxgrid-popup-form:is(.bz-popup-narrow, .bz-popup-form) > .dxbl-modal-root > .dxbl-popup {
        animation-name: bz-panel-fade;
    }
}

/* `translate`, not `transform`: DevExpress writes an inline transform only for a positioned or
   dragged popup, and the two properties compose instead of overwriting each other.
   shortcut: the slide assumes a left-to-right page; mirror it if an RTL locale ships. */
@keyframes bz-panel-in { from { translate: 100% 0; } }
@keyframes bz-panel-fade { from { opacity: 0; } }
