/* =====================================================
   INRADR Design System — Filter (Ch. 19)
   Ported from .docs/context/design/design-system-inradr.html
   inradr-design layer · global filter drawer (InradrGlobalFilterDrawer / InradrMultiSelect /
   InradrSingleSelect)

   The fields are DevExpress editors (DxDropDownBox / DxComboBox) and the toggle and reset are
   DxButtons; their DevExpress parts are mapped in inradr-feature/inradr-feature-dashboard-controls.css.
   The spec's native-input field, overlay, table-header filter and quick-filter parts have no
   consumer in B and stay in the spec HTML (OQ-35).
   ===================================================== */

/* --- Filter toolbar layout --- */
.inradr-filter-top-row {
    display: flex;
    align-items: center;
    gap: var(--inradr-space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--inradr-space-sm);
}

/* DELIBERATE DEVIATION FROM THE PROTOTYPE:
   The spec places the global-filter trigger top-left (design-system-inradr.md, "Placement:
   top-left"; .filter-top-row carries no justify-content). The dashboards put it right, which
   margin-left:auto does at the end of the flex row. */
.inradr-filter-right-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--inradr-space-xs);
    flex-wrap: wrap;
    margin-left: auto;
}

/* --- Global filter (expandable panel) --- */
/* The top padding is the room for the badge's 6px overhang: the drawer usually opens the content body,
   the shell's single scroll surface (overflow: auto), which would otherwise cut off the top of the badge
   (measured 2026-09-30, WP-26). */
.inradr-global-filter {
    position: relative;
    display: block;
    width: 100%;
    padding-top: 6px;

    /* toggle button (a DxButton carrying .inradr-btn); anchors the count badge */
    .inradr-global-filter__toggle {
        position: relative;
    }

    /* active-filter count badge */
    .inradr-global-filter__counter {
        position: absolute;
        top: -6px;
        right: -6px;
        min-width: 18px;
        height: 18px;
        border-radius: var(--inradr-radius-full);
        background: var(--inradr-color-status-warn);
        border: none;
        color: var(--inradr-color-text-on-navy);
        font-size: var(--inradr-text-badge-size);
        font-weight: var(--inradr-text-body-bold-weight);
        line-height: 18px; /* = badge height, centres the digit */
        text-align: center;
        padding: 0 5px;
        pointer-events: none; /* clicks on the badge reach the toggle below */
        display: none;

        &.inradr-global-filter__counter--visible {
            display: inline-block;
        }
    }

    /* The badge deliberately protrudes 6px beyond the trigger (top/right -6px). Every ancestor in
       its own chain must therefore stay non-clipping, or the count is cut off. No DevExpress wrapper
       further up clips it (measured 2026-09-30); the scroll surface is handled by the padding above. */
    &,
    .inradr-filter-top-row,
    .inradr-filter-right-actions,
    .inradr-global-filter__toggle {
        /* !important: the protruding badge must survive any later overflow rule on these
           wrappers; no competitor in B today (WP-26, 2026-09-30). */
        overflow: visible !important;
    }

    /* expandable panel */
    .inradr-global-filter__panel {
        display: none;
        margin-top: var(--inradr-space-sm);
        position: relative;
        border: 1px solid var(--inradr-color-border);
        border-radius: var(--inradr-radius-sm);
        background: var(--inradr-color-surface);
        padding: var(--inradr-space-sm);
        gap: var(--inradr-space-xs) var(--inradr-space-sm);
        align-items: end;
        box-shadow: var(--inradr-elevation-2-shadow);
        z-index: var(--inradr-layer-filter-panel);

        &.inradr-global-filter__panel--open {
            display: grid;
            grid-template-columns: minmax(0, 1fr);
        }
    }

    /* filter grouping level */
    .inradr-global-filter__level {
        padding: var(--inradr-space-xs) 0;
        background: transparent;
        display: grid;
        gap: var(--inradr-space-sm);

        & + .inradr-global-filter__level {
            border-top: 1px solid var(--inradr-color-border);
            padding-top: var(--inradr-space-sm);
            margin-top: var(--inradr-space-xs);
        }
    }

    /* Ubuntu ships 400/500/700 only, so the former 600 already rendered as 700. */
    .inradr-global-filter__level-title {
        font-size: var(--inradr-text-caption-size);
        font-weight: var(--inradr-text-body-bold-weight);
        line-height: var(--inradr-text-caption-line-height);
        color: var(--inradr-color-text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* Column counts only through the --inradr-global-filter-columns* tokens (spec): 4 / 3 / 2 / 1. */
    .inradr-global-filter__fields {
        display: grid;
        grid-template-columns: repeat(var(--inradr-global-filter-columns), minmax(0, 1fr));
        gap: var(--inradr-space-xs) var(--inradr-space-sm);
        align-items: end;
    }

    /* individual filter field: label ABOVE the control */
    .inradr-global-filter__field {
        position: relative;
        min-width: 160px;

        > label {
            display: block;
            margin-bottom: 6px;
            font-size: var(--inradr-text-caption-size);
            font-weight: var(--inradr-text-body-strong-weight);
            line-height: var(--inradr-text-caption-line-height);
            color: var(--inradr-color-text-secondary);
        }

        /* Control wrapper: stretches the DevExpress editor to the column width
           (formerly .field-wrap in the deleted inradr-form.css). */
        .inradr-field-wrap {
            display: block;
            width: 100%;
        }
    }

    .inradr-global-filter__footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        grid-column: 1 / -1;
        gap: var(--inradr-space-sm);
        padding-top: var(--inradr-space-xs);
    }

    .inradr-global-filter__impact {
        font-size: var(--inradr-text-caption-size);
        line-height: var(--inradr-text-caption-line-height);
        color: var(--inradr-color-text-secondary);

        strong {
            color: var(--inradr-color-text-heading);
            font-weight: var(--inradr-text-body-strong-weight);
        }
    }

    .inradr-global-filter__reset {
        display: inline-flex;
        justify-content: flex-end;
        align-items: center;
    }
}

/* --- Filter overlay of a multi-select field (spec filter-overlay; InradrMultiSelect) ---
   The drop-down panel: search, "Alles auswählen" and the options (DevExpress list box), then the actions.
   A selection takes effect with "Anwenden" only. The panel lives in a body-level portal, outside
   .inradr-global-filter, so these rules stand on their own. */
.inradr-filter-overlay {
    display: flex;
    flex-direction: column;
}

.inradr-filter-overlay__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--inradr-gap-btn-action);
    padding: var(--inradr-space-xs);
    border-top: 1px solid var(--inradr-color-border);
}

/* Why "Anwenden" is disabled: nothing is ticked. */
.inradr-filter-overlay__hint {
    margin-right: auto;
    font-size: var(--inradr-text-caption-size);
    line-height: var(--inradr-text-caption-line-height);
    color: var(--inradr-color-text-muted);
}

/* --- Responsive --- */
@media (max-width: 1279px) {
    .inradr-global-filter .inradr-global-filter__fields {
        grid-template-columns: repeat(var(--inradr-global-filter-columns-lg), minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .inradr-global-filter .inradr-global-filter__fields {
        grid-template-columns: repeat(var(--inradr-global-filter-columns-md), minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .inradr-global-filter {
        .inradr-global-filter__fields {
            grid-template-columns: repeat(var(--inradr-global-filter-columns-sm), minmax(0, 1fr));
        }

        .inradr-global-filter__footer {
            flex-direction: column;
            align-items: flex-start;
        }

        .inradr-global-filter__reset {
            width: 100%;

            .inradr-btn {
                margin-left: auto;
            }
        }
    }
}
