$aiot-css-prefix: aiot;

.#{$aiot-css-prefix}-tree {
    display: block;
    position: relative;
    //float: left;
    box-sizing: border-box;
    transition: opacity 500ms ease;
    opacity: 1;

    &.#{$aiot-css-prefix}-wrap-collapse {
        width: 0 !important;
        min-width: 0 !important;

        .#{$aiot-css-prefix}-pad > :not(.#{$aiot-css-prefix}-split) {
            visibility: hidden;
        }

        .#{$aiot-css-prefix}-split-collapse:after {
            content: "\E61F";
        }
    }

    .clear {
        clear: both;
    }

    .#{$aiot-css-prefix}-pad {
        padding: 10px 15px 0 0;
        margin: 0;
    }

    .#{$aiot-css-prefix}-split-resizer,
    .#{$aiot-css-prefix}-split-collapse {
        position: absolute;
        right: -9px;
        top: 18px;
        width: 16px;
        height: 30px;
        background: #d6d6d6;
        border-radius: 15px 15px 0 0;
        cursor: col-resize;
        touch-action: none;

        &:after {
            content: "\E647";
            font-family: "anticon" !important;
            color: #f1f1f1;
            position: absolute;
            top: 7px;
            left: -2px;
            font-size: 19px;
        }
    }

    .#{$aiot-css-prefix}-split-resizer:after {
        transform: rotate(90deg);
    }

    .#{$aiot-css-prefix}-split-collapse {
        top: 49px;
        border-radius: 0 0 15px 15px;
        cursor: pointer;
        height: 17px;

        &:after {
            content: "\E620";
            font-size: 9px;
            left: 3.5px;
            top: 4px;
            line-height: 9px;
        }
    }

    .#{$aiot-css-prefix}-toolbar-placeholder {
        float: left;
        font-size: 15px;
        padding: 5px 4px;
    }

    .#{$aiot-css-prefix}-toolbar {
        position: relative;
        box-sizing: border-box;
        margin: 12px 0 0;
        padding: 12px 15px;
        width: 100%;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
        border: 1px solid #e5e5e5;
        background: #fff;
        color: #555;
        font-size: 13px;
    }

    .#{$aiot-css-prefix}-toolbar-items {
        float: right;
        font-size: 15px;

        > a {
            padding: 4px 3px;
            display: block !important;
            float: left;
            color: #b4b9be;
            text-align: center;
            text-decoration: none;
            cursor: pointer;
            font-size: 18px;

            &:hover {
                color: #00008b;
            }

            &.#{$aiot-css-prefix}-border-left {
                border-left: 1px solid #e5e5e5;
                padding-left: 5px;
                margin-left: 5px;
            }
        }
    }

    .#{$aiot-css-prefix}-fixed-header {
        > div {
            background: #f1f1f1;
            z-index: 1;
            border-radius: 0px 0px 5px 5px;
            overflow: hidden;
            transition: box-shadow 500ms ease;
        }

        .#{$aiot-css-prefix}-tree-headline {
            transition: padding 250ms ease;
        }

        &.active > div {
            box-shadow:
                0px 0px 5px -5px #f1f1f1,
                0 3px 10px 1px rgba(0, 0, 0, 0.22);

            .#{$aiot-css-prefix}-tree-headline {
                padding-left: 5px;
            }

            .#{$aiot-css-prefix}-toolbar {
                border-color: white;
            }
        }
    }

    .#{$aiot-css-prefix}-search {
        margin: 5px 0 5px 7px;
        height: 24px;
    }

    .#{$aiot-css-prefix}-nodes {
        padding-top: 5px;

        .#{$aiot-css-prefix}-search-selected:before {
            content: "";
            display: block;
            position: absolute;
            top: 0px;
            left: 3px;
            right: 0px;
            bottom: 0px;
            box-shadow: 0px 0px 2px 1px #0073aa !important;
            background: rgba(0, 115, 170, 0.1);
            z-index: 999;
        }

        ul {
            display: block;
            margin: 0;
            padding: 0;
            list-style: none;
            position: relative;

            ul {
                margin: 0 0 0 20px;
            }

            li {
                display: block;
                margin: 0;
                padding: 0;
                position: relative;
            }

            &:after {
                content: "";
                position: absolute;
                top: 20px;
                left: 14px;
                bottom: 12px;
                border-right: 1px solid #ddd;
                border-left: 1px solid #fafafa;
                transition: border 200ms ease-out;
                width: 0;
                z-index: -2;
            }

            &.aiot-disable-links .aiot-node:not(.aiot-forceEnable) {
                opacity: 0.7;
                cursor: not-allowed !important;
            }
        }

        .#{$aiot-css-prefix}-node {
            text-decoration: none;
            display: block;
            padding: 4px 10px;
            box-shadow: none !important;
            transition: 250ms background ease;
            position: relative;
            cursor: pointer;
            color: #0073aa;

            &.#{$aiot-css-prefix}-state-hover {
                background: none;

                &:before {
                    position: absolute;
                    left: 4px;
                    right: 0;
                    bottom: 0;
                    top: 0;
                    box-shadow: 0px 0px 5px #0073aa !important;
                    border: 1px solid #0073aa;
                    z-index: 99;
                    clear: both;
                    content: "";
                    display: block;
                }
            }

            &:after {
                clear: both;
                content: "";
                display: block;
            }

            > div {
                float: left;
            }

            .#{$aiot-css-prefix}-node-icon {
                width: 20px;

                > i {
                    background: white;
                    border-top: 3px solid white;
                    border-bottom: 3px solid white;
                }
            }

            &.#{$aiot-css-prefix}-checkable .#{$aiot-css-prefix}-node-icon > label {
                display: none;

                .ant-checkbox-inner {
                    width: 13px;
                    height: 13px;
                }

                .ant-checkbox:not(.ant-checkbox-indeterminate) .ant-checkbox-inner:after {
                    left: 3px;
                    top: 0px;
                }
            }

            .#{$aiot-css-prefix}-node-name {
                display: inline-block;
                width: calc(100% - 50px);
                text-overflow: ellipsis;
                white-space: nowrap;
                overflow: hidden;
                padding-bottom: 1px;
            }

            input.#{$aiot-css-prefix}-node-name {
                background: none;
                border: 0;
                box-shadow: 0 2px 1px -1px #ababab;
                padding: 0;
                margin: 0;
                font-size: 13px;
                outline: 0 !important;
            }

            .#{$aiot-css-prefix}-node-count,
            button {
                color: #fff;
                float: right;
                background: #9ca1a6;
                font-size: 8px;
                padding: 1px 3px;
                border-radius: 999px;
                min-width: 14px;
                text-align: center;
                margin: -1px 0;
            }

            button {
                color: white;
                background: #0073aa;
                padding: 5px 4px;
                border-radius: 3px;
                border: 0;
            }

            button[disabled] {
                opacity: 0.5;
            }

            &.#{$aiot-css-prefix}-active {
                cursor: default;
                background: #e0e0e0;
                background: linear-gradient(
                    to right,
                    rgba(224, 224, 224, 0) 30px,
                    rgba(224, 224, 224, 1) 30%,
                    rgba(224, 224, 224, 1) 100%
                );
            }
        }
    }

    .#{$aiot-css-prefix}-expander {
        position: absolute;
        top: 0px;
        left: -17px;
        text-align: center;
        width: 25px;
        height: 21px;
        padding-top: 4px;
        font-size: 11px;
        color: #000;
        opacity: 0.8;
        font-family: "anticon" !important;

        &.#{$aiot-css-prefix}-expander-all {
            top: -30px;

            &:hover {
                box-shadow: 0px -3px 3px 1px rgba(0, 115, 170, 0.19);
            }
        }

        &:hover {
            border-radius: 3px;
            box-shadow: -3px 0px 3px 1px rgba(0, 115, 170, 0.19);
        }

        &:after {
            content: "\E627";
            background: #f1f1f1;
        }

        &.#{$aiot-css-prefix}-open:after {
            content: "\E624";
        }
    }

    .#{$aiot-css-prefix}-disabled {
        opacity: 0.7;
        cursor: not-allowed !important;
    }

    /* Sortable */
    .#{$aiot-css-prefix}-sortable-chosen {
        .#{$aiot-css-prefix}-node-name,
        .#{$aiot-css-prefix}-node-count,
        .#{$aiot-css-prefix}-node-icon i:before,
        .#{$aiot-css-prefix}-node-icon i:after {
            opacity: 0.5;
        }

        .#{$aiot-css-prefix}-expander {
            visibility: hidden;
        }
    }

    /* SortableJs creates an own ghost for the fallback implementation */
    .#{$aiot-css-prefix}-sortable-drag.sortable-fallback {
        opacity: 0 !important;
    }

    .#{$aiot-css-prefix}-sortable-empty {
        display: none !important;
        min-height: 10px;
        margin-top: -10px !important;

        > li {
            padding-top: 10px !important;
        }
    }
}

