.component-backend-document {
    .document-toolbar-container {
        background-color: @document-toolbar-bg;
        border-bottom: 1px solid @primary-border;

        > div {
            font-size: 0;
            white-space: nowrap;
            padding: 3px 0;
        }
    }

    &.no-toolbar-elements .document-toolbar-container {
        display: none;
    }

    .document-toolbar-scrollable {
        width: 100%;
        overflow: hidden;
    }

    .document-toolbar-element {
        display: inline-block;
        font-size: @font-size-base;
        color: @toolbar-color;
        line-height: 33px;
        margin-right: 8px;
        vertical-align: top;
        user-select: none;

        &.button-icon-only {
            + .button-icon-only {
                margin-left: -6px;
            }
        }

        &:first-child {
            margin-left: -4px;
            padding-left: @document-ui-base-padding;
        }

        &:last-child {
            margin-right: 0;
            padding-right: @document-ui-base-padding;
        }

        &.element-type-separator {
            border-right: 1px solid @primary-border;
            height: 25px;
            position: relative;
            top: 5px;

            &:first-child {
                border-right: none;
                padding-left: 0!important;
            }

            &:last-child {
                display: none; // Do not display separators in the end of the toolbar
            }
        }

        .backend-toolbar-button {
            vertical-align: top;
            text-align: left;

            &.icon-only {
                text-align: center;
            }

            &.has-menu-trigger {
                border-top-right-radius: 0;
                border-bottom-right-radius: 0;
            }

            &.menu-trigger {
                padding: 0;
                border-top-left-radius: 0;
                border-bottom-left-radius: 0;
                width: 18px;
                min-width: 0;
                position: relative;

                &:before {
                    content: '';
                    display: block;
                    border-right: 1px solid @primary-border;
                    height: 15px;
                    position: absolute;
                    top: 10px;
                    margin-left: -2px;
                    transition: top 0.1s, height 0.1s;
                }

                &.pressed:before {
                    border-right-color: @brand-selection-text;
                    opacity: 0.5;
                }

                &:after {
                    .icon-OctoFont();
                    content: @icon-angle-down-arrow;
                    font-size: 16px;
                    vertical-align: middle;
                    position: relative;
                    top: -1px;
                }
            }

            &.pressed {
                background: rgba(var(--oc-selection-rgb), .2) !important;
                color: @brand-selection-text;
            }

            .button-label {
                display: inline-block;
            }
        }

        &:hover {
            .backend-toolbar-button {
                background: @toolbar-focus-bg;

                &.menu-trigger:before {
                    border-right: 1px solid @color-grey-6;
                    top: 7px;
                    height: 20px;
                }
            }
        }
    }

    &.built-in-mode {
        .document-toolbar-element {
            &:first-child {
                margin-left: 0;
                padding-left: 4px;
            }

            &:last-child {
                padding-right: 4px!important;
            }
        }
    }

    .fixed-right:after,
    .document-toolbar-scroll-container:before {
        content: '';
        position: absolute;
        display: block;
        width: 5px;
        height: 39px;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .fixed-right {
        position: relative;

        &:after {
            background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, #000 100%);
            left: -5px;
            top: -3px;
        }

        .document-toolbar-element {
            &:first-child {
                margin-left: 0;
                padding-left: 5px;
            }

            &:last-child {
                padding-right: @document-ui-base-padding - 6px;
            }
        }
    }

    .document-toolbar-scroll-container {
        position: relative;

        &:before {
            left: 0;
            top: 0;
            background: linear-gradient(90deg, #000 0%, rgba(0, 0, 0, 0) 100%);
        }

        &.scroll-before:before {
            opacity: 0.15;
        }

        &.scroll-after {
            .fixed-right:after {
                opacity: 0.15;
            }
        }
    }
}

.backend-component-document-toolbar-button-length-tester {
    white-space: pre-wrap;
    font-size: @font-size-base;
    position: fixed;
    visibility: hidden;
    left: -1000em;
    top: -1000em;
}
