@import '../../style/theme/index';

$button-prefix-cls: #{$anna-prefix}-btn;

$large-height: 80px;

.#{$button-prefix-cls} {
  position: relative;
  box-sizing: border-box;
  display: inline-block;
  padding: 0 32px;
  background-color: $btn-default-bg;
  height: 64px;
  line-height: 60px;
  border: 1PX solid $btn-default-bg;
  border-radius: 64px;
  color: $brand-color;
  font-weight: 500;
  font-size: 28px;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  touch-action: manipulation;
  -webkit-appearance: none;
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  // 移除浏览器默认样式
  margin: 0;
  outline: 0;
  cursor: pointer;
  // 覆盖微信默认的<overflow: hidden>，<overflow: hidden>隐藏的是border以内的内容，隐藏不包括border
  overflow: unset;
  // 设置点击链接的时候出现的高亮颜色
  // -webkit-tap-highlight-color: unset;
  &:not(&-disabled):active {
    // 由于absolute是相对于border以内的内容，不包括border, 所以要设置-1PX才能把border也罩住。
    .#{$button-prefix-cls}-mask{
      box-sizing: border-box;
      position: absolute;
      top: -1PX;
      right: -1PX;
      bottom: -1PX;
      left: -1PX;
      content: '';
      background-color: rgba(0, 0, 0, 0.5);
      border-radius: inherit;
      pointer-events: none;
      transition: background-color 0.3s;
    }
  }
  &:after {
    display: none;
  }
  &-text {
    font-weight: 500;
    font-size: 28px;
  }
  &-small{
    font-size: 24px;
    padding: 0 24px;
    height: 48px;
    line-height: 44px;
    border-radius: 52px;
  }
  &-large{
    padding: 0 40px;
    height: 80px;
    line-height: 76px;
    border-radius: 80px;
  }
  &-superlarge{
    font-size: 30px;
    height: 84px;
    line-height: 80px;
    border-radius: 84px;
  }
  &-primary{
    border-color: $brand-color;
    background-color: $brand-color;
    color: $light-base;
  }

  // plain
  &-plain{
    font-weight: 400;
    color: #666;
    border: 1PX solid #DDD;
    background-color: $light-base;
  }
  &-plain.#{$button-prefix-cls}-primary{
    border-color: $brand-color;
    color: $brand-color;
  }

  // hairline
  &-hairline{
    line-height: 64px;
    border-width: 0;
    &:before {
      box-sizing: border-box;
      position: absolute;
      top: -50%;
      right: -50%;
      bottom: -50%;
      left: -50%;
      content: '';
      border: 1PX solid #DDD;
      border-color: inherit;
      border-radius: inherit;
      transform: scale(0.5);
      pointer-events: none; // 这样伪类元素可以点击穿透, 也就是能看到, 但是不触发任何默认事件(click等);
    }
  }
  &-small.#{$button-prefix-cls}-hairline{
    line-height: 48px;
  }
  &-large.#{$button-prefix-cls}-hairline{
    line-height: 80px;
  }
  &-superlarge.#{$button-prefix-cls}-hairline{
    line-height: 84px;
  }

  // square
  &-square{
    padding: 0 30px;
    border-radius: 12px;
  }
  &-square.#{$button-prefix-cls}-small {
    padding: 0 14px;
  }
  &-circle{
    padding: 0;
    min-width: 64px;
    border-radius: 50%;
    z-index: 9;
  }
  &-circle.#{$button-prefix-cls}-small{
    min-width: 48px;
  }
  &-circle.#{$button-prefix-cls}-large{
    min-width: 80px;
  }
  &-circle.#{$button-prefix-cls}-superlarge{
    min-width: 84px;
  }
  &-disabled{
    cursor: default;
    opacity: 0.4;
    transition: opacity .2s;
  }
  &-danger-default{
    color: $danger-color;
  }
  &-danger{
    border-color: $danger-color;
    background-color: $danger-color;
    color: $light-base;
  }
  &-look{
    &-secondary{
      color: $brand-color;
      background-color: #ECF5FF;
      border-color: #ECF5FF;
    }
    &-secure{
      color: $light-base;
      background-color: #07C160;
      border-color: #07C160;
    }
    &-warning{
      color: $dark-base;
      background-color: #FFC409;
      border-color: #FFC409;
    }
    &-light{
      color: $dark-base;
      background-color:#F4F5F8;
      border-color: #F4F5F8;
    }
    &-medium{
      color: $light-base;
      background-color: #92949c;
      border-color: #92949c;
    }
    &-dark{
      color: $light-base;
      background-color: #222428;
      border-color: #222428;
    }
    &-anna{
      color: $light-base;
      background-color: #FF7777;
      border-color: #FF7777;
    }
    &-orange{
      color: $light-base;
      background-color: #ff4f00;
      border-color: #ff4f00;
    }
  }
  &-block{
    width: 100%;
  }
  &-float{
    position: fixed;
    box-shadow: 0 6px 24px #CCC;
    // box-shadow: 0 6px 16px -8px rgba(0,0,0,.12), 0 12px 32px 0 rgba(0,0,0,.08), 0 18px 56px 16px rgba(0,0,0,.05);
    &-center{
      left: 50%;
      bottom: 60px;
      transform: translateX(-50%);
    }
    &-left{
      left: 24px;
      bottom: 60px;
    }
    &-right{
      right: 24px;
      bottom: 60px;
    }
  }
  &-loading{
    padding-left: 32px + 36px + 16px;
    transition: padding .3s cubic-bezier(.645,.045,.355,1);
    // 用flex布局使icon和text垂直居中会导致移动端动画不渲染的问题，故改为verticalAlign
    &-icon{ //微信小程序text标签下包含view标签导致loading不显示
      display: inline;
      padding-right: 16px;
      margin-left: -36px - 16px;
    }
  }
  &-ghost{
    border-color: transparent;
    background-color: transparent;
  }
}

.width-fix{
  height: $large-height;
  display: inline-block;
  overflow: hidden;
  .default{
    display: inline-block;
    width: 200%;
    height: 200%;
    font-size: 28px * 2;
    transform: scale(0.5);
    transform-origin: 0 0;
    text-align: center;
  }
  .large{
    line-height: $large-height * 2;
    border-radius: $large-height * 2;
  }
  .primary{
    background-color: $brand-color;
    color: $light-base;
  }
  .disabled{
    opacity: 0.4;
    color: hsla(0,0%,100%,.6) !important;
  }
}
