/* =====================================================
   INRADR Design System — Buttons (Ch. 03)
   Ported from .docs/context/design/design-system-inradr.html
   inradr-design layer · own inradr-btn component only

   Only the variants B renders are shipped (OQ-35): primary, secondary, icon, text and danger on
   DxButton CssClass, plus disabled, and the segmented button group. The other catalogue variants (tertiary, link, dropdown,
   icon-dropdown, icon-left) and the [data-tooltip] helper live on in the spec HTML; re-add one here
   together with its first consumer.
   The DxButton paint (DX :active beats these rules) is mapped in
   inradr-feature/inradr-feature-button.css. Both read the --inradr-color-button-* tokens, whose
   Dark values (inradr-color.css) give the spec's dark-mode buttons.
   ===================================================== */

/* --- Button base + variants ------------------------------ */
.inradr-btn {
    box-sizing: border-box;
    height: var(--inradr-height-control);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: var(--inradr-font-body);
    font-size: var(--inradr-text-body-size);
    font-weight: var(--inradr-text-body-strong-weight);
    border-radius: var(--inradr-radius-sm);
    padding: var(--inradr-space-xs) var(--inradr-btn-padding-x);

    /* --- Variant: primary ---
       Re-added with its first consumer: the "new" buttons of the tenant overview's appointment and note cards
       (OverviewCardListRenderer), filled like inradr-app's btn--primary. Accent, text on navy. */
    &.inradr-btn--primary {
        background: var(--inradr-color-button-primary-bg);
        color: var(--inradr-color-button-primary-text);
        border-color: var(--inradr-color-button-primary-bg);

        &:hover {
            background: var(--inradr-color-button-primary-hover-bg);
            border-color: var(--inradr-color-button-primary-hover-bg);
        }

        &:active {
            background: var(--inradr-color-button-primary-active-bg);
            border-color: var(--inradr-color-button-primary-active-bg);
        }

        &:focus-visible {
            outline: var(--inradr-focus-ring-width) solid var(--inradr-color-button-focus);
            outline-offset: var(--inradr-focus-ring-offset);
        }
    }

    /* --- Variant: secondary --- */
    &.inradr-btn--secondary {
        background: var(--inradr-color-button-secondary-bg);
        color: var(--inradr-color-button-secondary-text);
        border-color: var(--inradr-color-button-secondary-text);

        &:hover {
            background: var(--inradr-color-button-secondary-hover-bg);
            color: var(--inradr-color-button-secondary-hover-text);
        }

        &:active {
            background: var(--inradr-color-button-secondary-active-bg);
            color: var(--inradr-color-button-secondary-text);
        }

        &:focus-visible {
            outline: var(--inradr-focus-ring-width) solid var(--inradr-color-button-focus);
            outline-offset: var(--inradr-focus-ring-offset);
        }
    }

    /* --- Variant: text --- */
    &.inradr-btn--text {
        /* Note: HTML-source variant, beyond the markdown button catalog */
        background: transparent;
        color: var(--inradr-color-button-text-color);

        &:hover {
            background: var(--inradr-color-button-text-hover-bg);
        }

        &:active {
            color: var(--inradr-color-accent-dark);
        }

        &:focus-visible {
            outline: var(--inradr-focus-ring-width) solid var(--inradr-color-button-focus);
            outline-offset: var(--inradr-focus-ring-offset);
        }
    }

    /* --- Variant: disabled ---
       Kept without a consumer: it is the DS disabled contract every variant falls back to. */
    &.inradr-btn--disabled {
        background: var(--inradr-color-button-disabled-bg);
        color: var(--inradr-color-button-disabled-text);
        cursor: not-allowed;

        &,
        &:hover,
        &:active {
            pointer-events: none;
        }
    }

    /* --- Variant: danger ---
       Re-added with its first consumer: the delete button of the tenant overview's appointment and note cards
       (OverviewCardListRenderer). Filled as the spec's btn--danger and inradr-app: danger, text on navy. */
    &.inradr-btn--danger {
        background: var(--inradr-color-button-danger-bg);
        color: var(--inradr-color-button-danger-text);
        border: var(--inradr-button-danger-border-width) solid var(--inradr-color-button-danger-border);

        &:hover {
            background: var(--inradr-color-button-danger-hover-bg);
            border-color: var(--inradr-color-button-danger-hover-border);
        }

        &:active {
            background: var(--inradr-color-button-danger-active-bg);
            border-color: var(--inradr-color-button-danger-active-border);
        }

        &:focus-visible {
            outline: var(--inradr-focus-ring-width) solid var(--inradr-color-button-danger-focus);
            outline-offset: var(--inradr-focus-ring-offset);
        }
    }

    /* --- Variant: icon-only (square control, aria-label required) --- */
    &.inradr-btn--icon {
        width: var(--inradr-height-control);
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;

        &:focus-visible {
            outline: var(--inradr-focus-ring-width) solid var(--inradr-focus-ring-color);
            outline-offset: var(--inradr-focus-ring-offset);
        }
    }
}

