@import "../mixins/mixins";

/* buttons sytle guide */
input[type="submit"],
input[type="reset"],
input[type="button"] {
  &.btn-block {
    width: 100%;
  }
}
// anchor button style
a.sb-btn {
  text-align: center;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.sb-btn {
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  outline: 0;
  display: inline-block;
  border: 1px solid;
  // color: $white-color;
  cursor: pointer;
  min-width: ($base-block-space * 8);
  @include border-radius(0.125rem);
  position: relative;
  line-height: 1.15;
  text: {
    transform: capitalize;
    decoration: none;
  }
  &:hover {
    opacity: 1;
  }
  &:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 3px;
    background: $primary-600;
    opacity: 0;
    border-radius: 50%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
  }
  &.flat {
    border-radius: 0;
  }
  &.sb-btn-radius {
    border-radius: 2rem;
  }
}
// Create button color classess from the below list
// btnname basecolor hovercolor outlinecolor
$btns: "gray" var(--gray-200) var(--gray-400) var(--gray-100),
  "primary" var(--primary-400) var(--primary-800) var(--primary-100),
  "secondary" var(--secondary-200) var(--secondary-400) var(--secondary-0),
  "tertiary" var(--tertiary-100) var(--tertiary-400) var(--tertiary-0),
  "red" var(--red-100) var(--red-400) var(--red-0),
  "info" var(--primary-400) var(--primary-800) var(--primary-100),
  "success" var(--secondary-200) var(--secondary-400) var(--secondary-100),
  "warning" var(--tertiary-100) var(--tertiary-400) var(--tertiary-0),
  "error" var(--red-100) var(--red-400) var(--red-0);
@each $btn in $btns {
  $btntypes: btn btn-outline btn-dashed btn-link btn-square;

  @each $btntype in $btntypes {
    .sb-#{nth($btntype, 1)}-#{nth($btn, 1)} {
      @if $btntype == btn {
        background-color: #{nth($btn, 2)};
        border-color: #{nth($btn, 2)};
        color: var(--white);
        &:hover,
        &:active,
        &.active {
          background-color: #{nth($btn, 3)};
          border: 1px solid transparent;
          color: var(--white);
        }
      } @else if $btntype == btn-outline {
        background-color: var(--white);
        color: #{nth($btn, 2)};
        border-color: #{nth($btn, 2)};
        &:hover,
        &:active,
        &.active {
          color: #{nth($btn, 3)};
          background-color: #{nth($btn, 4)};
        }
      } @else if $btntype == btn-link {
        background: none;
        border: 0px;
        color: #{nth($btn, 2)};
        &:hover,
        &:active,
        &.active {
          background-color: #{nth($btn, 4)};
        }
      } @else if $btntype == btn-dashed {
        border-style: dashed;
        border-width: 1px;
        background-color: #fff;
        border-color: #{nth($btn, 2)};
        color: #{nth($btn, 2)};
        &:hover,
        &:active,
        &.active {
          background-color: #{nth($btn, 4)};
        }
      }
    }
  }
}
// Create button sizes classess from the below list
// class height padding fontsize width
$btnsizes: "xs" 1.5rem "0.25rem 0.5rem" 0.75rem null,
  "normal" 2rem "0.5rem 1rem" 0.75rem null, "sm" 2.5rem "0.5rem 1rem" 1rem null,
  "md" 3rem "0.5rem 1rem" 1remrem null, "lg" 3.5rem "1rem 1.5rem" 1.25rem null,
  "full" 1.5rem "0.5rem 1rem" 1.25rem 100%;
@each $btn in $btnsizes {
  .sb-btn-#{nth($btn, 1)} {
    height: #{nth($btn, 2)};
    padding: #{nth($btn, 3)};
    font-size: #{nth($btn, 4)};
    width: #{nth($btn, 5)};
  }
}
// Create button square classess from the below list
// class height width fontsize padding
$btnSquaresizes: "xs" 1.5rem 1.5rem 1rem null, "normal" 4rem 4rem 0.75rem null,
  "sm" 3rem 3rem 0.75rem null, "md" 4rem 4rem 1rem null,
  "lg" 8rem 8rem 1.25rem null;
