.select2-container--default {

    // Control sizing
    //------------------------------------

    /* 1 */
    &.form-control-sm,
    &.form-control-lg {
        border-radius: 0;
        font-size: 12px;
        height: auto;
        line-height: 1;
        padding: 0;
    }

    &.form-control-sm,
    .input-group-sm &,
    .form-group-sm & {
        .select2-selection--single {
            border-radius: @border-radius-small;
            font-size: @font-size-small;
            height: @input-height-small;
            line-height: @line-height-small;
            padding: @padding-small-vertical (@padding-small-horizontal + (@caret-width-base * 3)) @padding-small-vertical @padding-small-horizontal;

            /* 2 */
            .select2-selection__arrow b {
                margin-left: -@padding-small-vertical;
            }
        }

        .select2-selection--multiple {
            min-height: @input-height-small;

            .select2-selection__choice {
                font-size: @font-size-small;
                line-height: @line-height-small;
                margin: (@padding-small-vertical - 2) 0 0 (@padding-small-horizontal / 2);
                padding: 0 (@padding-small-vertical - 2);
            }

            .select2-search--inline .select2-search__field {
                padding: 0 @padding-small-horizontal;
                font-size: @font-size-small;
                height: @input-height-small - 2;
                line-height: @line-height-small + 1;
            }

            .select2-selection__clear {
                margin-top: @padding-small-vertical;
            }
        }
    }

    &.input-lg,
    .input-group-lg &,
    .form-group-lg & {
        .select2-selection--single {
            border-radius: @border-radius-large;
            font-size: @font-size-large;
            height: @input-height-large;
            line-height: @line-height-large;
            padding: @padding-large-vertical (@padding-large-horizontal + (@caret-width-large * 3)) @padding-large-vertical @padding-large-horizontal;

            /* 1 */
            .select2-selection__arrow {
                width: @caret-width-large;

                b {
                    border-width: @caret-width-large @caret-width-large 0 @caret-width-large;
                    margin-left: -@caret-width-large;
                    margin-left: -@padding-large-vertical;
                    margin-top: -(@caret-width-large / 2);
                }
            }
        }

        .select2-selection--multiple {
            min-height: @input-height-large;

            .select2-selection__choice {
                font-size: @font-size-large;
                line-height: @line-height-large;
                border-radius: 4px;
                margin: (@padding-large-vertical - 1) 0 0 (@padding-large-horizontal / 2);
                padding: 0 @padding-large-vertical;
            }

            .select2-search--inline .select2-search__field {
                padding: 0 @padding-large-horizontal;
                font-size: @font-size-large;
                height: @input-height-large - 2;
                line-height: @line-height-large + 1;
            }

            .select2-selection__clear {
                margin-top: @padding-large-vertical;
            }
        }
    }

    &.input-lg.select2-container--open {
        .dropdown-arrow;
    }

    .input-group-lg & {
        &.select2-container--open {
            .dropdown-arrow;
        }
    }

    // RTL Support
    //------------------------------------

    &[dir="rtl"] {

        .select2-selection--single {
            padding-left: @padding-base-horizontal + @caret-width-base*3;
            padding-right: @padding-base-horizontal;
            .select2-selection__rendered {
                padding-right: 0;
                padding-left: 0;
                text-align: right; /* 1 */
            }

            .select2-selection__clear {
                float: left;
            }

            .select2-selection__arrow {
                left: @padding-base-horizontal;
                right: auto;

                b {
                    margin-left: 0;
                }
            }
        }

        .select2-selection--multiple {
            .select2-selection__choice,
            .select2-selection__placeholder {
                float: right;
            }

            .select2-selection__choice {
                margin-left: 0;
                margin-right: (@padding-base-horizontal / 2);
            }

            .select2-selection__choice__remove {
                margin-left: 2px;
                margin-right: auto;
            }
        }
    }
}

// Validation
//------------------------------------

.has-warning {
    .validation-state-focus(@state-warning-text);
}

.has-error {
    .validation-state-focus(@state-danger-text);
}

.has-success {
    .validation-state-focus(@state-success-text);
}

// Input groups
//------------------------------------

.input-group .select2-container--default {
    display: table;
    table-layout: fixed;
    position: relative;
    z-index: @zindex-form;
    float: left;
    width: 100%;
    margin-bottom: 0;
}

.input-group.select2-default-prepend .select2-container--default {
    .select2-selection {
        .border-left-radius(0);
    }
}

.input-group.select2-default-append .select2-container--default {
    .select2-selection {
        .border-right-radius(0);
    }
}

.select2-default-append,
.select2-default-prepend {
    .select2-container--default,
    .input-group-btn,
    .input-group-btn .btn {
        vertical-align: top;
    }
}

/**
 * Temporary fix for https://github.com/select2/select2-default-theme/issues/9
 *
 * Provides `!important` for certain properties of the class applied to the
 * original `<select>` element to hide it.
 *
 * @see https://github.com/select2/select2/pull/3301
 * @see https://github.com/fk/select2/commit/31830c7b32cb3d8e1b12d5b434dee40a6e753ada
 */

.form-control.select2-hidden-accessible {
    position: absolute !important;
    width: 1px !important;
}

// Inline
//------------------------------------

.form-inline .select2-container--default {
    display: inline-block;
}
