@import '../../style/themes/index';
@import '../../style/mixins/index';
@import './mixin';

@yee-btn-prefix-cls: ~'@{yee-prefix}-btn';

// for compatible
@yee-btn-ghost-color: @yee-text-color;
@yee-btn-ghost-bg: transparent;
@yee-btn-ghost-border: @yee-border-color-base;

// Button styles
// -----------------------------
.@{yee-btn-prefix-cls} {
  // Fixing https://github.com/ant-design/ant-design/issues/12978
  // Fixing https://github.com/ant-design/ant-design/issues/20058
  // Fixing https://github.com/ant-design/ant-design/issues/19972
  // Fixing https://github.com/ant-design/ant-design/issues/12978
  // Fixing https://github.com/ant-design/ant-design/issues/18107
  // Fixing https://github.com/ant-design/ant-design/issues/13214
  // It is a render problem of chrome, which is only happened in the codesandbox demo
  // 0.001px solution works and I don't why
  line-height: @yee-line-height-base - 0.001;
  .yee-btn;
  .yee-btn-default;

  // Make sure that the target of Button's click event always be `button`
  // Ref: https://github.com/ant-design/ant-design/issues/7034
  > i,
  > span {
    display: inline-block;
    transition: margin-left 0.3s @yee-ease-in-out;
    pointer-events: none;
  }

  &-primary {
    .yee-btn-primary;

    .@{yee-btn-prefix-cls}-group &:not(:first-child):not(:last-child) {
      border-right-color: @yee-btn-group-border;
      border-left-color: @yee-btn-group-border;

      &:disabled {
        border-color: @yee-btn-default-border;
      }
    }

    .@{yee-btn-prefix-cls}-group &:first-child {
      &:not(:last-child) {
        border-right-color: @yee-btn-group-border;
        &[disabled] {
          border-right-color: @yee-btn-default-border;
        }
      }
    }

    .@{yee-btn-prefix-cls}-group &:last-child:not(:first-child),
    .@{yee-btn-prefix-cls}-group & + & {
      border-left-color: @yee-btn-group-border;
      &[disabled] {
        border-left-color: @yee-btn-default-border;
      }
    }
  }

  &-ghost {
    .yee-btn-ghost;
  }

  &-dashed {
    .yee-btn-dashed;
  }

  &-danger {
    .yee-btn-danger;
  }

  &-link {
    .yee-btn-link;
  }

  &-icon-only {
    .yee-btn-square(@yee-btn-prefix-cls);

    > i {
      vertical-align: middle;
    }
  }

  &-round {
    .yee-btn-round(@yee-btn-prefix-cls);
    &.@{yee-btn-prefix-cls}-icon-only {
      width: auto;
    }
  }

  &-circle,
  &-circle-outline {
    .yee-btn-circle(@yee-btn-prefix-cls);
  }

  &::before {
    position: absolute;
    top: -1px;
    right: -1px;
    bottom: -1px;
    left: -1px;
    z-index: 1;
    display: none;
    background: @yee-component-background;
    border-radius: inherit;
    opacity: 0.35;
    transition: opacity 0.2s;
    content: '';
    pointer-events: none;
  }

  .@{yee-iconfont-css-prefix} {
    transition: margin-left 0.3s @yee-ease-in-out;

    // Follow icon blur under windows. Change the render.
    // https://github.com/ant-design/ant-design/issues/13924
    &.@{yee-iconfont-css-prefix}-plus,
    &.@{yee-iconfont-css-prefix}-minus {
      > svg {
        shape-rendering: optimizeSpeed;
      }
    }
  }

  &&-loading {
    position: relative;
    &:not([disabled]) {
      pointer-events: none;
    }
  }

  &&-loading::before {
    display: block;
  }

  &&-loading:not(&-circle):not(&-circle-outline):not(&-icon-only) {
    padding-left: 29px;
    .@{yee-iconfont-css-prefix}:not(:last-child) {
      margin-left: -14px;
    }
  }

  &-sm&-loading:not(&-circle):not(&-circle-outline):not(&-icon-only) {
    padding-left: 24px;
    .@{yee-iconfont-css-prefix} {
      margin-left: -17px;
    }
  }

  &-group {
    .yee-btn-group(@yee-btn-prefix-cls);
  }

  // http://stackoverflow.com/a/21281554/3040605
  &:focus > span,
  &:active > span {
    position: relative;
  }

  // To ensure that a space will be placed between character and `Icon`.
  > .@{yee-iconfont-css-prefix} + span,
  > span + .@{yee-iconfont-css-prefix} {
    margin-left: 8px;
  }

  &-background-ghost {
    color: @yee-component-background;
    background: transparent !important;
    border-color: @yee-component-background;
  }

  &-background-ghost&-primary {
    .yee-button-variant-ghost(@yee-btn-primary-bg);
  }

  &-background-ghost&-danger {
    .yee-button-variant-ghost(@yee-btn-danger-border);
  }

  &-background-ghost&-link {
    .yee-button-variant-ghost(@yee-link-color; transparent);

    color: @yee-component-background;
  }

  &-two-chinese-chars::first-letter {
    letter-spacing: 0.34em;
  }

  &-two-chinese-chars > *:not(.@{yee-iconfont-css-prefix}) {
    margin-right: -0.34em;
    letter-spacing: 0.34em;
  }

  &-block {
    width: 100%;
  }

  // https://github.com/ant-design/ant-design/issues/12681
  &:empty {
    vertical-align: top;
  }
}

a.@{yee-btn-prefix-cls} {
  // Fixing https://github.com/ant-design/ant-design/issues/12978
  // It is a render problem of chrome, which is only happened in the codesandbox demo
  // 0.1px for padding-top solution works and I don't why
  padding-top: 0.1px;
  line-height: @yee-btn-height-base - 2px;

  &-lg {
    line-height: @yee-btn-height-lg - 2px;
  }
  &-sm {
    line-height: @yee-btn-height-sm - 2px;
  }
}
