:host {
    --ak-c-table--expandable-overlay--Color: color-mix(
        var(--pf-global--palette--purple-100),
        transparent 80%
    );
}

:host([theme="dark"]) {
    --ak-c-table--expandable-overlay--Color: color-mix(
        var(--pf-global--palette--blue-700),
        transparent 90%
    );

    --ak-c-table--expandable-overlay--Color: color-mix(
        var(--pf-global--palette--blue-100),
        transparent 90%
    );
}

.pf-c-table {
    --pf-global--primary-color--100: var(--pf-global--primary-color--300);
    --pf-c-table--m-compact__expandable-row-content--PaddingTop: var(--pf-global--spacer--sm);
    --pf-c-table--m-compact__expandable-row-content--PaddingBottom: var(--pf-global--spacer--sm);

    .presentational {
        --pf-c-table--cell--MinWidth: 0;
    }
}

::part(search-form) {
    --pf-c-input-group--BackgroundColor: transparent;
}

::part(search-input) {
    background-color: transparent !important;
}

.pf-c-table__expandable-row {
    background: color-mix(
        var(--pf-c-table--BackgroundColor),
        var(--ak-c-table--expandable-overlay--Color)
    );

    ::part(table) {
        --pf-c-table--BackgroundColor: transparent;
        --pf-c-table--tr--m-hoverable--hover--BackgroundColor: color-mix(
            var(--pf-c-table--BackgroundColor),
            var(--ak-c-table--expandable-overlay--Color)
        );
    }

    ::part(toolbar) {
        --pf-c-toolbar--BackgroundColor: transparent;
    }

    ::part(pagination-bottom) {
        --pf-c-pagination--m-bottom--BackgroundColor: transparent;
    }
}

.ak-c-table__actions {
    display: flex;
    justify-content: start;

    ::part(spinner-button) {
        padding-inline: var(--pf-global--spacer--md);
    }

    .pf-c-button:not(:has(i)):not(:first-child) {
        margin-inline-start: var(--pf-global--spacer--sm);
    }
}

td.pf-c-table__toggle:first-child > .pf-c-button {
    --pf-c-button--PaddingLeft: 0;
}

td ak-mdx::part(content) {
    --pf-c-content--FontSize: 1em;
}

/**
 * TODO: Row actions need a better approach to alignment,
 * but this will at least get the buttons in a grid-like layout.
 */
td:has(ak-action-button),
td:has(ak-forms-modal),
td:has(ak-rbac-object-permission-modal) {
    button[slot="trigger"]:has(i) {
        padding-inline: 0.5em !important;
    }

    button.pf-m-tertiary {
        margin-inline-start: 0.25em;
    }

    pf-tooltip {
        color: inherit;
    }

    & > * {
        display: inline-flex;
        place-items: center;
        justify-content: center;
    }
}

.pf-m-search-filter {
    flex: 1 1 auto;
    margin-inline: 0;
}

.pf-c-table thead .pf-c-table__check {
    min-width: 3rem;
}

.pf-c-table tbody .pf-c-table__check input {
    margin-top: calc(var(--pf-c-table__check--input--MarginTop) + 1px);
}

.selected-chips::part(chip-group) {
    margin-block-end: var(--pf-global--spacer--sm);
}

.pf-c-toolbar {
    display: flex;
    flex-flow: row wrap;
    padding-inline: var(--pf-global--spacer--md);
    gap: var(--pf-global--spacer--sm);
}

.pf-c-toolbar__content {
    flex: 1 1 auto;
    flex-flow: row wrap;
    margin: 0;
    justify-content: space-between;
    gap: var(--pf-global--spacer--sm);
    padding-inline: 0;
    .pf-c-switch {
        --pf-c-switch--ColumnGap: var(--pf-c-toolbar__item--m-search-filter--spacer);
    }
}

.pf-c-toolbar__group {
    flex-flow: row wrap;
    gap: var(--pf-global--spacer--sm);

    .pf-c-card__title .pf-icon {
        margin-inline-end: var(--pf-global--spacer--sm);
    }
}

[part="toolbar-primary"] {
    flex: 2 1 auto;
}

.pf-c-table {
    --pf-c-table--m-striped__tr--BackgroundColor: var(--pf-global--BackgroundColor--dark-300);
}

/**
 * Prevents text selection from interfering with click events
 * when rapidly interacting with cells.
 */
thead,
.pf-c-table tr.pf-m-hoverable {
    user-select: none;
}

time {
    text-transform: capitalize;
}

.pf-c-pagination {
    ak-timestamp {
        font-size: 0.75rem;
        font-style: italic;
        color: var(--pf-global--Color--200);

        &::part(label) {
            display: inline-block;
        }

        &::part(elapsed) {
            display: inline-block;
        }
    }
}

:host {
    display: block;
    container-type: inline-size;
}

:host([display-box="contents"]) {
    display: contents;
}

.pf-c-table {
    @container (width > 1200px) {
        --pf-c-table--cell--MinWidth: 9em;
    }
}
