@import 'scss/styles.scss';

.cursor-wait {
    cursor: wait;
}

.ca-modal-btn {
    position: relative;
    outline: none;
    border: none;
    border-radius: 2px;
    height: 32px;
    margin: 0;
    padding: 6px 12px;
    background: $ta-light-grey-5;
    color: $ta-light-grey-6;

    cursor: pointer;
    pointer-events: none;

    transition:
        background 0.3s ease-in-out,
        color 0.3s ease-in-out;

    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    &.has-animation {
        transition: all 150ms cubic-bezier(0.46, 0.03, 0.51, 0.95);

        &:hover {
            transform: scaleX(1.054) scaleY(1.25);

            .button-text {
                transform: scaleX(calc(1 / 1.054)) scaleY(calc(1 / 1.25));
            }
        }

        &:active {
            transform: scaleX(1.027) scaleY(1.125);

            .button-text {
                transform: scaleX(calc(1 / 1.027)) scaleY(calc(1 / 1.125));
            }
        }

        &.loading {
            cursor: wait;
            transform: scaleX(1.027) scaleY(1.125);
            pointer-events: none;

            .button-text {
                transform: scaleX(calc(1 / 1.027)) scaleY(calc(1 / 1.125));
            }

            .button-text.loading-text {
                transform: translate(-50%, -50%) scaleX(calc(1 / 1.027))
                    scaleY(calc(1 / 1.125));
            }
        }
    }

    .button-text {
        &.has-animation {
            display: inline-block;
            transition: transform 150ms cubic-bezier(0.46, 0.03, 0.51, 0.95);
        }

        &.hidden-text {
            visibility: hidden;
        }

        &.loading-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            white-space: nowrap;
        }

        .loading-dots {
            display: inline-block;

            .dot {
                display: inline-block;
                font-family: serif;
                animation: dot-cycle 1.5s infinite;

                // Dot 1: visible 0-14.28%, invisible 14.29-57.14%, visible 57.15-100%
                &:nth-child(1) {
                    animation-name: dot-cycle-1;
                }

                // Dot 2: visible 0-28.57%, invisible 28.58-71.42%, visible 71.43-100%
                &:nth-child(2) {
                    animation-name: dot-cycle-2;
                }

                // Dot 3: visible 0-42.85%, invisible 42.86-85.71%, visible 85.72-100%
                &:nth-child(3) {
                    animation-name: dot-cycle-3;
                }
            }
        }
    }

    .spinner-absolute {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .spinner-wrapper {
        position: absolute;
        right: 22px;
    }

    &.valid {
        pointer-events: all;
    }

    &.modal-small-btn {
        min-width: 100px;
    }

    &.modal-normal-btn {
        min-width: 150px;
    }

    &.modal-full-width-btn {
        width: 100%;
    }

    &.modal-big-full-width-btn {
        height: 62px;
        width: 100%;
    }

    &.special-small-btn {
        height: 22px;
        width: 100%;
        font-size: 11px !important;
        line-height: 14px !important;
    }

    &.special-default-btn {
        height: 26px;
        min-width: 100px;
    }

    &.special-default-full-width-btn {
        height: 26px;
        width: 100%;
    }

    &.primary-positive-btn {
        &.valid {
            background: $ta-blue-14;
            color: $white-2;

            &.text-and-spinner-shown {
                background: $blue-9;
                color: $ta-blue-19;
            }

            &:hover {
                background: $ta-blue-15;
            }

            &.has-animation {
                &:active {
                    background: $ta-blue-27;
                }

                &.loading {
                    background: $ta-blue-27;
                }
            }
        }
    }

    &.secondary-positive-btn {
        &.valid {
            background: $grey-12;
            color: $blue-11;

            &:hover {
                background: $blue-9;
                color: $white-2;
            }

            &.has-animation {
                &:active {
                    background: $ta-blue-27;
                    color: $white-2;
                }

                &.loading {
                    background: $ta-blue-27;
                    color: $white-2;
                }
            }
        }
    }

    &.primary-neutral-btn {
        &.valid {
            background: $grey-2;
            color: $white-2;

            &:hover {
                background: $black;
            }

            &.has-animation {
                &:active {
                    background: $black-9;
                    color: $white-2;
                }

                &.loading {
                    background: $black-9;
                    color: $white-2;
                }
            }
        }
    }

    &.secondary-neutral-btn {
        &.valid {
            background: $grey-12;
            color: $black;

            &:hover {
                background: $black;
                color: $white-2;
            }

            &.has-animation {
                &:active {
                    background: $black-9;
                    color: $white-2;
                }

                &.loading {
                    background: $black-9;
                    color: $white-2;
                }
            }
        }
    }

    &.primary-negative-btn {
        &.valid {
            background: $red-9;
            color: $white-2;

            &:hover {
                background: $ta-red-14;
            }

            &.has-animation {
                &:active {
                    background: $ta-red-24;
                }

                &.loading {
                    background: $ta-red-24;
                }
            }
        }
    }

    &.secondary-negative-btn {
        &.valid {
            background: $grey-12;
            color: $red-9;

            &:hover {
                background: $ta-red-14;
                color: $white-2;
            }

            &.has-animation {
                &:active {
                    background: $ta-red-24;
                    color: $white-2;
                }

                &.loading {
                    background: $ta-red-24;
                    color: $white-2;
                }
            }
        }
    }

    &.plain-text-btn {
        &.valid {
            background: transparent;
            color: $ta-blue-14;

            &:hover {
                background: transparent;
                color: $ta-blue-15;
            }
        }
    }

    &.primary-white-btn {
        &.valid {
            background: $white-2;
            color: $ta-blue-14;

            &:hover {
                background: $ta-blue-14;
                color: $white-2;
            }
        }
    }
    &.special-positive-btn {
        padding: 4px 8px !important;
        &.valid {
            background: $ta-blue-18;
            color: $white-2;

            &:hover {
                background: $white-2;
                color: $blue-9;
            }
        }
    }
    &.special-neutral-btn {
        padding: 4px !important;
        &.valid {
            background: $grey-12;
            color: $bw6-2;

            &:hover {
                background: $bw-9;
                color: $black;
            }
        }
    }
}

// Dot 1: visible 0-14.28%, invisible 14.29-57.14%, visible 57.15-100%
@keyframes dot-cycle-1 {
    0%,
    14.28% {
        opacity: 1;
    }
    14.29%,
    57.14% {
        opacity: 0;
    }
    57.15%,
    100% {
        opacity: 1;
    }
}

// Dot 2: visible 0-28.57%, invisible 28.58-71.42%, visible 71.43-100%
@keyframes dot-cycle-2 {
    0%,
    28.57% {
        opacity: 1;
    }
    28.58%,
    71.42% {
        opacity: 0;
    }
    71.43%,
    100% {
        opacity: 1;
    }
}

// Dot 3: visible 0-42.85%, invisible 42.86-85.71%, visible 85.72-100%
@keyframes dot-cycle-3 {
    0%,
    42.85% {
        opacity: 1;
    }
    42.86%,
    85.71% {
        opacity: 0;
    }
    85.72%,
    100% {
        opacity: 1;
    }
}
