@import '../../assets/scss/components/checkbox/variables';

.st-checkbox {
  $root: &;

  display: inline-flex;
  align-content: center;
  align-items: center;
  justify-content: flex-start;
  line-height: 1;
  cursor: pointer;

  &--hovered:not(&--readonly) {
    #{$root}__inner {
      border: $st-border-style $st-checkbox-common-border-width $st-color-dark-gunmetal;
    }
  }

  &__input {
    position: relative;
    line-height: 1;
    white-space: nowrap;
    outline: none;
  }

  &__inner {
    position: relative;
    box-sizing: border-box;
    display: block;
    width: $st-checkbox-width;
    height: $st-checkbox-height;
    border: $st-border-style $st-checkbox-common-border-width $st-checkbox-common-border-color;
    border-radius: $st-checkbox-border-radius;

    &::after {
      position: absolute;
      top: 2px;
      left: 5px;
      box-sizing: content-box;
      width: $st-checkbox-check-mark-width;
      height: $st-checkbox-check-mark-height;
      content: '';
      border: $st-checkbox-check-mark-weight $st-border-style $st-checkbox-check-mark-color;
      border-top: 0;
      border-left: 0;
      transition: $st-checkbox-check-mark-transition;
      transform: rotate(45deg) scaleY(0);
      transform-origin: center;
    }
  }

  &__original-input {
    position: absolute;
    left: 0;
    width: 0;
    height: 0;
    margin: 0;
    outline: none;
    opacity: 0;
  }

  &__label {
    display: inline-block;
    padding: $st-checkbox-label-padding;
    font-size: $st-checkbox-label-font-size;
    transition: $st-checkbox-label-transition;
  }

  &--readonly {
    cursor: default;
  }

  &--checked,
  &--indeterminate {
    #{$root}__inner {
      background-color: $st-checkbox-checked-background-color;
      border-color: $st-checkbox-checked-border-color;

      &::after {
        transform: rotate(45deg) scaleY(1);
      }
    }

    &#{$root}--hovered:not(#{$root}--readonly) {
      #{$root}__inner {
        border-color: $st-checkbox-checked-border-color;
      }
    }
  }

  &--indeterminate {
    #{$root}__inner {
      &::after {
        border-bottom: none;
        transform: rotate(90deg) scaleY(1);
      }
    }
  }

  &--disabled {
    cursor: not-allowed;

    #{$root}__inner {
      background-color: $st-checkbox-disabled-background-color;
      border-color: $st-checkbox-disabled-border-color;
    }

    #{$root}__label {
      color: $st-checkbox-disabled-color;
    }

    &#{$root}:not(#{$root}--readonly) {
      #{$root}__inner {
        border-color: $st-checkbox-disabled-border-color;
      }
    }
  }

  &--disabled#{$root}--checked {
    #{$root}__inner {
      background-color: $st-checkbox-checked-disabled-background-color;
      border-color: $st-checkbox-checked-disabled-border-color;
    }
  }
}
