/*
 * nxlblazor-dx-overrides.css
 *
 * Overrides for the DevExpress Fluent theme.
 * Loaded after all DevExpress theme sheets via NxlHeadStyles.razor.
 *
 * DevExpress Fluent (v26+) intentionally sets cursor:default on buttons to
 * match native Windows Fluent UX guidelines. This file restores the expected
 * web behaviour (cursor:pointer) for interactive elements.
 */

/* ─── Buttons ────────────────────────────────────────────────────────────────
   .dxbl-btn is the base class for DxButton, DxToolbarItem, and the window
   close button. Target only enabled, non-readonly instances so that disabled
   buttons keep the default cursor.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-btn:not(:disabled):not(.dxbl-disabled) {
    cursor: pointer;
}

/* ─── Toolbar dropdown items ─────────────────────────────────────────────────
   Items that appear in overflow / dropdown menus of DxToolbar.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-toolbar-dropdown-item:not(.dxbl-disabled) {
    cursor: pointer;
}

/* ─── Drop-down menu separators ──────────────────────────────────────────────
   NxlDropDownButtonItem draws its group separator only while it is visible, but a visible
   group leader whose earlier items are all hidden would still open the menu with a line. A
   hidden item leaves an empty list item behind (no button).
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-btn-dropdown-list > li[role="separator"]:not(li:has(button) ~ li[role="separator"]) {
    display: none;
}

/* ─── Plain listbox variant ──────────────────────────────────────────────────
   Removes the border and forces height:auto so the list shrinks to its items.
   Apply via CssClass="nxl-listbox-plain" on NxlListBox / DxListBox.
   ─────────────────────────────────────────────────────────────────────────── */
.nxl-listbox-plain {
    height: auto;
    border: none;
    min-width: 100px;
}

/* ─── DxTabs: directional content padding ────────────────────────────────────
   Standalone DxTabs (not nested inside DxFormLayout) has zero inner padding on
   the content panel by default. Apply on the single side adjacent to
   the tab strip — matching the DevExpress FormLayout tab-group content token
   (--DS-sizing-120). The other three sides inherit the outer layout padding
   (--nxl-shell-content-padding on .nxl-shell__content), keeping content visually balanced.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-tabs.dxbl-tabs-top    > .dxbl-tabs-content-panel > .dxbl-tabs-content { padding-top:    1.25rem; }
.dxbl-tabs.dxbl-tabs-bottom > .dxbl-tabs-content-panel > .dxbl-tabs-content { padding-bottom: 1.25rem; }
.dxbl-tabs.dxbl-tabs-left   > .dxbl-tabs-content-panel > .dxbl-tabs-content { padding-left:   1.75rem; }
.dxbl-tabs.dxbl-tabs-right  > .dxbl-tabs-content-panel > .dxbl-tabs-content { padding-right:  1.75rem; }

/* ─── DxTabs left/right: room before the divider ─────────────────────────────
   A vertical strip's items get DevExpress's 0.625rem inline padding on both
   sides, which crowds the text against the divider between strip and content.
   Widen only the side facing the divider. DevExpress sets the padding as a
   shorthand from a selector following the strip's whole internal DOM path
   (scroll viewer > ul > li > item), hence !important on the one longhand.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-tabs.dxbl-tabs-left  > .dxbl-tabs-tablist .dxbl-tabs-item { padding-right: 1rem !important; }
.dxbl-tabs.dxbl-tabs-right > .dxbl-tabs-tablist .dxbl-tabs-item { padding-left:  1rem !important; }

/* ─── DxTabs left/right: auto height ────────────────────────────────────────
   Left/right-position DxTabs defaults to height:100%, expecting to fill a
   dedicated full-height panel. In the NxlFrame layout (.nxl-shell__content
   is a scrollable flex column with NxlPageHeader above), this causes tabs to
   swallow the full viewport height. Override to height:auto so the component
   sizes to its content and scrolls naturally with the rest of the page.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-tabs.dxbl-tabs-left,
.dxbl-tabs.dxbl-tabs-right {
    height: auto;
}

/* ─── DxTabs: labels that jump up when clicked ──────────────────────────────
   Each tab's text container holds the label and a hidden bold copy of it (the
   space reservation, height 0) so the tab keeps its width when it turns active.
   The copy's 20px line still overflows the 0px box, and the container clips it
   with overflow:hidden, which leaves it a scroll container: a click on the label
   scrolls it ~10px and the label shows cut off at the top. clip hides the same
   overflow without being scrollable. DevExpress sets overflow from a selector
   following the strip's whole internal DOM path, hence !important.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-tabs .dxbl-tabs-item > .dxbl-tabs-text-container {
    overflow: clip !important;
}

/* ─── DxFlyout: hidden arrow ─────────────────────────────────────────────────
   DxFlyout has no parameter for its pointer arrow. NxlFlyout with
   Arrow="NxlFlyoutArrow.Hidden" adds this class to the dialog (DxFlyout.CssClass
   lands on .dxbl-flyout-dialog, which contains the <dxbl-flyout-arrow> element).
   display:none also removes the gap the arrow reserves: DevExpress measures the
   .dxbl-arrow box on every positioning pass and adds its size to Distance, so a
   hidden arrow measures 0 and the panel sits Distance px from its target.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-flyout .nxl-flyout--arrow-hidden .dxbl-arrow {
    display: none;
}

/* ─── NxlButtonGroup: wrapping, Fill width, Spaced buttons ─────────────────────
   NxlButtonGroup puts nxl-button-group (+ --fill / --spaced) on DevExpress's
   .dxbl-btn-group element. The group wraps instead of overflowing a narrow
   container. Spaced undoes DevExpress's joining, which drops the inner corner
   radii and overlaps the borders by one border width through high-specificity
   :not() chains (hence !important).
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-btn-group.nxl-button-group {
    flex-wrap: wrap;
    max-width: 100%;
}

.dxbl-btn-group.nxl-button-group--fill {
    display: flex;
    width: 100%;
}

.dxbl-btn-group.nxl-button-group--fill > .dxbl-btn {
    flex: 1 1 0;
    min-width: max-content;
}

.dxbl-btn-group.nxl-button-group--spaced {
    gap: var(--nxl-space-2, 0.5rem);
}

.dxbl-btn-group.nxl-button-group--spaced > .dxbl-btn {
    border-radius: var(--dxbl-btn-border-radius) !important;
    margin-inline-end: 0 !important;
    margin-bottom: 0 !important;
}

/* A pressed item already switches to Contained Primary (NxlButtonGroupItem).
   In Multiple mode DevExpress also marks it .dxbl-active, whose group variables
   darken it to the "selected" shade; Radio mode does not. The active variables
   are reset to the rest ones so both modes show the same primary. */
