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

@import './_var.less';

.@{checkbox} {
  display: inline-flex;
  vertical-align: middle;
  position: relative;
  background: @checkbox-bg-color;

  &:focus {
    outline: 0;
  }

  &--block {
    display: flex;
    padding: @checkbox-vertical-padding;
  }

  &--horizontal {
    padding: 0;
    margin-right: @spacer-2;
  }

  &--right {
    flex-direction: row-reverse;
  }

  .limit-title-row {
    /* stylelint-disable-next-line */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .image-center {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }

  &__icon-wrapper {
    display: block;
  }

  &__icon-left {
    margin-right: 20px;
    width: 20px;
  }

  &__icon-right {
    right: 0;
    display: contents;
    .image-center();
  }

  &__icon-image {
    width: @checkbox-icon-size;
    height: @checkbox-icon-size;
    vertical-align: top;
  }

  &__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: @checkbox-icon-size;
    height: @checkbox-icon-size;

    &:empty {
      display: none;
    }

    &--checked {
      color: @checkbox-icon-checked-color;
    }

    &--disabled {
      cursor: not-allowed;
      color: @checkbox-icon-disabled-color;
    }

    &--left {
      margin-right: @spacer;
    }

    &-circle,
    &-rectangle {
      display: flex;
      align-items: center;
      justify-content: center;
      width: @checkbox-icon-size;
      height: @checkbox-icon-size;
      color: @checkbox-icon-color;
      font-size: calc(@checkbox-icon-size - 8px);
      border: @checkbox-border-width solid @checkbox-border-color;
      box-sizing: border-box;

      &--checked {
        background: @checkbox-icon-checked-color;
        border-color: @checkbox-icon-checked-color;
      }

      &--disabled {
        background: @checkbox-icon-disabled-bg-color;
      }

      &--checked&--disabled {
        background: @checkbox-icon-disabled-color;
        border-color: @checkbox-icon-disabled-color;
      }
    }

    &-circle {
      width: calc(@checkbox-icon-size - 2px);
      height: calc(@checkbox-icon-size - 2px);
      border-radius: 50%;
    }

    &-rectangle {
      width: calc(@checkbox-icon-size - 4px);
      height: calc(@checkbox-icon-size - 4px);
    }

    &-line {
      display: flex;
      align-items: center;
      justify-content: center;
      width: @checkbox-icon-size;
      height: @checkbox-icon-size;
      color: @checkbox-icon-checked-color;
      font-size: @checkbox-icon-size;

      &--disabled {
        color: @checkbox-icon-disabled-color;
      }
    }
  }

  &__content {
    flex: 1;
  }

  &__title {
    color: @checkbox-title-color;
    font: @checkbox-title-font;
    line-height: @checkbox-title-line-height;

    .limit-title-row();

    &--disabled {
      color: @checkbox-title-disabled-color;
    }
  }

  &__description {
    color: @checkbox-description-color;
    .limit-title-row();

    font: @checkbox-description-font;

    &--disabled {
      color: @checkbox-description-disabled-color;
    }
  }

  &__title + &__description:not(:empty) {
    margin-top: calc(@spacer / 2);
  }

  &__border {
    position: absolute;
    bottom: 0;
    left: @spacer-5;
    right: 0;
    height: 1px;
    background: @checkbox-border-color;
    transform: scaleY(0.5);

    &--right {
      left: @spacer-2;
    }
  }

  // theme = tag 启用
  &--tag {
    font: @font-body-medium;
    padding-top: @spacer;
    padding-bottom: @spacer;
    text-align: center;
    background-color: @checkbox-tag-bg-color;
    border-radius: @radius-default;

    &.@{checkbox}--checked {
      color: @checkbox-tag-active-color;
      background-color: @checkbox-tag-active-bg-color;
    }

    .@{checkbox}__title--checked {
      color: @checkbox-tag-active-color;
    }

    .@{checkbox}__content {
      margin-right: 0;
    }
  }
}
