@icon-color: #333333;

.select2-container,
.select2-drop,
.select2-search,
.select2-search input {
    -webkit-box-sizing: border-box; /* webkit */
    -moz-box-sizing: border-box; /* firefox */
    box-sizing: border-box; /* css3 */
}

.select2-container {
    display: inline-block;
    height: auto !important;
    margin: 0;
    padding: 0;
    position: relative;
    vertical-align: middle;
    zoom: 1;

    &-active {
        @color-rgba: rgba(red(@input-border-focus), green(@input-border-focus), blue(@input-border-focus), .6);
        border-color: @input-border-focus;
        .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}");
    }

    .select2-choice {
        background-clip: padding-box;
        border: 0;
        border-radius: @border-radius-base;
        .box-shadow(inset 0 -1px 1px rgba(0,0,0,.05));
        color: @text-color;
        display: block;
        height: 32px;
        line-height: 26px;
        outline: none !important;
        overflow: hidden;
        padding: 3px @padding-base-horizontal;
        position: relative;
        text-decoration: none;
        white-space: nowrap;
        user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;

        >.select2-chosen {
            display: inline-block;
            float: none;
            margin-right: 26px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            width: auto;
        }

        abbr.select2-search-choice-close {
            background: none;
            border-right: 1px solid @input-border;
            color: @gray;
            cursor: pointer;
            display: none;
            font-style: normal;
            font-weight: normal;
            font-size: 150%;
            height: 100%;
            line-height: 1.5em;
            outline: none;
            position: absolute;
            right: 30px;
            top: 0;
            width: 22px;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;

            &:before {
                color: @icon-color;
                content: "\00d7";
            }

            &:hover {
                color: @brand-danger;
            }
        }

        .select2-arrow {
            background-clip: padding-box;
            background-color: transparent;
            border-radius: 0 @border-radius-base @border-radius-base 0;
            display: inline-block;
            width: 22px;
            position: absolute;
            right: 0;

            b {
                width: 1.4em;
                display: inline-block;
                line-height: 1;
                vertical-align: middle;
                box-sizing: border-box;
                overflow: hidden;
                white-space: nowrap;

                font-size: .65em;

                &::before {
                    font-family: "Glyphicons Halflings";

                    font-style: normal;
                    font-weight: normal;
                    speak: none;

                    position: relative;
                    top: 1px;
                    display: inline-block;
                    text-decoration: inherit;
                    width: 1em;
                    text-align: center;

                    font-variant: normal;
                    text-transform: none;

                    line-height: 1em;

                    margin-right: .2em;
                    margin-left: .2em;

                    -webkit-font-smoothing: antialiased;
                    -moz-osx-font-smoothing: grayscale;

                    content: @icon-select-open;
                }
            }
        }
    }

    .select2-choices {
        border: 0 !important;
        border-radius: @border-radius-base;
    }

    &.select2-drop-above {
        border-radius: 0 0 @border-radius-base @border-radius-base;

        .select2-choice {
            border-bottom-color: @input-border;
        }
    }

    &.select2-allowclear .select2-choice {
        .select2-chosen {
            margin-right: 42px;
        }

        abbr {
            display: inline-block;
        }
    }

    &.select2-container-disabled .select2-choice {
        background-color: #f4f4f4;
        background-image: none;
        border: 1px solid #ddd;
        cursor: default;

        .select2-arrow {
            background-color: #f4f4f4;
            background-image: none;
            border-left: 0;
        }

        abbr {
            display: none;
        }
    }
}

html[dir="rtl"] {
    .select2-container .select2-choice {
        padding: 0 8px 0 0;

        >.select2-chosen {
            margin-left: 26px;
            margin-right: 0;
        }
        .select2-arrow {
            left: 0;
            right: auto;

            border-left: none;
            border-right: 1px solid @input-border;
            border-radius: @border-radius-base 0 0 @border-radius-base;
        }
    }

    .select2-search input {
        padding: 4px 5px 4px 20px;
    }

    .select2-dropdown-open .select2-choice .select2-arrow {
        border-right: none;
    }

    .select2-results {
        padding: 0 4px 0 0;
        margin: 4px 0 4px 4px;
    }

    .select2-container-multi {
        .select2-choices {
            padding: 0 0 0 5px;

            li {
                float: right;
            }

            .select2-search-choice {
                margin: 3px 5px 3px 0;
                padding: 3px 18px 3px 5px;
            }
        }

        .select2-search-choice-close {
            left: auto;
            right: 2px;
        }
    }

    .select2-search-choice-close {
        right: auto;
        left: 3px;
    }
}