/* --- Segmented button group (spec button-segmented-group) -----------
   One choice out of a few: a joined row of equal-width native buttons (type="button") in a role="group" with an
   accessible name; the pressed option in the accent (aria-pressed="true"). One border around the group and between
   the options; the group rounds and clips the outer corners only. The focus ring sits inside the option, so the group
   does not clip it. Labels may wrap, they are never cut. An option that is not available stays focusable and says
   why (aria-disabled="true"); it looks like a natively disabled one, in the DS disabled colours.
   Consumers: the options of the chart filter (ChartLocalFilterPopover, stacked) and the appearance of the account
   panel (InradrAccountComponent, a row). */
.inradr-segmented-button-group {
    display: flex;
    align-items: stretch;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    border: 1px solid var(--inradr-color-border);
    border-radius: var(--inradr-radius-sm);
}

/* Stacked variant (DSX-18, ClickUp 124ca7ct3f2): the options one below the other, left-aligned and full width, with
   the separator on top instead of on the left. The specification knows only the row; long German metric names do not
   fit a row in the 320px chart filter and must not be cut. Proposed to design as FB-14. */
.inradr-segmented-button-group--vertical {
    flex-direction: column;

    & > .inradr-segmented-button {
        flex: 0 0 auto;
        justify-content: flex-start;
        text-align: start;
    }

    & > .inradr-segmented-button + .inradr-segmented-button {
        border-left: 0;
        border-top: 1px solid var(--inradr-color-border);
    }
}

.inradr-segmented-button {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: var(--inradr-height-control);
    padding: 0 var(--inradr-space-xs);
    border: 0;
    background: var(--inradr-color-surface);
    color: var(--inradr-color-text-primary);
    font-family: var(--inradr-font-body);
    font-size: var(--inradr-text-body-size);
    font-weight: var(--inradr-text-body-strong-weight);
    line-height: var(--inradr-text-body-line-height);
    text-align: center;
    cursor: pointer;

    & + & {
        border-left: 1px solid var(--inradr-color-border);
    }

    &:hover:not([aria-pressed="true"], [aria-disabled="true"], :disabled) {
        background: var(--inradr-color-surface-muted);
    }

    &:active:not([aria-pressed="true"], [aria-disabled="true"], :disabled) {
        background: var(--inradr-color-accent-tint-16);
    }

    &[aria-pressed="true"] {
        background: var(--inradr-color-accent);
        color: var(--inradr-color-text-on-navy);
        cursor: default;

        /* Dark appearance (spec): Deep Sea text on the accent fill. */
        :root[data-theme="dark"] & {
            color: var(--inradr-color-surface-muted);
        }
    }

    &:is([aria-disabled="true"], :disabled) {
        background: var(--inradr-color-surface-muted);
        color: var(--inradr-color-text-muted);
        cursor: not-allowed;
    }

    &:focus-visible {
        outline: var(--inradr-focus-ring-width) solid var(--inradr-color-accent-dark);
        outline-offset: calc(-1 * var(--inradr-focus-ring-width));
    }

    /* decorative 16px icon before the label */
    & > [aria-hidden="true"] {
        flex: 0 0 auto;
        font-size: 16px;
        line-height: 1;
    }
}