.dxbl-btn-group.nxl-button-group > .dxbl-btn.dxbl-active {
    --dxbl-btn-active-bg: var(--dxbl-btn-bg);
    --dxbl-btn-active-color: var(--dxbl-btn-color);
    --dxbl-btn-active-border-color: var(--dxbl-btn-border-color);
}

/* Joined buttons overlap by one border width, and at fractional widths the
   rounding can make that two pixels. The next (outline) button's background is
   transparent, so the pressed fill showed through it as a 1px strip beside its
   border — a stray line that vanished when hovering that button filled it.
   The pressed item stacks above its neighbours instead, covering the overlap. */
.dxbl-btn-group.nxl-button-group > .dxbl-btn.nxl-button-group-item--pressed {
    z-index: 1;
}

/* ─── NxlEditorAddon: a static editor button ─────────────────────────────────
   The add-on is a DxEditorButton, so it shares the edit box's height, border
   and theme, and a click on it still focuses the input. It keeps the rest look
   on hover and press, and the default cursor. DevExpress sets the hover/active
   variables on the button itself (.dxbl-text-edit > .dxbl-btn-group > .dxbl-btn),
   so they are reset there, one class stronger.
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-text-edit > .dxbl-btn-group > .dxbl-btn.nxl-editor-addon {
    --dxbl-btn-hover-bg: var(--dxbl-btn-bg);
    --dxbl-btn-hover-color: var(--dxbl-btn-color);
    --dxbl-btn-hover-border-color: var(--dxbl-btn-border-color);
    --dxbl-btn-active-bg: var(--dxbl-btn-bg);
    --dxbl-btn-active-color: var(--dxbl-btn-color);
    --dxbl-btn-active-border-color: var(--dxbl-btn-border-color);
    cursor: default;
}

/* ─── NxlEditorSelector / NxlEditorMenu: drop-down editor buttons ───────────
   A DxEditorButton showing the chosen item (or the menu's label) and a muted
   chevron. Long texts end in an ellipsis rather than squeezing the input.
   ─────────────────────────────────────────────────────────────────────────── */
.nxl-editor-selector-content,
.nxl-editor-menu-content {
    display: inline-flex;
    align-items: center;
    gap: var(--nxl-space-1);
    min-width: 0;
}

