/**
 * @class Ext.SplitButton
 */

.#{$prefix}splitButton {
    display: inline-flex;
    position: relative;
    // min-width/min-height of 0 allows the button to be flex-shrunk by an owning box
    // layout to a size that's smaller than the button's content-size
    min-width: 0;
    min-height: 0;

    .#{$prefix}splitBody-el {
        overflow: hidden;
        align-items: center;
        display: flex;
        flex: 1 1 auto;
    }

    .#{$prefix}body-el {
        overflow: hidden;
        margin: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: inherit;
    }

    .#{$prefix}icon-el {
        flex-shrink: 0;
        display: none;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        text-align: center;
    }

    &.#{$prefix}has-icon .#{$prefix}icon-el {
        display: flex;
    }

    .#{$prefix}text-el {
        white-space: nowrap;
        text-overflow: ellipsis;
        display: none;
        overflow: hidden;
    }

    &.#{$prefix}has-text .#{$prefix}text-el {
        display: block;
    }

    &.#{$prefix}icon-align-top,
    &.#{$prefix}icon-align-bottom {
         .#{$prefix}text-el {
             max-width: 100%;
         }
    }

    .#{$prefix}arrow-el {
        display: none;
        flex-shrink: 0;
    }

    &.#{$prefix}has-arrow,
    &.#{$prefix}has-menu:not(.#{$prefix}no-arrow) {
        .#{$prefix}arrow-el {
            display: flex;
        }
    }

    .#{$prefix}button-el {
        // button-el is a transparent element that overlays the entire button and captures
        // clicks and tabs for accessibility purposes.
        opacity: 0;
        outline: none;
        cursor: pointer;
        z-index: 3; // must have higher z-index than badge-el
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border: 0;
        margin: 0;
        padding: 0;
    }

    &.#{$prefix}icon-align-top .#{$prefix}body-el {
        flex-direction: column;
    }

    &.#{$prefix}icon-align-bottom .#{$prefix}body-el {
        flex-direction: column-reverse;
    }

    &.#{$prefix}icon-align-right .#{$prefix}body-el {
        flex-direction: row-reverse;
    }

    &.#{$prefix}text-align-left .#{$prefix}body-el {
        margin-left: 0;
    }

    &.#{$prefix}text-align-right .#{$prefix}body-el {
        margin-right: 0;
    }

    .#{$prefix}ie11 &:not(.#{$prefix}has-text) .#{$prefix}body-el {
        flex-direction: column;
    }

    &.#{$prefix}arrow-align-right .#{$prefix}splitBody-el {
        flex-direction: row;
        align-items: center;
    }

    &.#{$prefix}arrow-align-bottom {
        .#{$prefix}splitBody-el {
            flex-direction: column;
            justify-content: flex-start;
        }

        .#{$prefix}body-el {
            margin-bottom: 0;
            max-width: 100%;
        }
        
        .#{$prefix}arrow-el {
            margin-top: auto;
        }
    }

    &.#{$prefix}disabled {
        pointer-events: none;
    }

    &.#{$prefix}focused:after {
        // This is a pseudo element for simulating a focus outline.
        // We can't use regular css outline because it does not support radius.
        // We also can't simulate an outline using box-shadow because buttons may
        // already have a box-shadow configured using the $button-shadow var.
        // This rule just brings the pseudo element into existence.  It's border is styled
        // by the button-ui mixin.

        .#{$prefix}keyboard-mode & {
            content: '';
            pointer-events: none;
            position: absolute;
            top: -1px;
            right: -1px;
            bottom: -1px;
            left: -1px;

        }
    }

    &:before {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        opacity: 0;
    }

    &.#{$prefix}pressing,
    &.#{$prefix}pressed {
        &:before {
            opacity: 1;
        }
    }
}
