@import '../../styles/vars';
@import '../../styles/typography';
@import '../../styles/sizes';
@import '../../styles/flex';
@import '../../styles/color';
@import '../../styles/media';


@mixin transparentSetting(){
  box-shadow: none;
}

.one-ui-button {
    $root: &;
    display: flex;
    align-items: center;
    border-radius: 30px;
    border: none;
    text-align: center;
    line-height: 1.5;
    cursor: pointer;
    height: auto;
    outline: none;
    transition: background 0.3s, box-shadow .3s ease-in-out, color .3s linear;
    justify-content: center;
    overflow: hidden;
    position: relative;
    letter-spacing: .3px;
    box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);


    @include font('s-12','medium','family-euclid');
    @include setMargin();
    @include setFlex();
    @include setAlign();


    &__content {
        &--fullWidth {
          width: 100%;
        }
        display: inline-flex;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        align-items: center;
        text-align: center;
        transition: transform .2s ease, opacity .2s ease;
        font-family: inherit;

        @include media('','xsm'){
            white-space: normal;
        }
    }
    &__loader{
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate3d(-50%,100%,0);
        transition: transform .2s ease, opacity .2s ease;
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 0;
    }
    &--loading{
        #{$root}__loader{
            transform: translate3d(-50%,-50%,0);
            opacity: 1;
        }
        #{$root}__content{
            transform: translate3d(0,-50%,0);
            opacity: 0;
        }
    }
    .one-ui-icon {
        display: inline-flex;
        //margin-right: 8px;
    }


    &--size {
        $sizeNames: xs sm md lg xl xxl;
        $sizes: 24 32 40 48 56 64;
        $paddings: 2px 8px, 2px 16px, 6px 18px, 10px 26px, 10px 28px, 14px 32px,  14px 40px;
        $roundedPaddings: 2px 6px 10px 14px 18px 18px;
        $fontSize: 8px 10px 12px 14px 16px 18px;

        @mixin buttonSize($root, $size) {
            $i: index($sizes, $size);
            &-#{nth($sizeNames, $i)} {
                padding: #{nth($paddings, $i)};

                height: #{$size}px;
                min-height: #{$size}px;
                min-width: #{$size}px;
                font-size: #{nth($fontSize, $i)};

                &#{$root}--rounded {
                    padding: #{$roundedPaddings};
                }
                &#{$root}--align-left{
                    padding-left: #{ ($size - 16 )/2}px;
                }
            }
        }
        @each $size in $sizes{
            @include buttonSize($root, $size);
        }
    }
    @include media('','xsm'){
        height: auto;
    }


    &--type {
        @mixin theme($textColor, $bgColor, $hoverColor, $hoverBorderColor: transparent) {
            &,
            &:focus {
                background-color: $bgColor;
                color: $textColor;
                &:after {
                    border-color: $bgColor;
                }
            }
            &:focus {
              border-color: $hoverBorderColor;
            }
            &:hover {
                color: $textColor;
                border-color: $hoverBorderColor;
                transition: border-color .1s ease-in-out;
                background-color: $hoverColor;
            }
            &.one-ui-button--active {
                background-color: $hoverColor;
                box-shadow: inset 0px 1px 1px rgba(181, 175, 175, 0.25);
            }
        }
        &-primary {
            @include theme(color(white, 1), color(dark, 0),color(dark, 3));
        }
        &-primary-green {
            color: color(dark,0);
            transform: translate3d(0, 0, 0);
            box-shadow: 0px 2px 2px 0px hsla(0, 0%, 0%, 0.25);
            background: color(teal);
            transition: box-shadow .3s ease-out, transform .3s ease-out, background-position .5s ;
            &:hover{
                background: color(white);
                box-shadow: 0px 2px 2px 0px hsla(0, 0%, 0%, 0.25) inset;
            }

        }
        &-primary-white{
            @include theme(color(dark), color(white),color(white));
          &-border-grey-3 {
            @include theme(color(dark), color(white),color(white), color(grey, 3));
            border: 1px solid color(grey, 5);
          }
        }

        &-white {
          @include theme(color(dark), color(white),color(white));
          &-border-grey-3 {
            box-shadow: none;
            @include theme(color(dark), color(white),color(white), color(dark, 4, 1));
            border: 1px solid color(grey, 5);
          }
        }
        &-secondary {
            @include theme(color(dark, 0), color(white), color(grey, 1, 0.7));
/*            @at-root .one-ui-wrapper--frame-solid-dark > & {
                @include theme(color(white), color(dark,2),color(dark,3));
            }*/
            &:hover {
                box-shadow: 0px 2px 2px color(dark, 1, .25), inset 0px 2px 2px color(dark, 1, .25);
            }
        }
        &-dark {
            @include theme(color(white), color(dark,1),color(dark,2))
        }
        &-transparent-black {
            @include theme(color(white), transparent,color(dark,2));
            @include transparentSetting();
        }
        &-transparent-grey {
            @include theme(color(dark, 0), transparent,color(grey));
            @include transparentSetting();
        }

        &-transparent-white {
            @include theme(color(dark, 0), transparent,color(white));
            @include transparentSetting();
            &-border-grey-3 {
              @include theme(color(dark, 0), transparent,transparent);
              @include transparentSetting();
              border: 1px solid color(grey, 3);
            }
        }

      &-transparent-transparent {
        @include theme(color(dark, 0), transparent,transparent);
        @include transparentSetting();
        &-border-grey-3 {
          @include theme(color(dark, 0), transparent,transparent);
          @include transparentSetting();
          border: 1px solid color(grey, 3);
        }
      }

        &-violet {
            @include theme(color(white, 1), color(violet, 1),color(violet, 1, 0.7));
        }
        &-alert {
            @include theme(color(white), color(red),color(red,2))
        }
        //&-line {
        //    background-color: transparent;
        //    color: color(dark)!important;
        //    border: 1px solid color(gray, 2)!important;
        //
        //    &:hover,
        //    &:focus {
        //        background-color: $gray_color;
        //    }
        //}
    }

    @include setColor();

    &--rounded {
        border-radius: 100px;
    }
    &--bold{
        @include font(bold)
    }
    &--uppercase{
        text-transform: uppercase;
        letter-spacing: .5px;
    }

    &--disableBorderRadius{
        border-radius: 0;
    }

    &--squareBorderRadius {
        border-radius: 5px;
    }

    &--fullWidth {
        width: 100%;
    }

    &--noContent{
        padding-left: 0;
        padding-right: 0;
        .one-ui-icon {
            margin-right: 0;
        }
    }

    &--disabled {
        opacity: .5;
        cursor: not-allowed;
        pointer-events: none;
        user-select: none;
    }
}
