@checkbox-tick: '<svg xmlns="http://www.w3.org/2000/svg" width="9" height="9"><path style="fill: var(--gray)" d="M7.8 .5l.8 1 -5.2 7L.5 4.2l.8-1 2 1.8L7.8 .5z"/></svg>';


.checkbox__real-input {
  height: 0;
  width: 0;
  opacity: 0;
}

//
// Checkbox container
//

.checkbox-wrap {
  display: flex;
  cursor: @button-cursor;
  align-self: flex-start;
  align-items: center;

  .checkbox-wrap__label {
    margin-bottom: 0;
    cursor: inherit;
    color: var(--checkbox-label-text-color);

    &:first-child {
      margin-right: 10px;
    }

    &:last-child {
      margin-left: 10px;
    }
  }
}

.checkbox-wrap--disabled {
  cursor: not-allowed;
}

//
// Normal checkbox
//

.checkbox {
  .size(15px);
  position: relative;
}

.checkbox__input {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--input-background-color);
  border: 1px solid var(--input-checkbox-border);
  border-radius: 3px;
  cursor: inherit;
  transition: border-color 200ms, background-color 200ms;
  left: 0;
  top: 0;
}

.checkbox__real-input:focus + .checkbox__input {
  border-color: @input-border-color-focus;
}

.checkbox--switch .checkbox__real-input:focus + .checkbox__input {
  border-color: rgba(0, 0, 0, 0.2);
}

.checkbox__input--error,
.checkbox__real-input:focus + .checkbox__input--error {
  border-color: @input-border-color-error;
}

.checkbox__input--loading {
  display: none;
}

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

.progress__item--checkbox {
  background: var(--gray);
}

.checkbox__handle:last-child {
  color: var(--input-checkbox-handle);
  position: absolute;
  transition: opacity 200ms, background-color 200ms, transform 400ms @easeInOutBack;
  opacity: 0;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: 9px;
  height: 9px;
}

.checkbox__handle--loading {
  display: none;
}

.checkbox__real-input:checked ~ .checkbox__handle {
  opacity: 1;
}

fieldset[disabled] .checkbox__real-input:checked ~ .checkbox__handle,
.checkbox__real-input:checked[disabled] ~ .checkbox__handle {
  opacity: 0.5;
}

fieldset[disabled] .checkbox__real-input ~ .checkbox__input,
.checkbox__real-input[disabled]  .checkbox__input {
  border-color: @input-border-color-disabled;
  background-color: var(--input-background-disabled);
  cursor: not-allowed;
}


//
// Switch
//

.checkbox--switch {
  .size(40px, 22px);
  cursor: pointer;
  z-index: 1;
}

.checkbox--switch .checkbox__input {
  border: @input-switch-border-width solid rgba(0, 0, 0, 0.2);
  background-color: var(--gray-darkest);
  border-radius: 15px;
  transition: background-color 200ms;
}

.checkbox--switch .checkbox__real-input:checked ~ .checkbox__input {
  opacity: 1;
  border: 0;
  background-color: var(--main-color-brand-highlight) !important;
}

.checkbox--switch .checkbox__real-input:checked ~ .checkbox__handle {
  background-color: #fff !important;
  transform: translateX(18px) rotate(90deg);
}

.checkbox--switch .checkbox__handle {
  .size(16px);
  background-color: var(--input-checkbox-switch-handle);
  border-radius: 16px;
  opacity: 1;
  left: 3px;
  top: 3px;
  transform: none;
  cursor: pointer;
  z-index: 20;
  transform-style: preserve-3d;
}

.checkbox--switch .checkbox__handle::after {
  .size(18px);

  content: "";
  position: absolute;
  display: block;
  top: -1px;
  left: -1px;

  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 18px;

  z-index: -10;
  transform: translateZ(-1px);
  cursor: pointer;
}

.checkbox--switch .checkbox__real-input[disabled] ~ .checkbox__handle,
.checkbox--switch .checkbox__real-input:checked[disabled] ~ .checkbox__handle {
  background-color: fade(@input-switch-thumb-off, 40%);
}

.checkbox--switch .checkbox__real-input[disabled] ~ .checkbox__input,
.checkbox--switch .checkbox__real-input:checked[disabled] ~ .checkbox__input {
  opacity: 0.5;
}

.checkbox__input--dark {
  background-color: #171717 !important;
}

.checkbox__handle--dark {
  color: var(--gray);
  background-color: #585858 !important;
}

.checkbox__input--light {
  background-color: #f0f0f0 !important;
}

.checkbox__handle--light {
  color: var(--gray);
  background-color: #fff !important;
}