.select2-drop {
    width: 100%;
    margin-top: -1px;
    position: absolute;
    z-index: 9999;
    top: 100%;

    color: @text-color;
    background: @input-bg;
    border: 1px solid @input-border;

    border-radius: 0 0 @border-radius-base @border-radius-base;

    &-mask {
        border: 0;
        margin: 0;
        padding: 0;
        position: fixed;
        left: 0;
        top: 0;
        min-height: 100%;
        min-width: 100%;
        height: auto;
        width: auto;
        opacity: 0;
        z-index: 9998;
        /* styles required for IE to work */
        background-color: #fff;
        filter: alpha(opacity=0);
    }

    &-active {
        border: 1px solid @brand-primary;
        border-top-color: @input-border;

        &.select2-drop-multi {
            background: @input-bg;
            //border-top-width: 0;
        }
    }

    &.select2-drop-above {
        border-bottom: 1px solid @input-border;
        border-top: 1px solid @brand-primary;
        border-radius: @border-radius-base @border-radius-base 0 0;
        margin-top: 1px;
        z-index: 10001;
    }

    &-auto-width {
        border-top: 1px solid @input-border;
        width: auto;
    }
}

.select2-search {
    border-bottom: 1px solid @input-border;
    display: inline-block;
    min-height: 26px;
    margin: 0;
    padding-left: 5px;
    padding-right: 5px;
    padding-bottom: (@padding-base-vertical - 1);
    position: relative;
    white-space: nowrap;
    width: 100%;
    z-index: 10000;

    input {
        border: 1px solid @brand-primary;
        border-radius: @border-radius-base;
        font-size: 1em;
        .form-control-focus();
        height: auto !important;
        margin: 0;
        margin-top: 5px;
        min-height: 26px;
        padding: @padding-base-vertical;
        outline: 0;
        width: 100%;

        &.select2-active {
            background: @input-bg no-repeat 100%;
        }
    }
}

.select2-container-active {
    .select2-choice,
    .select2-choices {
        border: 1px solid @brand-primary;
        outline: none;
    }

    .select2-choice {
        border: 0;

        .select2-arrow {
            b {
                color: @brand-primary;
            }
        }
    }
}

.select2-dropdown-open {
    border-color: @brand-primary;
    border-radius: @border-radius-base @border-radius-base 0 0;
    .transition(all 0 ease 0);

    .select2-choice {
        border: 0;
        border-bottom-color: transparent;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        .box-shadow(none);

        .select2-arrow {
            background: transparent;
            border-left: none;

            .box-shadow(none);

            b:before {
                content: @icon-select-close;
            }
        }
    }

    .select2-choices {
        border-radius: @border-radius-base @border-radius-base 0 0;
    }
}