@each $btn in $btnSquaresizes {
  .sb-btn-square {
    &.sb-btn-#{nth($btn, 1)} {
      height: #{nth($btn, 2)};
      width: #{nth($btn, 3)};
      font-size: #{nth($btn, 4)};
      //width: #{nth($btn, 5)};
      i.icon {
        margin: 0 0 0 0;
        font-size: 2em;
      }
      span {
        margin: 0.5rem 0 0 0;
      }
    }
  }
}
.sb-btn-white {
  box-shadow: 0 calculateRem(-1px) calculateRem(4px) 0 rgba(0, 0, 0, 0.1),
    0 3px 4px 0 rgba(0, 0, 0, 0.2);
  border: 0px solid #ddd;
}
.sb-btn-square {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  font-size: 0.75rem;
  padding: 0.5rem;
}
.sb-btn-disabled {
  background-color: var(--gray-100);
  border: 1px solid var(--gray-100);
  color: var(--gray-200);
  cursor: default;
}
.sb-btn-outline-disabled {
  background-color: var(--white);
  border: 1px solid var(--gray-100);
  color: var(--gray-200);
  cursor: default;
  font-weight: normal;
}
// button link
.sb-btn-link {
  background: none;
  border: 0;
  &:hover {
    // font-weight: $font-weight-bold;
  }
}

.sb-btn-download {
  transition: all 1.2s ease-in-out;
  i::after {
    content: "\f019";
    font-size: calculateRem(13px);
    color: var(--white);
  }
  &:hover {
    animation: pulse 0.2s 2 both;
  }
  &.loading {
    i {
      animation: loading 2s infinite linear;
      &::after {
        content: "\f1ce";
      }
    }
  }
  &.success {
    i::after {
      content: "\f00c";
      color: transparent;
      animation: change-icon 1s 0.6s linear both;
    }
  }
}

// Buttons with icon
.sb-right-icon-btn {
  padding: $base-block-space $base-block-space $base-block-space
    $base-block-space;
  i.icon {
    margin-left: $base-block-space;
    margin-right: 0;
  }
  html[dir="rtl"] & {
    padding: $base-block-space $base-block-space $base-block-space
      $base-block-space;
    i.icon {
      margin-right: ($base-block-space / 2);
      margin-right: 0;
    }
  }
}
.sb-left-icon-btn {
  padding: $base-block-space $base-block-space $base-block-space
    $base-block-space;
  i.icon {
    margin-right: $base-block-space;
  }
  html[dir="rtl"] & {
    padding: $base-block-space $base-block-space $base-block-space
      $base-block-space;
    i.icon {
      margin-left: $base-block-space;
    }
  }
}
.sb-left-icon-btn.sb-btn-xs {
  padding: ($base-block-space * 0) ($base-block-space * 1)
    ($base-block-space * 0) ($base-block-space * 1);
}
//Buttons toggle
.ui.toggle.checkbox.sb-toggle {
  min-height: ($base-block-space * 3);
  position: relative;
  display: inline-block;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  outline: 0;
  vertical-align: baseline;
  font-style: normal;
  min-height: ($base-block-space * 2);
  font-size: 1rem;
  min-width: ($base-block-space * 2);
  input {
    width: ($base-block-space * 8);
    height: ($base-block-space * 3);
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    outline: 0;
    z-index: 3;
    &:focus:checked ~ label:before,
    &:focus:checked ~ .box:before,
    &:checked ~ .box:before,
    &:checked ~ label:before {
      background-color: #024f9d !important;
    }
  }
  label {
    min-height: ($base-block-space * 2);
    padding-left: ($base-block-space * 9);
    color: rgba(0, 0, 0, 0.87);
    position: relative;
    display: block;
    outline: 0;
    font-size: 1rem;
    &:before {
      display: block;
      position: absolute;
      content: "";
      z-index: 1;
      transform: none;
      border: none;
      top: 1px;
      left: 0;
      background: rgba(0, 0, 0, 0.05);
      box-shadow: none;
      width: ($base-block-space * 8);
      height: ($base-block-space * 3);
      border-radius: 500rem;
      @include btn-theme($primary-color);
      transition: border 0.1s ease, opacity 0.1s ease, transform 0.1s ease,
        box-shadow 0.1s ease, -webkit-transform 0.1s ease;
    }
    &:after {
      background: var(--white) linear-gradient(transparent, rgba(0, 0, 0, 0.05));
      position: absolute;
      content: "" !important;
      opacity: 1;
      z-index: 2;
      border: none;
      width: (($base-block-space * 3) - 4);
      height: (($base-block-space * 3) - 4);
      top: 3px;
      left: 0;
      border-radius: 500rem;
      -webkit-transition: background 0.3s ease, left 0.3s ease;
      transition: background 0.3s ease, left 0.3s ease;
    }
  }
  input ~ label:after {
    left: 0.1rem;
    box-shadow: none;
  }
  input:checked ~ label:after {
    left: calculateRem(41px);
    box-shadow: none;
  }
}
// button groups
.btn-group {
  border: $sb-btn-group-border-width solid $sb-btn-group-border-color;
  display: inline-flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  flex-direction: row;
  flex-direction: row;
  font-size: 0;
  vertical-align: baseline;
  .sb-btn {
    background: $sb-btn-group-btn-background;
    border-left: $sb-btn-group-border-width solid $sb-btn-group-border-color;
    flex: 1 0 auto;
    margin: 0;
    border-radius: 0;
    margin: 0;
    border: 0;
    color: $sb-btn-group-btn-color;
    min-width: ($base-block-space * 5);
    &:first-child {
      border-left: none;
      margin-left: 0;
    }
    &:active,
    &.active {
      background-color: $sb-btn-group-btn-active-background-color;
      color: $sb-btn-group-btn-color;
    }
    .icon {
      margin: 0;
      vertical-align: top;
    }
  }
}

