/*
 * Copyright (c) 2019-present Sonatype, Inc.
 * This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License 2.0 which accompanies this
 * distribution and is available at https://www.eclipse.org/legal/epl-2.0/.
 */
@use '../../scss-shared/nx-focus-border-helpers';
@use '../../scss-shared/nx-radio-checkbox-helpers';

$-height: 16px;
$-width: 16px;

.nx-checkbox {
  min-width: $-width;
}

.nx-checkbox__box {
  align-items: center;
  border-radius: 2px;
  box-sizing: border-box;
  display: inline-flex;
  height: $-height;
  justify-content: center;
  width: $-width;

  // Pseudo-element style is for the focus border
  &::after {
    @include nx-focus-border-helpers.radio-checkbox-focus-border($-height, $-width);
    border-radius: 4px;
  }

  .fa-check {
    color: var(--nx-color-component-background);
    font-size: var(--nx-font-size-s);
  }
}

.nx-checkbox__input {
  &:checked {
    + .nx-checkbox__box {
      background-color: var(--nx-color-radio-checkbox-selected);

      &, &:hover {
        @include nx-radio-checkbox-helpers.inset-box-shadow(var(--nx-color-radio-checkbox-selected));
      }
    }
  }

  &:disabled {
    &, &:hover {
      + .nx-checkbox__box {
        @include nx-radio-checkbox-helpers.inset-box-shadow(var(--nx-color-checkbox-disabled-inner-border));
        background-color: var(--nx-color-checkbox-disabled-background);

        .fa-check {
          color: var(--nx-color-checkbox-disabled-icon);
        }
      }
    }
  }
}
