/* =====================================================
   INRADR Design System — Data Visualization (Ch. 18)
   Chart-local filter popover, chart action cluster, table toolbar, card legend
   and chart tooltips. The period choice in the popover is the segmented button
   group of inradr-button.css.
   inradr-design layer · consumes button/badge/filter/spacing/radius/elevation tokens

   Class names follow the inradr-* BEM policy since WP-25 (map: .docs/archive/2026-10-documentation-cleanup/features/
   design-migration/wp-25-class-rename-map.md). The DevExpress parts (DxTextBox inside the search pill,
   DxChart tooltip frame) are mapped in inradr-feature.
   ===================================================== */

/* --- Chart-local filter popover ------------------------------------- */
.inradr-chart-filter {
    position: relative;
    display: inline-flex;

    /* Popover open: fill the trigger in the accent. The layers icon has no "-plus" variant, so the
       state needs a visual (ChartLocalFilterPopover.razor). Same treatment as a pressed .inradr-segmented-button.
       The :hover rule repeats the colour because the DxButton hover rule sets its own. */
    &.inradr-chart-filter--open .inradr-chart-actions__button {
        background: var(--inradr-color-accent);
        border-color: var(--inradr-color-accent);
        color: var(--inradr-color-text-on-navy);

        &:hover {
            background: var(--inradr-color-accent-hover);
            color: var(--inradr-color-text-on-navy);
        }
    }

    /* count badge on the funnel trigger — same warning style as .inradr-global-filter__counter */
    .inradr-chart-filter__counter {
        position: absolute;
        top: -6px;
        right: -6px;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: var(--inradr-radius-full);
        background: var(--inradr-color-status-warn);
        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;
        pointer-events: none;
        display: none;
        align-items: center;
        justify-content: center;

        &.inradr-chart-filter__counter--visible {
            display: inline-flex;
        }
    }
}

/* Anchored popover (elevation 3). The width keeps a 12px margin to both viewport edges. */
.inradr-chart-filter__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: var(--inradr-layer-popover);
    display: grid;
    gap: 10px;
    width: min(320px, calc(100vw - 2 * var(--inradr-space-2xs)));
    padding: var(--inradr-space-2xs);
    border: 1px solid var(--inradr-color-border);
    border-radius: var(--inradr-radius-sm);
    background: var(--inradr-color-surface);
    box-shadow: var(--inradr-elevation-3-shadow);
}

/* Section label of the popover (spec chart-filter-display-option: uppercase, bold, secondary text). 13px instead of
   the spec's 12px: the type scale's floor (exception DSX-02 of the design-system record). */
.inradr-chart-filter__title {
    font-size: var(--inradr-text-caption-size);
    font-weight: var(--inradr-text-list-header-weight);
    line-height: var(--inradr-text-caption-line-height);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--inradr-color-text-secondary);
}

/* A section of the panel: the periods, and below them the optional "Darstellung" section (check boxes). */
.inradr-chart-filter__section {
    display: grid;
    gap: 10px;

    &.inradr-chart-filter__section--divided {
        padding-top: 10px;
        border-top: 1px solid var(--inradr-color-border);
    }
}

.inradr-chart-filter__checkbox {
    font-size: var(--inradr-text-body-size);
    color: var(--inradr-color-text-primary);
}

.inradr-chart-filter__reset {
    justify-self: center;
}

/* --- Download menu of a card with several exports (2026-11-11) -------- */
/* InradrCardActions with ExtraDownloads: the download button opens a list of exports, anchored like the chart filter
   panel. The open trigger is filled in the accent, like an open chart filter. */
.inradr-download-menu {
    position: relative;
    display: inline-flex;

    &.inradr-download-menu--open .inradr-chart-actions__button {
        background: var(--inradr-color-accent);
        border-color: var(--inradr-color-accent);
        color: var(--inradr-color-text-on-navy);

        &:hover {
            background: var(--inradr-color-accent-hover);
            color: var(--inradr-color-text-on-navy);
        }
    }
}

.inradr-download-menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: var(--inradr-layer-popover);
    display: grid;
    min-width: 240px;
    max-width: calc(100vw - 2 * var(--inradr-space-2xs));
    padding: var(--inradr-space-xxs) 0;
    border: 1px solid var(--inradr-color-border);
    border-radius: var(--inradr-radius-sm);
    background: var(--inradr-color-surface);
    box-shadow: var(--inradr-elevation-3-shadow);
}

.inradr-download-menu__item {
    padding: var(--inradr-space-xs) var(--inradr-space-2xs);
    border: 0;
    background: transparent;
    color: var(--inradr-color-text-primary);
    font: inherit;
    font-size: var(--inradr-text-body-size);
    line-height: var(--inradr-text-body-line-height);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;

    &:hover:not(:disabled),
    &:focus-visible {
        background: var(--inradr-color-surface-muted);
        outline: none;
    }

    &:disabled {
        color: var(--inradr-color-text-secondary);
        cursor: default;
    }
}

/* --- Chart header action cluster ------------------------------------ */
.inradr-chart-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--inradr-space-xs);
    flex-wrap: nowrap;
}

.inradr-chart-card__meta {
    display: inline-flex;
    align-items: center;
    gap: var(--inradr-space-xs);
    min-height: var(--inradr-height-control);
}

