@form_padding_top_bottom: 7px;
@form_padding_sides: 20px;

@form_font_size: 12;
@form_line_height: 26px;

@form_dots_top: 25px;
@form_dots_side: 16px;

@form_icons_width: 50px;
@form_padding_icon_offset: @form_icons_width;
@form_icons_top: 0;
@form_icons_side: 0;
@form_icons_color: rgba(0,0,0,0.4);

@chosen_border_radius: 5px;
@form_border_radius: 5px;

@form_border_color: var(--primary_color);
@form_highlight_color:  color-mix(in srgb, var(--primary_color), var(--darken_mixin_color) 8%);
@form_border_dark: #fff;
@form_border_width: 1.5px;
@form_font_weight: 600;

@field_min_height: 44px;

:root {
    --form_padding_top_bottom: @form_padding_top_bottom;
    --form_padding_sides: @form_padding_sides;

    --form_font_size: @form_font_size;
    --form_line_height: @form_line_height;

    --form_dots_top: @form_dots_top;
    --form_dots_side: @form_dots_side;

    --form_icons_width: @form_icons_width;
    --form_padding_icon_offset: @form_padding_icon_offset;
    --form_icons_top: @form_icons_top;
    --form_icons_side: @form_icons_side;
    --form_icons_color: @form_icons_color;

    --chosen_border_radius: @chosen_border_radius;
    --form_border_radius: @form_border_radius;

    --form_border_color: @form_border_color;
    --form_highlight_color:  @form_highlight_color;
    --form_border_dark: @form_border_dark;
    --form_border_width: @form_border_width;
    --form_font_weight: @form_font_weight;

    --field_min_height: @field_min_height;

}