.sb-btn-loading-spinner {
  padding: ($base-block-space * 1) ($base-block-space * 2)
    ($base-block-space * 1) ($base-block-space * 1);
}

@keyframes spinner-border {
  to {
    transform: rotate(360deg);
  }
}

.sb-loading-spinner {
  width: 1rem;
  height: 1rem;
  margin-right: 8px;
  border-width: 0.2em;
  display: inline-block;
  vertical-align: text-bottom;
  border: 0.15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  -webkit-animation: spinner-border 0.75s linear infinite;
  animation: spinner-border 0.75s linear infinite;
}

.sb-btn-loading:before {
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  margin: -0.64285714em 0 0 -0.64285714em;
  width: 1.28571429em;
  height: 1.28571429em;
  border-radius: 500rem;
  border: 0.2em solid rgba(0, 0, 0, 0.15);
}

.sb-btn-loading:after {
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  margin: -0.64285714em 0 0 -0.64285714em;
  width: 1.28571429em;
  height: 1.28571429em;
  -webkit-animation: button-spin 0.6s linear;
  animation: button-spin 0.6s linear;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  border-radius: 500rem;
  border-color: #fff transparent transparent;
  border-style: solid;
  border-width: 0.2em;
  -webkit-box-shadow: 0 0 0 1px transparent;
  box-shadow: 0 0 0 1px transparent;
}
/*Create ripple effec*/
.ripple {
  position: relative;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}
.ripple:after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}
.ripple:active:after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

//download button animation
.sb-btn-download {
  transition: all 1.2s ease-in-out;
  i::after {
    content: "\f019";
    font-size: 13px;
    color: #fff;
  }
  &:hover {
    animation: pulse 0.2s 2 both;
  }
  &.loading {
    i {
      animation: loading 2s infinite linear;
      &::after {
        content: "\f1ce";
      }
    }
  }
  &.success {
    i::after {
      content: "\f00c";
      color: transparent;
      animation: change-icon 1s 0.6s linear both;
    }
  }
}

@keyframes loading {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(359deg);
    transform: rotate(359deg);
  }
}

@keyframes change-icon {
  0% {
    color: transparent;
  }
  100% {
    color: #fff;
  }
}

@keyframes pulse {
  from {
    transform: scale3d(1, 1, 1);
  }
  50% {
    transform: scale3d(1.05, 1.05, 1.05);
  }
  to {
    transform: scale3d(1, 1, 1);
  }
}

*[lang="hi"] .sb-btn-xs {
  line-height: 1.5;
}

*[lang="hi"] .sb-btn-normal {
  line-height: 1.5;
}
.sb-btn-orange-link{
    background-color: var(--tertiary-400);
    border-color: var(--tertiary-400);
    border: none !important;
    border-radius: 0 !important;
    &:hover{
      background-color: var(--tertiary-400) !important;
      border-color: var(--tertiary-400) !important; 
    }
}
.sb-btn-dark-green{
  background: var(--green);
  border:solid 1px green !important;
  color: var(--white);
}
.sb-btn{
  &:focus{
    outline: 0 !important;
  }
}