.nxl-editor-selector-text,
.nxl-editor-menu-text {
    max-width: var(--nxl-editor-selector-max-width, 10rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nxl-editor-selector-null {
    opacity: 0.6;
}

.nxl-editor-addon-chevron {
    font-size: 0.75em;
    opacity: 0.6;
}

/* The list fills the flyout edge to edge, as wide as its items: DevExpress pads
   the body through variables on the dialog element. */
.dxbl-flyout > .dxbl-flyout-dialog.nxl-editor-selector-flyout {
    --dxbl-flyout-body-padding-top: 0;
    --dxbl-flyout-body-padding-bottom: 0;
    --dxbl-flyout-body-padding-x: 0;
}

.nxl-editor-selector-list {
    border: none;
    min-width: 3rem;
    height: auto;
    max-height: inherit;
}

/* The editor's add-on pop-ups (see NxlEditorAddonPopups) stay out of the page
   flow, so the host elements DevExpress leaves in place take no gap. */
.nxl-editor-addon-popups {
    position: absolute;
    width: 0;
    height: 0;
    overflow: visible;
}

.nxl-editor-selector-item {
    display: inline-flex;
    align-items: center;
    gap: var(--nxl-space-2);
}

/* ─── Caption-less form item ────────────────────────────────────────────────
   NxlFormItem ShowCaption="false": no caption, and none of the room a
   horizontal caption keeps (DevExpress renders an empty one to align editors).
   ─────────────────────────────────────────────────────────────────────────── */
.dxbl-fl .nxl-form-item-bare > .dxbl-fl-empty-caption,
.dxbl-fl .nxl-form-item-bare > .dxbl-fl-cpt {
    display: none;
}

/* ─── Popup / window header actions ─────────────────────────────────────────
   NxlPopup and NxlWindow HeaderActions: the title takes the free space, so the
   actions sit right before DevExpress's close button (whose own auto margin
   then has nothing left to take).
   ─────────────────────────────────────────────────────────────────────────── */
.nxl-header-title {
    flex: 1 1 auto;
    min-width: 0;
}

.nxl-header-actions {
    display: flex;
    align-items: center;
    gap: var(--nxl-space-1);
}

/* ─── Dynamic form: invalid fields ───────────────────────────────────────────
   A field of NxlDynamicForm showing an error gets DevExpress's own invalid look
   on its editor: the theme's validation colour on the border, as DevExpress does
   inside an EditForm. The variables live on the editor element, so they are set
   there. Global, not scoped: a form rendering only its items (Layout Items) has
   no element of its own for a scoped rule to start from.
   ─────────────────────────────────────────────────────────────────────────── */
.nxl-dynamic-form-invalid .dxbl-text-edit {
    --dxbl-text-edit-border-color: var(--dxbl-text-edit-validation-invalid-color);
    --dxbl-text-edit-focus-border-color: var(--dxbl-text-edit-validation-invalid-color);
}

.nxl-dynamic-form-invalid .dxbl-checkbox {
    --dxbl-checkbox-check-element-border: var(--dxbl-checkbox-danger-unchecked-check-element-border);
    --dxbl-checkbox-hover-check-element-border: var(--dxbl-checkbox-danger-unchecked-hover-check-element-border);
}

/* ─── Message toasts ─────────────────────────────────────────────────────────
   NxlMessageToast on the light or dark toast theme (the app's own mode): a surface card
   whose accent (the type's colour, or the recoloured confirm button's) shows in a coloured
   bar and icon, the same accent NxlMessage.razor.css gives the popup's icon (the CssClass
   modifiers land on the dxbl-toast element itself).
   The body comes in through the template, stacked; DevExpress lays the template out as a
   padded row that leaves an empty strip under plain toasts. DevExpress styles the parts
   through .dxbl-toast-portal .dxbl-toast …, so the overrides start from the same chain.
   ─────────────────────────────────────────────────────────────────────────── */
.nxl-message-toast {
    --nxl-message-accent: var(--dxds-color-content-primary-default-rest, #0f6cbd);
    position: relative;
    overflow: hidden;
    max-width: calc(100vw - 2rem);
}

.nxl-message-toast.nxl-message-accent--success {
    --nxl-message-accent: var(--dxds-color-content-success-default-rest, #107c10);
}

.nxl-message-toast.nxl-message-accent--warning {
    --nxl-message-accent: var(--dxds-color-content-warning-default-rest, #f7630c);
}

.nxl-message-toast.nxl-message-accent--danger {
    --nxl-message-accent: var(--dxds-color-content-danger-default-rest, #c50f1f);
}

.nxl-message-toast.nxl-message-accent--info {
    --nxl-message-accent: var(--dxds-color-content-info-default-rest, #5c2e91);
}

.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-accent-line {
    flex: 0 0 auto;
    width: 4px;
    background-color: var(--nxl-message-accent);
}

/* The Tabler glyph fills DevExpress's 20px icon cell exactly, so it lines up with the
   title's 20px line instead of riding on the font's own line box. */
.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-icon-column {
    color: var(--nxl-message-accent);
}

.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-icon-column .dxbl-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 1;
    color: var(--nxl-message-accent);
}

.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-content {
    row-gap: 0;
}

.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-text-content:empty {
    display: none;
}

.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-template {
    flex-direction: column;
    padding: 0;
}

.dxbl-toast-portal .dxbl-toast.nxl-message-toast .dxbl-toast-template:empty {
    display: none;
}

.nxl-message-toast-body {
    display: flex;
    flex-direction: column;
    gap: var(--nxl-space-3);
    min-width: 0;
}

/* A toast is too narrow for side-by-side fields: every form item takes the full row. */
.nxl-message-toast-body .dxbl-fl [class*="dxbl-col-"] {
    flex: 0 0 100%;
    max-width: 100%;
}

.nxl-message-toast-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
}

.nxl-message-toast-text {
    font-size: 14px;
    line-height: 20px;
    word-break: break-word;
}

.nxl-message-toast-text p:last-child {
    margin-bottom: 0;
}

.nxl-message-toast-text ul,
.nxl-message-toast-text ol {
    margin: var(--nxl-space-1) 0 0;
    padding-left: 1.25rem;
}

/* A plain toast's actions: text buttons tucked under the message, their label flush with its
   right edge. Fluent draws a text button grey until hovered; here it rests in its own colour, so
   the action reads as one. */
.nxl-message-toast-actions {
    margin: calc(-1 * var(--nxl-space-2)) calc(-1 * var(--nxl-space-2)) calc(-1 * var(--nxl-space-1)) 0;
}

.nxl-message-toast-actions .dxbl-btn.dxbl-btn-text-primary { --dxbl-btn-text-color: var(--dxds-color-content-primary-default-rest, #0f6cbd); }
.nxl-message-toast-actions .dxbl-btn.dxbl-btn-text-success { --dxbl-btn-text-color: var(--dxds-color-content-success-default-rest, #107c10); }
.nxl-message-toast-actions .dxbl-btn.dxbl-btn-text-warning { --dxbl-btn-text-color: var(--dxds-color-content-warning-default-rest, #f7630c); }
.nxl-message-toast-actions .dxbl-btn.dxbl-btn-text-danger  { --dxbl-btn-text-color: var(--dxds-color-content-danger-default-rest, #c50f1f); }
.nxl-message-toast-actions .dxbl-btn.dxbl-btn-text-info    { --dxbl-btn-text-color: var(--dxds-color-content-info-default-rest, #5c2e91); }

/* Time left, draining along the bottom edge; it stops while the pointer rests on the toast or
   the keyboard focus is in it, as NxlMessageToast's timer does. */
.nxl-message-toast-countdown {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background-color: var(--nxl-message-accent);
    opacity: 0.35;
    transform-origin: left center;
    animation-name: nxl-message-toast-countdown;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.nxl-message-toast-body:hover .nxl-message-toast-countdown,
.nxl-message-toast-body:focus-within .nxl-message-toast-countdown {
    animation-play-state: paused;
}

@keyframes nxl-message-toast-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .nxl-message-toast-countdown {
        display: none;
    }
}

/* A phone: toasts span the screen less a small margin, and those at the bottom sit above the
   shell's mobile bar (gone while the on-screen keyboard is up). 3.5rem is the bar's
   --nxl-shell-mobilebar-height, which is set on the shell and so out of the portal's reach. */
@media (max-width: 767.98px) {
    /* !important: DevExpress writes the provider's Width on the portal as an inline style. */
    .dxbl-toast-portal:has(.nxl-message-toast) {
        left: 0;
        right: 0;
        width: auto !important;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .dxbl-toast-portal .dxbl-toast.nxl-message-toast {
        --dxbl-toast-margin-x: 0;
        width: auto;
        max-width: none;
    }
}

body:has(.nxl-shell:not([data-nxl-keyboard]) .nxl-shell__mobilebar) .dxbl-toast-portal.dxbl-toast-align-bottom:has(.nxl-message-toast) {
    bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}

/* A focused grid row is filled with the accent colour and takes light text: a link in a cell, in
   the accent colour too, and a subtle or outline badge, tinted on a transparent ground, would vanish
   into it. The link takes the row's text; the badge sits on the plain surface colour. */
.dxbl-grid-focused-row a {
    color: inherit;
}

.dxbl-grid-focused-row .nxl-badge--subtle,
.dxbl-grid-focused-row .nxl-badge--outline {
    --nxl-badge-v-bg: var(--dxds-color-surface-neutral-default-rest);
}