/* Checked */
.#{$aiot-css-prefix}-tree:not(.#{$aiot-css-prefix}-toolbar-active-button)
    .#{$aiot-css-prefix}-checkable:not(.#{$aiot-css-prefix}-state-hover):hover,
.#{$aiot-css-prefix}-has-checked .#{$aiot-css-prefix}-checkable {
    .#{$aiot-css-prefix}-node-icon {
        > :not(label) {
            display: none !important;
        }

        > label {
            display: block !important;
        }
    }
}

/* Sorting */
body.#{$aiot-css-prefix}-currently-sorting {
    .#{$aiot-css-prefix}-tree .#{$aiot-css-prefix}-nodes ul:after {
        border-left: 1px solid #0273aa;
    }

    .#{$aiot-css-prefix}-sortable-empty {
        display: block !important;
    }

    ul.#{$aiot-css-prefix}-sortable-gets-empty.#{$aiot-css-prefix}-sortable-one {
        &:after {
            border-left: none !important;
        }

        > .#{$aiot-css-prefix}-sortable-placeholder {
            height: 10px;
        }
    }
}

.ant-popover.#{$aiot-css-prefix}-toolbar-menu {
    padding-left: 21px;

    .ant-popover-arrow {
        left: 17px;
    }
}

/* Movement */
.#{$aiot-css-prefix}-helper {
    padding: 5px 15px 5px 20px;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    z-index: 9999999;
    background: #0073aa;
    box-shadow: 0px 1px 3px 3px rgba(0, 0, 0, 0.2);
    white-space: nowrap;

    p {
        display: block;
        margin: 0;
        padding: 0;
        font-size: 10px;
    }

    .#{$aiot-css-prefix}-helper-method-append {
        display: none;
    }
}

body.#{$aiot-css-prefix}-helper-method-append .#{$aiot-css-prefix}-helper {
    background: #159887;

    .#{$aiot-css-prefix}-helper-method-move {
        display: none;
    }

    .#{$aiot-css-prefix}-helper-method-append {
        display: block;
    }
}

/* RTL */
html[dir="rtl"] {
    .aiot-tree {
        .aiot-nodes {
            ul ul {
                margin: 0 20px 0 0;
            }

            .aiot-node {
                > div {
                    float: right;
                }

                .aiot-node-count,
                button {
                    float: left;
                }
            }
        }

        .aiot-expander {
            left: unset;
            right: -17px;
        }

        .aiot-nodes {
            .aiot-node.aiot-active {
                background: linear-gradient(to left, rgba(224, 224, 224, 0) 30px, #e0e0e0 30%, #e0e0e0 100%);
            }

            ul:after {
                left: unset;
                right: 16px;
            }
        }
    }
}
