@use "../../scss/globals.scss";

.checkbox-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: globals.$spacing-unit;
  cursor: pointer;

  &:has(input:disabled) {
    cursor: not-allowed;
    opacity: globals.$disabled-opacity;
  }

  &__checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    border-radius: 4px;
    background-color: globals.$dark-background-color;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition:
      border-color 0.2s ease,
      background-color 0.2s ease,
      color 0.2s ease;
    border: solid 1px globals.$border-color;
    color: globals.$body-color;

    &:hover:not(:has(input:disabled)) {
      border-color: rgba(255, 255, 255, 0.5);
    }

    &.checked {
      background-color: #ffffff;
      border-color: #ffffff;
      color: globals.$dark-background-color;
    }

    &:has(.checkbox-field__input:focus-visible) {
      outline: 2px solid var(--color-primary);
      outline-offset: 1px;
    }
  }

  &__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.65);
    transition:
      opacity 0.2s ease,
      transform 0.2s ease;

    &.checked {
      opacity: 1;
      transform: scale(1);
    }
  }

  &__input {
    width: 100%;
    height: 100%;
    position: absolute;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;

    &:disabled {
      cursor: not-allowed;
    }
  }

  &__label {
    cursor: pointer;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;

    &:has(+ input:disabled) {
      cursor: not-allowed;
    }
  }
}
