﻿$baseFontSize: 16;
@function rem($val) {
  @return #{$val / $baseFontSize}rem;
}

.input__base.checkbox-input {
  display: block;
  border: none;
  .checkbox-input__checkbox__wrapper {
    display: flex;
    flex-wrap: nowrap;
  }
  &.validation__error {
    border: none !important;
  }
  &.checkbox-input--with-label {
    input {
      margin-right: 0.5rem;
    }
  }
  .checkbox-input__label {
    flex: 1;
    left: 0;
    display: flex;
    align-items: center;
    > input {
      margin-left: 5px;
    }
  }
  &.checkbox-input--disabled {
    input::after,
    label,
    input::before {
      cursor: not-allowed;
    }
  }
  > input {
    margin-left: 3px;
  }
  input {
    position: relative;
    padding: 10px 10px 5px 5px;
    color: $input-text-color;
    &:focus {
      outline: 0;
    }
    &:focus-visible {
      outline: 1px dotted;
      outline: 5px auto -webkit-focus-ring-color;
    }
    border: none;
    width: auto;
    top: 0;
    &:before {
      transition: transform 0.4s cubic-bezier(0.45, 1.8, 0.5, 0.75);
      transform: rotate(-45deg) scale(0, 0);
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      z-index: 1;
      width: rem(14);
      height: rem(7);
      border: 2px solid $primary-color;
      border-top-style: none;
      border-right-style: none;
      pointer-events: none;
    }

    &:checked {
      &:before {
        transform: rotate(-45deg) scale(1, 1);
      }
    }
    &:indeterminate {
      &:before {
        border-left-style: none;
        transform: rotate(0deg) scale(0.8, 1.2) translateX(0);
      }
    }
    &:after {
      content: '';
      position: absolute;
      top: -3px;
      left: -3px;
      width: 1.2rem;
      height: 1.2rem;
      background: #fff;
      border-radius: 2px;
      border: 2px solid $input-border-color;
      cursor: pointer;
      transition: 0.5s ease border-color;
    }

    &:focus {
      &:after {
        outline: 0;
      }
    }
    &:focus-visible {
      &:after {
        outline: 1px dotted;
        outline: 5px auto -webkit-focus-ring-color;
      }
    }
  }
  &.validation__error {
    input:after {
      border: 2px solid $input-validation-error-border-color;
    }
  }
  label {
    top: 0;
    user-select: none; // margin-bottom: 4px;
    pointer-events: auto;
    position: relative;
    display: inline-block;
    cursor: pointer;
  }
}
