.dropdown {
    position: relative;
    display: inline-block;

    &.open > .dropdown-toggle,
    .dropdown-toggle.open {
        &.mod-primary .dropdown-toggle-arrow {
            @include arrow-up-icon(var(--white));
        }

        .dropdown-toggle-arrow {
            @include arrow-up-icon(var(--deprecated-medium-blue));
        }
    }

    &.open > .dropdown-menu {
        display: block;
        margin-bottom: $form-bottom-padding;
    }

    .btn {
        border-color: var(--default-border-color);

        &:focus {
            border: 1px solid var(--digital-blue-60);
        }
    }
}

.dropdown-prepend {
    padding-right: 5px;
    color: var(--default-text-color);
}

.dropdown-option-append {
    display: inline-block;
    width: $dropdown-option-append-width;
}

.dropdown-selected-value {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-transform: none;
    text-overflow: ellipsis;

    &.with-append {
        width: calc(100% - #{$dropdown-toggle-with-append-right-padding});
    }

    .disabled {
        color: var(--deprecated-medium-grey);
    }
}

.dropdown-toggle {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    overflow: hidden;
    font-size: $dropdown-button-font-size;
    line-height: 16px;
    white-space: nowrap;
    text-transform: none;
    text-overflow: ellipsis;

    &:disabled .dropdown-toggle-arrow {
        @include arrow-down-icon(var(--deprecated-medium-grey));
    }

    &.mod-search {
        text-align: left;
    }

    &.dropdown-toggle-placeholder {
        color: var(--default-text-color);
    }

    &.mod-primary {
        font-size: $button-font-size;
        text-transform: none;

        .dropdown-toggle-arrow {
            @include arrow-down-icon(var(--white));
        }
    }

    .dropdown-option-append {
        float: right;
        width: $dropdown-toggle-append-width;
        color: var(--title-text-color);
        text-align: right;
    }

    .dropdown-toggle-arrow,
    .dropdown-toggle-arrow-style {
        position: absolute;
        top: calc(50% - (#{$dropdown-arrow-icon-size} / 2)); // Remove the approximated svg inner top/bottom padding
        right: $button-padding-x;
        width: $dropdown-arrow-icon-size;
        height: $dropdown-arrow-icon-size;

        &.icon {
            pointer-events: none;
            fill: var(--grey-80);
        }
    }

    .dropdown-toggle-arrow-size {
        width: $dropdown-arrow-icon-size;
        height: $dropdown-arrow-icon-size;
    }

    .dropdown-toggle-arrow {
        @include arrow-down-icon(var(--deprecated-medium-blue));
    }
}

.dropdown-toggle .value-icon,
.dropdown-menu li .value-icon {
    display: inline-flex;
    margin-right: 3px;

    &,
    & svg {
        width: 0.8em;
        height: 0.8em;
    }
}

%dropdown-option-line-style {
    display: inline-block;
    padding: $dropdown-option-padding;
    overflow: hidden;
    color: var(--title-text-color);
    font-size: $dropdown-choice-font-size;
    line-height: $default-line-height;
    white-space: nowrap;
    text-overflow: ellipsis;
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    display: none;
    float: left;
    box-sizing: border-box;
    min-width: 100%;
    max-height: $dropdown-menu-max-height;
    margin: 0;
    padding: $dropdown-choices-top-bottom-margin 0;
    overflow-y: auto;
    color: var(--title-text-color);
    list-style: none;
    background-color: var(--white);
    border: $default-border;
    border-radius: 0 0 2px 2px;
    box-shadow: 0 2px 4px rgb(0 0 0 / 41%);

    @include slim-scroll(var(--white), var(--grey-20));

    &.mod-right {
        right: 0;
        left: auto;
    }

    li,
    .option-wrapper {
        &:hover,
        &:focus {
            color: var(--grey-80);
            background: var(--grey-20);
        }

        &.disabled {
            > a,
            > span,
            .dropdown-option-append {
                color: var(--deprecated-medium-grey);
                background-color: var(--grey-60);
                cursor: default;
            }
        }

        > a,
        > span {
            width: 100%;

            @extend %dropdown-option-line-style;

            &.selected-value {
                color: var(--grey-40);
                font-weight: var(--main-font-bold);
                background-color: var(--navy-blue-80);
            }

            &.disabled {
                color: var(--deprecated-medium-grey);
                cursor: default;
            }

            &.no-search-results {
                white-space: normal;
                word-break: break-word;
            }
        }

        &.active {
            color: var(--grey-40);

            > a,
            > span {
                &.enabled:not(.selected-value) {
                    background: var(--grey-20);
                }
            }
        }

        &.divider {
            height: 1px;
            margin: 8px 0;
            background-color: var(--grey-60);
            cursor: default;
        }

        .dropdown-option.with-append {
            width: calc(100% - #{$dropdown-option-append-width});
        }

        .dropdown-option-append {
            width: $dropdown-option-append-width;

            @extend %dropdown-option-line-style;
        }
    }
}

// Dropdown Search

.dropdown.mod-search {
    .dropdown-button-search-container,
    .filter-container {
        width: inherit;
        min-width: $dropdown-button-min-width;

        input.filter-box {
            width: inherit;
            min-width: $dropdown-button-min-width;
        }
    }

    .dropdown-menu {
        width: $dropdown-button-min-width;
    }
}

.select-dropdown-container {
    z-index: $table-header-z-index;
    background-color: var(--white);
    border-radius: 8px;

    > .select-dropdown-filter {
        background-color: var(--grey-20);
        border: 1px solid var(--grey-40);
        border-bottom: none;
        border-radius: 8px 8px 0 0;

        ~ .list-box {
            padding: 0 0 8px;
            border-radius: 0 0 8px 8px;
        }
    }
}