.chosen-container {
    position: relative;
    min-width: 190px;
    display: inline-block;
    vertical-align: middle;
    zoom: 1;
    *display: inline;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    width: 100%;

    a {
        cursor: pointer;
    }

    .chosen-drop {
        position: absolute;
        top: 100%;
        left: -9999px;
        width: 100%;
        border-top: 0;
        background: #fff;
        z-index: 8999999;

        .darkBg & {
            background: transparent;
        }
    }

    .search-choice .group-name, .chosen-single .group-name {
        margin-right: 4px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: #fff;

        &::after {
            content: ":";
            padding-left: 2px;
            vertical-align: top;
        }
    }



    .chosen-single {
        position: relative;
        display: block;
        overflow: hidden;
        text-align: left;
        padding: ~"calc(var(--form_padding_top_bottom) + 1px) var(--form_padding_icon_offset) calc(var(--form_padding_top_bottom) - 1px) var(--form_padding_sides)";
        height: var(--field_min_height);
        text-decoration: none;
        white-space: nowrap;
        .rems(@form_font_size);
        line-height: var(--form_line_height);
        border-radius: var(--chosen_border_radius);

        border: var(--form_border_width) solid var(--form_border_color);
        background: #fff;
        font-family: var(--body_font);
        transition: border-color 200ms linear;
        color: var(--text_color);
        font-weight: var(--form_font_weight);

        .darkBg & {
            background: var(--dark_color);
            border-color: color-mix(in srgb, var(--fade_mixin_color), var(--form_border_dark) 40%);
            color: #fff;
        }

        &:hover {
            border-color: var(--form_highlight_color);

            .darkBg & {
                border-color: color-mix(in srgb, var(--fade_mixin_color), var(--form_border_dark) 20%);
            }
        }


        span {
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: inherit;
            line-height: inherit;
        }

        .chosen-single-with-deselect span {
            margin-right: 32px;
        }

        abbr {
            position: absolute;
            top: 6px;
            right: 26px;
            display: block;
            width: 12px;
            height: 12px;
            font-size: 1px;
        }

        div {
            position: absolute;
            bottom: 0;
            top: var(--form_icons_top);
            right: var(--form_icons_side);
            width: var(--form_icons_width);
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;

            b {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 100%;
                height: 100%;

                &:after {
                    position: relative;
                    top: auto;
                    left: 0;
                    .fa(f107, @secondary_color);
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    opacity: 1;
                    .rems(14);
                    line-height: 14px;
                    transition: all 200ms linear;
                }
            }
        }
    }

    &.chosen-container-active {

        .chosen-single {
            border-color: var(--form_highlight_color);
            transition: border-color 200ms linear;

            div > b:after {
                color: var(--secondary_color);
                opacity: 1;
                transition: all 200ms linear;
            }

            .darkBg & {
                background: var(--dark_color);
                border-color: #fff;
                color: #fff;
            }
        }

        &.chosen-with-drop {
            .chosen-single {
                border-radius: var(--chosen_border_radius) var(--chosen_border_radius) 0 0;
                border-bottom: none;
            }
        }
    }

    .chosen-search, .search-field {
        position: relative;
        z-index: 1010;
        padding: 8px;
        margin: 0;
        white-space: nowrap;
        width: 100%;

        &:after {
            position: absolute;
            top: 50%;
            right: 24px;
            transform: translateY(-50%);
            .fa(f002);
            z-index: 1000;
            .rems(14);
            line-height: 14px;
        }

        a {
            text-decoration: none;
        }

        input[type="search"] {
            float: none;
            outline: 0;
            padding: 8px 24px 8px 12px;
            width: 100% !important;

            &:focus {
                border: var(--form_border_width) solid var(--form_border_color);
                box-shadow: none;
            }
        }
    }


    .chosen-drop {
        margin-top: 0;
        background-clip: padding-box;
        text-align: left;
        border: var(--form_border_width) solid var(--form_border_color);
        border-top: none;
        border-top: none;
        overflow: hidden;
        border-radius: 0 0 var(--chosen_border_radius) var(--chosen_border_radius);
        box-shadow: none;
        transition: border-color 200ms linear;

        &.chosen-dropup {
            top: 100% !important;
            bottom: auto !important;
        }

        .darkBg & {
            background: var(--dark_color);
            border-color: color-mix(in srgb, var(--fade_mixin_color), #fff 40%);
        }
    }

    &.chosen-container-active {
        .chosen-drop {
            border-color: var(--form_highlight_color);
            transition: border-color 200ms linear;

            .darkBg & {
                border-color: transparent;
            }
        }
    }
}



&.chosen-with-drop .chosen-drop {
    left: 0;
}

.chosen-container-single.chosen-container-single-nosearch .chosen-search {
    position: absolute;
    left: -9999px;
}

.chosen-container {

    width: 100%;
    min-width: 100%;

    .chosen-results {
        float: left;
        width: 100%;
        background: #fff;
        position: relative;
        overflow-x: hidden;
        overflow-y: auto;
        max-height: 216px;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        padding: 0;

        .darkBg & {
            background: var(--dark_color);
        }

        li {
            margin: 0;
            padding: var(--form_padding_top_bottom) var(--form_padding_sides);
            list-style-type: none;
            word-wrap: break-word;
            -webkit-touch-callout: none;
            color: var(--text_color);
            font-family: var(--body_font);
            .rems(@form_font_size);
            line-height: var(--form_line_height);
            font-weight: var(--form_font_weight);
            transition: background 200ms linear, color 200ms linear;

            .darkBg & {
                color: #fff;
            }

            em {
                font-style: normal;
                text-decoration: underline;
            }

            &.active-result {
                cursor: pointer;
            }

            &.disabled-result {
                display: list-item;
                cursor: default;
                opacity: 0.5;
                pointer-events: none;
            }

            &.result-selected {
                background-color: var(--secondary_color) !important;
                color: #fff !important;
                transition: background 200ms linear, color 200ms linear;
            }

            &:hover, &.highlighted {
                background-color: color-mix(in srgb, var(--secondary_color), transparent 16%);
                transition: background 200ms linear, color 200ms linear;
            }

            &:active {
                background-color: color-mix(in srgb, var(--secondary_color), transparent 24%);
                transition: background 200ms linear, color 200ms linear;
            }

            .group-result {
                display: list-item;
                cursor: default;
            }

            .group-option {
                padding-left: 15px;
            }
        }
    }
}

.chosen-container-multi {

    .chosen-choices {
        position: relative;
        overflow: hidden;
        width: 100%;
        height: auto !important;
        background: #fff;
        border-radius: var(--chosen_border_radius);
        cursor: text;
        margin: 0;
        padding: 0 var(--form_padding_icon_offset) 0 0;
        transition: border-color 200ms linear;
        border: var(--form_border_width) solid var(--form_border_color);

        .darkBg & {
            background: transparent;
            border-color: color-mix(in srgb, var(--fade_mixin_color), var(--form_border_dark) 40%);
        }

        li {
            float: left;
            list-style-type: none;

            &.search-field {
                margin: 0;
                padding: 0;
                position: initial;
                width: ~"calc(100% + var(--form_padding_icon_offset))";

                input {
                    border: none;
                    background: transparent;
                    padding: var(--form_padding_top_bottom) var(--form_padding_icon_offset) var(--form_padding_top_bottom) var(--form_padding_sides);
                    color: var(--text_color);
                    min-width: 100% !important;
                    width: 100% !important;

                    .darkBg & {
                        color: #fff;
                    }
                }

                &:after {

                    position: absolute;
                    top: auto;
                    bottom: var(--form_icons_top);
                    right: var(--form_icons_side);
                    width: var(--form_icons_width);
                    height: 56px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    .rems(14);
                    line-height: 16px;
                    color: var(--form_icons_color) !important;
                    transition: color 200ms linear;
                    font-weight: 400 !important;
                    z-index: 1;
                    pointer-events: none;
                    transform: none !important;

                    .darkBg & {
                        color: #fff;
                    }

                }
            }

            &.search-choice-focus {
                background: red;
            }

            &.search-choice {
                position: relative;
                margin: 16px 8px 0 8px;
                padding: 0;
                max-width: 100%;
                color: var(--text_color);
                cursor: default;
                background-color: transparent;

                .darkBg & {
                    color: #fff;
                }

                & + .search-field {
                    margin-top: 12px;
                    background: rgba(0,0,0,0.04) !important;

                    .darkBg & {
                        background: rgba(0,0,0,0.1) !important;
                    }
                }

                span {
                    word-wrap: break-word;
                }

                .search-choice-close {
                    display: inline-block;
                    text-decoration: none;
                    margin: 0 0 0 5px;

                    &:after {
                        position: relative;
                        .fa(f057, @alert_color);
                        font-weight: 400;
                        transition: color 200ms linear;
                    }

                    &:hover {
                        &:after {
                            color:  color-mix(in srgb, var(--alert_color), var(--darken_mixin_color) 10%);
                            transition: color 200ms linear;
                        }
                    }

                    &:active {
                        &:after {
                            color:  color-mix(in srgb, var(--alert_color), var(--darken_mixin_color) 5%);
                            transition: color 200ms linear;
                        }
                    }
                }
            }
        }
    }


    &.chosen-container-active {

        .chosen-choices {

            border-color: var(--form_border_color);
            transition: border-color 200ms linear;

            .darkBg & {
                border-color: transparent;
            }
        }


        &.chosen-with-drop {

            .chosen-choices {
                border-radius: var(--chosen_border_radius) var(--chosen_border_radius) 0 0;
                border-bottom: none;

                li {

                    &.search-field {

                        input {
                            border-bottom-left-radius: 0 !important;
                            border-bottom-right-radius: 0 !important;
                        }
                    }

                }
            }

        }

    }

    .chosen-results {
        margin: 0;
        padding: 0;
    }

    .chosen-drop {

        &.chosen-dropup {
            margin-bottom: 8px;
        }

        .result-selected {
            display: list-item;
            color: #ccc;
            cursor: default;
        }
    }
}

.chosen-container-active {

    &.chosen-with-drop {

        .chosen-single {

            div {
                border-left: none;
                background: transparent;

                b {

                    &:after {
                        transform: rotate(-180deg);
                    }
                }
            }
        }
    }

    .chosen-disabled {
        cursor: default;
        opacity: 0.5;

        .chosen-single {
            cursor: default;
        }

        .chosen-choices .search-choice .search-choice-close {
            cursor: default;
        }
    }


}

.mobileChosen {
    position: relative;
    min-width: 200px;

    select {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
        z-index: 998;
    }
}

/*
* Ensure the select box is full width within chosen
 */
.chosen-container {
    &>select {
        width: 100% !important;
    }
}

.chosen-search {
    display: none !important;
}