.select2-hidden-accessible {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

.select2-results {
    margin: 0;
    max-height: 200px;
    padding: 0;
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

    ul.select2-result-sub {
        margin: 0;
        padding-left: 0;
    }

    li {
        background-image: none;
        display: list-item;
        list-style: none;

        &.select2-result-with-children > .select2-result-label {
            font-weight: bold;
        }

        em {
            background: #feffde;
            font-style: normal;
        }
    }

    .select2-result-label {
        cursor: pointer;
        margin: 0;
        min-height: 1em;
        padding: @padding-base-vertical @padding-base-horizontal;
        user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;

        .text-muted {
            color: @gray;
            display: block;
            font-size: @font-size-small;
        }
    }

    .select2-highlighted {
        background: @component-active-bg;
        color: @component-active-color;

        em {
            background: transparent;
        }

        ul {
            background: @input-bg;
            color: @text-color;
        }

        .text-muted {
            color: @text-muted;
        }
    }

    .select2-no-results,
    .select2-searching,
    .select2-ajax-error,
    .select2-selection-limit {
        color: @gray;
        display: list-item;
        font-style: oblique;
        padding: @padding-base-vertical @padding-base-horizontal;
    }

    .select2-disabled {
        background: #f4f4f4;
        cursor: default;
        display: list-item;

        &.select2-highlighted {
            background: #f4f4f4;
            color: #666;
            cursor: default;
            display: list-item;
        }
    }

    .select2-selected {
        display: none;
    }

    .select2-ajax-error {
        background: rgba(255, 50, 50, .2);
    }
}

.select2-results-dept-1 .select2-result-label { padding-left: 20px }
.select2-results-dept-2 .select2-result-label { padding-left: 40px }
.select2-results-dept-3 .select2-result-label { padding-left: 60px }
.select2-results-dept-4 .select2-result-label { padding-left: 80px }
.select2-results-dept-5 .select2-result-label { padding-left: 100px }
.select2-results-dept-6 .select2-result-label { padding-left: 110px }
.select2-results-dept-7 .select2-result-label { padding-left: 120px }

.select2-more-results.select2-active {
    background: #f4f4f4 no-repeat 100%;
}

.select2-more-results {
    background: #f4f4f4;
    display: list-item;
}

.select2-container-multi {
    .select2-choices {
        background-color: @input-bg;
        border: 1px solid @input-border;
        .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
        cursor: text;
        height: auto !important;
        height: 1%;
        margin: 0;
        min-height: 26px;
        overflow: hidden;
        padding: 0 (@padding-base-horizontal - 5);
        position: relative;

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

        .select2-search-field {
            margin: 0;
            white-space: nowrap;

            input {
                background: transparent !important;
                border: 0;
                color: #666;
                font-size: 100%;
                margin: 1px 0;
                outline: 0;
                padding: 5px;

                &.select2-active {
                    background: @input-bg no-repeat 100% !important;
                }
            }
        }

        .select2-search-choice {
            border: 1px solid @btn-default-border;
            border-radius: @btn-border-radius-small;
            color: @btn-default-color;
            cursor: default;
            line-height: 13px;
            margin: 4px 0 0 5px;
            padding: 5px 24px 4px 12px;
            position: relative;
            user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            background-color: @btn-default-bg;

            &.select2-search-choice-focus {
                background-color: darken(@btn-default-bg, 10%);
                border-color: darken(@btn-default-border, 12%);
                color: @btn-default-color;

                .select2-search-choice-close {
                    color: @text-muted;

                    &:hover {
                        color: @text-color;
                    }
                }
            }

            .select2-chosen {
                cursor: default;
            }

            .select2-search-choice-close {
                background: none;
                color: @gray;
                cursor: pointer;
                font-size: 125%;
                font-style: normal;
                font-weight: normal;
                height: 100%;
                position: absolute;
                right: 0px;
                top: 4px;
                width: 22px;
                -webkit-font-smoothing: antialiased;
                -moz-osx-font-smoothing: grayscale;

                &::before {
                    content: "\00d7";
                    padding-left: 6px;
                }

                &:hover {
                    color: @brand-danger;
                    text-decoration: none;
                }
            }
        }
    }

    &.select2-container-active .select2-choices {
        border: 1px solid @brand-primary;
        outline: none;
    }

    &.select2-container-disabled .select2-choices {
        background-color: #f4f4f4;
        background-image: none;
        border: 1px solid #ddd;
        cursor: default;

        .select2-search-choice {
            background-image: none;
            background-color: #f4f4f4;
            border: 1px solid #ddd;
            padding: 3px 5px 3px 5px;
        }
    }
}

.select2-locked {
    padding: 3px 5px 3px 5px !important;
}

.select2-default {
    color: @gray !important;
}

.select2-choices .select2-default {
    color: @input-color-placeholder !important;
}

.select2-result-selectable .select2-match,
.select2-result-unselectable .select2-match {
    text-decoration: underline;
}

.select2-offscreen, .select2-offscreen:focus {
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    height: 1px !important;
    left: 0 !important;
    margin: 0 !important;
    outline: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    top: 0 !important;
    width: 1px !important;
}

.select2-display-none {
    display: none;
}

.select2-measure-scrollbar {
    height: 100px;
    left: -10000px;
    overflow: scroll;
    position: absolute;
    top: -10000px;
    width: 100px;
}

.control-group.warning .select2-container .select2-choice,
.control-group.warning .select2-container .select2-choices,
.control-group.warning .select2-container-active .select2-choice,
.control-group.warning .select2-container-active .select2-choices,
.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice,
.control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices,
.control-group.warning .select2-container-multi.select2-container-active .select2-choices {
    border: 1px solid #C09853 !important;
}

.control-group.warning .select2-container .select2-choice div {
    background: #FCF8E3 !important;
    border-left: 1px solid #C09853 !important;
}

.control-group.error .select2-container .select2-choice,
.control-group.error .select2-container .select2-choices,
.control-group.error .select2-container-active .select2-choice,
.control-group.error .select2-container-active .select2-choices,
.control-group.error .select2-dropdown-open.select2-drop-above .select2-choice,
.control-group.error .select2-dropdown-open.select2-drop-above .select2-choices,
.control-group.error .select2-container-multi.select2-container-active .select2-choices {
    border: 1px solid #B94A48 !important;
}

.control-group.error .select2-container .select2-choice div {
    background: #F2DEDE !important;
    border-left: 1px solid #B94A48 !important;
}

.control-group.info .select2-container .select2-choice,
.control-group.info .select2-container .select2-choices,
.control-group.info .select2-container-active .select2-choice,
.control-group.info .select2-container-active .select2-choices,
.control-group.info .select2-dropdown-open.select2-drop-above .select2-choice,
.control-group.info .select2-dropdown-open.select2-drop-above .select2-choices,
.control-group.info .select2-container-multi.select2-container-active .select2-choices {
    border: 1px solid #3A87AD !important;
}

.control-group.info .select2-container .select2-choice div {
    background: #D9EDF7 !important;
    border-left: 1px solid #3A87AD !important;
}

.control-group.success .select2-container .select2-choice,
.control-group.success .select2-container .select2-choices,
.control-group.success .select2-container-active .select2-choice,
.control-group.success .select2-container-active .select2-choices,
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choice,
.control-group.success .select2-dropdown-open.select2-drop-above .select2-choices,
.control-group.success .select2-container-multi.select2-container-active .select2-choices {
    border: 1px solid #468847 !important;
}

.control-group.success .select2-container .select2-choice div {
    background: #DFF0D8 !important;
    border-left: 1px solid #468847 !important;
}
