/*!
 * Copyright 2023 Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
.k-loader {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    box-sizing: border-box;
    border-width: 0;
    box-shadow: none;

    // Prevents the inline elements from being displaced.
    // A good example is the 'pulsing' loader inside a button.
    line-height: 0;
}
.k-widget.k-loader {
    background: none;
    box-shadow: none;
}

.k-loader-canvas {
    position: relative;
}

// Loader segment
.k-loader-segment {
    position: absolute;
    display: inline-block;

    &::after {
        content: "";
        display: block;
        border-radius: @loader-segment-border-radius;
    }
}

// Loader sizes
.k-loader-sm {
    padding: @loader-padding-sm;

    .k-loader-segment {
        &::after {
            width: @loader-segment-size-sm;
            height: @loader-segment-size-sm;
        }
    }
}
.k-loader-md {
    padding: @loader-padding-md;

    .k-loader-segment {
        &::after {
            width: @loader-segment-size-md;
            height: @loader-segment-size-md;
        }
    }
}
.k-loader-lg {
    padding: @loader-padding-lg;

    .k-loader-segment {
        &::after {
            width: @loader-segment-size-lg;
            height: @loader-segment-size-lg;
        }
    }
}


// Loader Animation Types
.k-loader-pulsing-2 {
    .k-loader-segment {
        position: relative;

        &:nth-child(1) {
            animation: pulsing-2-first-child 1s ease infinite;
        }

        &:nth-child(2) {
            animation: pulsing-2-second-child 1s ease infinite;
        }
    }

    &.k-loader-sm {
        .k-loader-segment {
            &:first-child {
                margin-right: @loader-pulsing-2-segment-margin-x-sm;
            }

            &:last-child {
                margin-left: @loader-pulsing-2-segment-margin-x-sm;
            }
        }
    }

    &.k-loader-md {
        .k-loader-segment {
            &:first-child {
                margin-right: @loader-pulsing-2-segment-margin-x-md;
            }

            &:last-child {
                margin-left: @loader-pulsing-2-segment-margin-x-md;
            }
        }
    }

    &.k-loader-lg {
        .k-loader-segment {
            &:first-child {
                margin-right: @loader-pulsing-2-segment-margin-x-lg;
            }

            &:last-child {
                margin-left: @loader-pulsing-2-segment-margin-x-lg;
            }
        }
    }
}

.k-loader-spinner-3 {
    .k-loader-segment {
        &:nth-child(1) {
            animation: spinner-3-first-child 2s ease infinite;
        }

        &:nth-child(2) {
            animation: spinner-3-second-child 2s ease infinite;
        }

        &:nth-child(3) {
            animation: spinner-3-third-child 2s ease infinite;
        }
    }

    &.k-loader-sm {
        .k-loader-canvas {
            width: @loader-spinner-3-width-sm;
            height: @loader-spinner-3-height-sm;
        }
    }

    &.k-loader-md {
        .k-loader-canvas {
            width: @loader-spinner-3-width-md;
            height: @loader-spinner-3-height-md;
        }
    }

    &.k-loader-lg {
        .k-loader-canvas {
            width: @loader-spinner-3-width-lg;
            height: @loader-spinner-3-height-lg;
        }
    }
}

.k-loader-spinner-4 {
    .k-loader-canvas {
        animation: spinner-4 1.833s ease infinite;
    }

    .k-loader-segment {
        &:nth-child(1) {
            animation: spinner-4-first-child 1.833s ease infinite;
        }

        &:nth-child(2) {
            animation: spinner-4-second-child 1.833s ease infinite;
        }

        &:nth-child(3) {
            animation: spinner-4-third-child 1.833s ease infinite;
        }

        &:nth-child(4) {
            animation: spinner-4-fourth-child 1.833s ease infinite;
        }
    }

    &.k-loader-sm {
        .k-loader-canvas {
            width: @loader-spinner-4-width-sm;
            height: @loader-spinner-4-height-sm;
        }
    }

    &.k-loader-md {
        .k-loader-canvas {
            width: @loader-spinner-4-width-md;
            height: @loader-spinner-4-height-md;
        }
    }

    &.k-loader-lg {
        .k-loader-canvas {
            width: @loader-spinner-4-width-lg;
            height: @loader-spinner-4-height-lg;
        }
    }
}


// Pulsing 2
@keyframes pulsing-2-first-child {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}
@keyframes pulsing-2-second-child {
    0% { transform: scale(1.5); }
    50% { transform: scale(1); }
    100% { transform: scale(1.5); }
}

// Spinner 3
@keyframes spinner-3-first-child {
    0% {
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }

    33.3% {
        top: 100%;
        left: 0;
        transform: translateX(0) translateY(-100%);
    }

    66.6% {
        top: 100%;
        left: 100%;
        transform: translateX(-100%) translateY(-100%);
    }

    100% {
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }
}
@keyframes spinner-3-second-child {
    0% {
        top: 100%;
        left: 0;
        transform: translateX(0) translateY(-100%);
    }

    33.3% {
        top: 100%;
        left: 100%;
        transform: translateX(-100%) translateY(-100%);
    }

    66.6% {
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }

    100% {
        top: 100%;
        left: 0;
        transform: translateX(0) translateY(-100%);
    }
}
@keyframes spinner-3-third-child {
    0% {
        top: 100%;
        left: 100%;
        transform: translateX(-100%) translateY(-100%);
    }

    33.3% {
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(0);
    }

    66.6% {
        top: 100%;
        left: 0;
        transform: translateX(0) translateY(-100%);
    }

    100% {
        top: 100%;
        left: 100%;
        transform: translateX(-100%) translateY(-100%);
    }
}

// Spinner 4
@keyframes spinner-4-first-child {
    0% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }

    33.3% {
        top: 0;
        left: 0;
        transform: translateX(0) translateY(0);
    }

    66.6% {
        top: 0;
        left: 0;
        transform: translateX(0) translateY(0);
    }

    100% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }
}
@keyframes spinner-4-second-child {
    0% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }

    33.3% {
        top: 0;
        left: 100%;
        transform: translateX(-100%) translateY(0);
    }

    66.6% {
        top: 0;
        left: 100%;
        transform: translateX(-100%) translateY(0);
    }

    100% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }
}
@keyframes spinner-4-third-child {
    0% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }

    33.3% {
        top: 100%;
        left: 100%;
        transform: translateX(-100%) translateY(-100%);
    }

    66.6% {
        top: 100%;
        left: 100%;
        transform: translateX(-100%) translateY(-100%);
    }

    100% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }
}
@keyframes spinner-4-fourth-child {
    0% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }

    33.3% {
        top: 100%;
        left: 0;
        transform: translateX(0) translateY(-100%);
    }

    66.6% {
        top: 100%;
        left: 0;
        transform: translateX(0) translateY(-100%);
    }

    100% {
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
    }
}
@keyframes spinner-4 {
    0% {
        transform: rotate(0);
    }

    33.3% {
        transform: rotate(0);
    }

    66.6% {
        transform: rotate(180deg);
    }

    100% {
        transform: rotate(180deg);
    }
}