/* .inradr-chart-actions__button composes .inradr-btn.inradr-btn--secondary.inradr-btn--icon (36×36 accent square);
   this hook exists so the markup reads like the prototype and for the open-state fill above. */
.inradr-chart-actions__button {
    flex: 0 0 auto;
}

/* BottomLine: muted footnote under each chart + the grid (period/chart-type dependent for charts).
   Caption type: the former 11px sat below the 13px floor. */
.inradr-chart-card__footnote {
    margin-top: 10px;
    font-size: var(--inradr-text-caption-size);
    line-height: var(--inradr-text-caption-line-height);
    color: var(--inradr-color-text-muted);
}

/* --- Table toolbar -------------------------------------------------- */
.inradr-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--inradr-space-xs);
    flex-wrap: nowrap;
    margin-left: auto;
}

.inradr-table-toolbar__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--inradr-space-xs);
    flex-wrap: nowrap;
}

.inradr-table-toolbar__badges {
    display: inline-flex;
    align-items: center;
    gap: var(--inradr-space-xs);
}

/* Search pill: the DxTextBox inside is made borderless in inradr-feature-dashboard-controls.css. */
.inradr-table-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--inradr-height-control);
    padding: 0 10px;
    border: 1px solid var(--inradr-color-border);
    border-radius: var(--inradr-radius-sm);
    background: var(--inradr-color-surface);

    > i {
        color: var(--inradr-color-accent-dark);
        flex: 0 0 auto;
    }

    &:focus-within {
        border-color: var(--inradr-color-accent);
    }
}

.inradr-table-search__input {
    width: 220px;
}

/* --- True fullscreen for chart / table cards ------------------------ */
.inradr-chart-card:fullscreen,
.inradr-table-card:fullscreen {
    padding: var(--inradr-space-lg);
    background: var(--inradr-color-surface);
    overflow: auto;
}

/* In fullscreen the donut grows with the card: the viewport bounds it, not the dashboard cap
   (124ca7cqpjk). The subtrahend covers the fullscreen padding and the card's header row, so the
   square plot never pushes the legend into the overflow scroll. */
.inradr-chart-card--split:fullscreen > .inradr-chart-card__plot {
    max-height: calc(100vh - 220px);
}

@media (max-width: 767px) {
    .inradr-table-search__input {
        width: 140px;
    }
}

/* --------------------------------------------------------------------------
   Card legend (InradrChartLegend.razor)
   HTML rather than Plotly's native legend: on a waterfall trace Plotly shows only the
   trace name, not the roles the card needs to explain. Layout.ShowLegend stays false.

   The key is deliberately a rounded square, not a dot: it has to read like Plotly's own
   legend swatch, which a bar chart shows right next to it.
   Body size: the former clamp(13px, 0.8125rem + 0.25vw, 14px) resolved to 14px from 400px up.
   -------------------------------------------------------------------------- */
.inradr-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: var(--inradr-space-2xs);
    padding-top: 10px;
    border-top: 1px solid var(--inradr-color-border);
    font-size: var(--inradr-text-body-size);
    color: var(--inradr-color-text-secondary);
}

.inradr-chart-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.inradr-chart-legend__key {
    width: 10px;
    height: 10px;
    border-radius: var(--inradr-radius-xs);
    flex: none;
}

/* An outlined key for a mark that is an outline in the chart, such as the gap marker of the BVI bars. The frame
   colour is the inline border-color - data, like the fill of a plain key. */
.inradr-chart-legend__key--outline {
    box-sizing: border-box;
    border: 2px solid;
    background: transparent;
}

/* --- Donut legend (InradrDonutLegend) ---------------------------------------
   The compact list beside a donut (124ca7cqpjk): one column of colour key plus name, the name cut
   off with an ellipsis; the share stands outside the slice and in the row's title tooltip, so there
   is no value column. A key, not a button - the design system's click-to-highlight is left out
   (owner, 2026-10-06), so there is no hover or active state. Text at the 13px floor instead of the
   design system's 12px.
   -------------------------------------------------------------------------- */
.inradr-donut-legend {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--inradr-space-xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

.inradr-donut-legend__item {
    display: flex;
    align-items: center;
    gap: var(--inradr-space-xs);
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--inradr-radius-sm);
    background: var(--inradr-color-surface);
    color: var(--inradr-color-text-primary);
    font-family: var(--inradr-font-body);
    font-size: var(--inradr-text-caption-size);
    line-height: var(--inradr-text-caption-line-height);
}

/* The square of .inradr-chart-legend__key; the fill is the inline background - the slice's colour. */
.inradr-donut-legend__key {
    width: 10px;
    height: 10px;
    border-radius: var(--inradr-radius-xs);
    flex: none;
}

.inradr-donut-legend__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Colour key inside a chart tooltip. Same square as .inradr-chart-legend__key, but the tooltip is built as
   an HTML string and injected into .inradr-plot-tooltip, so it has no flex parent to sit in and
   needs inline-block plus its own spacing. The fill itself stays an inline style: it is the colour
   of the hovered mark, i.e. data, not styling. */
.inradr-plot-tooltip__key {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: var(--inradr-radius-xs);
    vertical-align: middle;
}
