/* ------------------------------------------------------------------------------
*
*  # Bootstrap multiselect
*
*  Styles for multiselect.js - custom multiple select plugin
*
*  Version: 1.0
*  Latest update: May 25, 2015
*
* ---------------------------------------------------------------------------- */


// Core
// ------------------------------

.multiselect {
    width: 100%;
    min-width: 100%;
    text-align: right;
    padding-right: @padding-base-horizontal;
    padding-left: ((@padding-base-horizontal * 2) + 5);
    text-overflow: ellipsis;
    overflow: hidden;

    // Default button overrides
    &.btn-default {
        &,
        &.disabled {
            background-color: @input-bg;
            border-color: @input-border;
        }

        &:active,
        .btn-group.open & {
            border-color: @input-border;
        }
    }

    // Caret
    .caret {
        position: absolute;
        top: 50%;
        left: @padding-base-horizontal;
        margin-top: -(@icon-font-size / 2);
        width: @icon-font-size;
        text-align: left;
    }


    //
    // Make it as an input instead of button
    //

    // Large
    &.btn-lg {
        padding-right: @padding-large-horizontal;
        padding-left: (@padding-large-horizontal * 2);

        .caret {
            left: @padding-large-horizontal;
        }
    }

    // Small
    &.btn-sm {
        padding-right: @padding-small-horizontal;
        padding-left: (@padding-small-horizontal * 2);

        .caret {
            left: @padding-small-horizontal;
        }
    }

    // Mini
    &.btn-xs {
        padding-right: @padding-xs-horizontal;
        padding-left: (@padding-xs-horizontal * 2);

        .caret {
            left: @padding-xs-horizontal;
        }
    }
}


// Container
// ------------------------------

.multiselect-container {
    min-width: 180px;
    max-height: 250px;
    overflow-y: auto;

    > li {
        padding: 0;

        > a {
            padding: 0;

            > label {
                margin: 0;
                height: 100%;
                cursor: pointer;
                padding: (@padding-base-vertical + 1) @padding-base-horizontal;
                padding-right: (@padding-base-horizontal + @checkbox-size + 10);
            }

            // Checkboxes and radios
            .checker,
            .choice {
                top: 50%;
                margin-top: -(@checkbox-size / 2);
                right: @padding-base-horizontal;
            }

            // Select all link
            &.multiselect-all label {
                font-weight: 500;
            }
        }

        // Disabled item
        &.disabled > a {
            background-color: transparent;

            > label {
                cursor: @cursor-disabled;
            }
        }

        // Optgroup title
        &.multiselect-group {
            > label,
            &.active > label {
                margin: 0;
                padding: (@padding-base-vertical + 1) @content-padding-base;
                font-size: @font-size-mini;
                line-height: @line-height-mini;
                color: @text-muted;
                text-transform: uppercase;
                margin-top: (@list-spacing * 2);
                background-color: transparent;
                cursor: default;
            }

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

            &:first-child {
                > label,
                &.active > label {
                    margin-top: @list-spacing;
                }
            }

            // Clickable group
            &.multiselect-group-clickable > label {
                cursor: pointer;
            }

            // Disabled group
            &.disabled {
                &,
                &:hover,
                &:focus {
                    label {
                        background-color: transparent;
                        cursor: @cursor-disabled;
                    }
                }
            }
        }
    }
}


// Width sizing
// ------------------------------

// Full width
.multi-select-full > .btn-group {
    width: 100%;

    .multiselect-container {
        width: inherit;
    }
}

// Fixed width
.multi-select-fixed > .btn-group > .btn {
    width: 250px;
}

// Auto width
.multi-select-auto > .btn-group > .btn {
    width: auto;
}


// Misc
// ------------------------------

// Border color
div[class*=border-] > .btn-group {
    border-color: inherit;

    > .multiselect {
        border-color: inherit;
    }
}

// Filter
li.multiselect-filter {
    position: relative;
    padding: @padding-base-horizontal;
    padding-top: (@padding-base-horizontal - @list-spacing);
    margin-bottom: 0;

    // Center icon vertically
    i {
        font-size: @font-size-base;
        position: absolute;
        right: (@padding-base-horizontal * 2);
        top: 50%;
        margin-top: -((@font-size-base / 2) + (@list-spacing / 2));
        .opacity(0.5);
    }

    // Input horizontal padding
    .form-control {
        padding-right: (@padding-base-horizontal * 3);
    }
}

// Remove left rounded corners
.input-group-btn,
.input-group-addon {
    & + .multi-select-full,
    & + .multi-select-auto,
    & + .multi-select-fixed,
    & + .btn-group {
        .multiselect:first-child {
            .border-left-radius(0);
        }
    }
}

// Button group styles
.btn-group-multiselect {
    width: 100%;

    .btn {
        float: none;
    }

    .multiselect {
        min-width: 0;
    }
}
.btn-group > .btn-group:nth-child(2) > .multiselect.btn {
    .border-left-radius(@border-radius-small);
}
