@import '../styles/base.less';

.rdf-checkbox {
  display: inline-flex;
  align-items: center;
  height: 32px;
  cursor: pointer;

  &__label {
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 14px;
    line-height: 1;
    color: @text-color;
  }

  &__indicator {
    box-sizing: border-box;
    position: relative;
    width: 16px;
    height: 16px;
    border: 1px solid @border-color;
    border-radius: 2px;
    overflow: hidden;
    transition: all 0.4s, border-color 0.2s;
  }

  &__line {
    position: absolute;
    top: 3px;
    left: 2px;
    width: 10px;
    height: 6px;
    border-bottom-left-radius: 1px;
    transform: rotate(-45deg);
    overflow: hidden;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 2px;
      height: 100%;
      background-color: #fff;
      border-radius: 1px;
      transform: scaleY(0);
      transform-origin: top;
      transition: all 0.1s;
      transition-delay: 0.1s;
    }

    &::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 1px;
      right: 0;
      height: 2px;
      background-color: #fff;
      border-radius: 1px;
      transform: scaleX(0);
      transform-origin: left;
      transition: all 0.1s;
    }
  }

  &:not(:last-child) {
    margin-right: 16px;
  }

  &:hover:not(&--disabled) {
    & .rdf-checkbox__indicator {
      border-color: @primary-color;
    }
  }
}

.rdf-checkbox--checked .rdf-checkbox {
  &__indicator {
    border-color: @primary-color;
    background: @primary-color;
    transition-delay: 0s;
  }

  &__line {
    &::before {
      will-change: transform;
      transform: scaleY(1);
      transition-delay: 0s;
    }

    &::after {
      will-change: transform;
      transform: scaleX(1);
      transition-delay: 0.1s;
    }
  }
}

/**
 * disabled
 */
.rdf-checkbox--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rdf-checkbox-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-items: flex-start;
}
