@import "../variables/variables";
@import "../mixins/private/filter-menu-mixins";
@import "../mixins/private/token-mixins";

.filter-menu,
.filter-menu-form {
    @include background-color-token(
        filter-menu-item-background-color,
        color-background-primary
    );

    min-width: 144px;
}

span.filter-menu,
span.filter-menu-form {
    display: inline-block;
}

.filter-menu__items,
.filter-menu-form__items {
    margin-top: 8px;
    min-width: 100%;
    position: relative;
}

span.filter-menu__items[role="menu"],
span.filter-menu-form__items {
    display: inline-block;
}

span.filter-menu__checkbox,
span.filter-menu__radio {
    display: block;
    flex-shrink: 1;
    height: 18px;
    min-width: 18px;
    width: 18px;

    svg {
        @include color-token(
            filter-menu-item-icon-color,
            color-foreground-primary
        );

        height: 18px;
        width: 18px;
    }
}

.filter-menu-form__item span.checkbox,
.filter-menu-form__item span.radio {
    align-items: flex-start;
    display: flex;
    flex-shrink: 1;
    justify-content: center;

    .checkbox__icon > svg {
        @include color-token(
            filter-menu-item-checked-color,
            color-foreground-primary
        );
    }
}

span.filter-menu__item[role^="menuitem"],
span.filter-menu-form__item {
    display: block;
}

.filter-menu__item[role^="menuitem"],
.filter-menu-form__item {
    padding: 8px 16px;

    @include filter-menu-item-base();
    &:last-child {
        margin-bottom: 8px;
    }
}

.filter-menu__header {
    align-items: center;
    background-color: var(--color-background-secondary);
    display: flex;
    gap: var(--spacing-100);
    padding: 14px var(--spacing-200);
}

.filter-menu__header svg {
    color: var(--color-foreground-secondary);
}

.filter-menu__header input {
    background-color: inherit;
    border: none;
    color: var(--color-foreground-primary);
    flex-grow: 1;
    font-size: var(--font-size-default);
}

.filter-menu__header button.btn {
    border: none;
    min-height: var(--spacing-250);
    min-width: var(--spacing-250);
    padding: 0;
    width: var(--spacing-250);
}

.filter-menu__header button:focus-visible {
    outline-style: solid;
}

button.filter-menu__footer,
button.filter-menu-form__footer[type="submit"] {
    border: none;
    border-top-style: solid;
    border-top-width: 1px;
    bottom: 0;
    padding: 16px;
    @include border-color-token(filter-menu-border-color, color-stroke-subtle);
    @include filter-menu-item-base();

    &:hover {
        background-color: var(--color-state-primary-hover);
    }
}

.filter-menu__text,
.filter-menu-form__text {
    flex-grow: 1;
    margin-inline-start: 8px;
}

.filter-menu__item[role="menuitemradio"] svg.icon--checked,
.filter-menu__item[role="menuitemcheckbox"] svg.icon--checked {
    display: none;
}

.filter-menu__item[role="menuitemradio"] svg.icon--unchecked,
.filter-menu__item[role="menuitemcheckbox"] svg.icon--unchecked {
    display: block;
}

.filter-menu__item[role="menuitemcheckbox"][aria-checked="true"]
    svg.icon--unchecked,
.filter-menu__item[role="menuitemradio"][aria-checked="true"]
    svg.icon--unchecked {
    display: none;
}
.filter-menu__item[role="menuitemcheckbox"][aria-checked="true"]
    svg.icon--checked,
.filter-menu__item[role="menuitemradio"][aria-checked="true"]
    svg.icon--checked {
    display: block;
}

/* https://developer.paciellogroup.com/blog/2018/03/focus-visible-and-backwards-compatibility/ */
div.filter-menu__item[role^="menuitem"]:focus:not(:focus-visible) {
    outline: none;
}
