@import '@helsenorge/designsystem-react/scss/palette';

$color-primary-1: #a61e7b;

/******** RESET *********/
input[type='checkbox'].atom_checkbox {
  &__input {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }

  & + label {
    cursor: pointer;
    display: block;
    font-size: 18px;
    font-weight: 400;
    margin: 0;
    word-break: break-word;
    hyphens: auto;
  }
}

.atom_checkbox {
  /******** INPUT *********/
  &__input {
    &:hover,
    &:focus {
      & + .atom_checkbox__label .atom_checkbox__checkicon:not(.atom_checkbox__checkicon--disabled) {
        background-color: $neutral400;
        box-shadow: 0 0 0 2px $neutral400;

        &.atom_checkbox__checkicon--blue {
          border-color: $blueberry700;
        }

        &.atom_checkbox__checkicon--lilla {
          border-color: $color-primary-1;
        }
      }
    }
  }

  /******** ICON *********/
  &__checkicon {
    display: inline-flex;
    flex-shrink: 0;
    vertical-align: middle;
    color: transparent;
    border: 2px solid $neutral500;
    margin-right: 0.75rem;
    margin-top: 0.2rem;
    width: 1.5rem;
    height: 1.5rem;

    &:focus {
      outline: none;
    }
  }

  &__checkicon--blue:not(.atom_checkbox__checkicon--disabled) {
    &.atom_checkbox__checkicon--checked {
      border-color: $blueberry700;
      color: $blueberry700;
    }
  }

  &__checkicon--lilla:not(.atom_checkbox__checkicon--disabled) {
    &.atom_checkbox__checkicon--checked {
      border-color: $color-primary-1;
      color: $color-primary-1;
    }
  }

  &__checkicon--disabled {
    background-color: $neutral200;

    &.atom_checkbox__checkicon--checked {
      color: $neutral500;
    }
  }

  /******** LABEL *********/
  &__labelwrapper {
    display: flex;
    align-items: center;
  }

  &__label,
  input[type='checkbox'] + label.atom_checkbox__label {
    display: inline-flex;
    align-items: center;
    color: $black;
    line-height: 1.5rem;
    padding: 0.625rem 1rem 0.625rem 0;

    &:hover {
      .atom_checkbox__checkicon:not(.atom_checkbox__checkicon--disabled) {
        background-color: $neutral400;
        box-shadow: 0 0 0 2px $neutral400;
      }
    }
  }

  &__label--boxed,
  input[type='checkbox'] + label.atom_checkbox__label--boxed {
    padding: 0.75rem 1rem;
    min-height: 3.125rem;
    background-color: $white;
    box-shadow: 0 0 0 2px $neutral200;

    &:hover,
    &:focus {
      box-shadow: 0 0 0 4px $neutral400;
    }

    &.atom_checkbox__label--checked {
      box-shadow: 0 0 0 2px $blueberry700;
      background-color: $blueberry50;

      &:hover,
      &:focus {
        box-shadow: 0 0 0 4px $blueberry700;
      }
    }
  }

  /******** TEXT *********/
  &__text {
    display: inline-flex;
  }

  &__text--checked {
    font-weight: 600;
  }

  /******** COMMENT *********/
  &__comment {
    display: block;
    margin-left: 1.7rem;
    font-size: 1.125rem;
  }
}
