$rct-icon-font-family: // stylelint-disable-line scss/dollar-variable-colon-space-after
  "Font Awesome 6 Free", "Font Awesome 5 Free", "FontAwesome", sans-serif;
$rct-icon-color: #33c !default;
$rct-label-hover: rgba($rct-icon-color, 0.1) !default;
$rct-label-active: rgba($rct-icon-color, 0.15) !default;
$rct-clickable-hover: rgba($rct-icon-color, 0.1) !default;
$rct-clickable-focus: rgba($rct-icon-color, 0.2) !default;
$rct-checkbox-outline-offset: 2px !default;
$rct-outline-color: rgba($rct-icon-color, 0.5) !default;
$rct-outline-radius: 2px;
$rct-outline-size: 2px !default;
$rct-outline-offset: -2px !default;

.react-checkbox-tree {
  display: flex;
  flex-direction: row-reverse;
  font-size: 16px;

  > ol {
    flex: 1 1 auto;
  }

  ol {
    padding-left: 0;
    margin: 0;
    list-style-type: none;

    ol {
      padding-left: 24px;
    }
  }

  button,
  input {
    &:focus {
      outline: $rct-outline-size solid $rct-outline-color;
      border-radius: $rct-outline-radius;
    }

    &:not(:focus-visible) {
      outline: none;
    }
  }

  button {
    line-height: normal;
    color: inherit;

    &:disabled {
      cursor: not-allowed;
    }

    &:focus {
      outline-offset: $rct-outline-offset;
    }
  }

  .rct-bare-label {
    cursor: default;
  }

  label {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    cursor: pointer;

    &:hover {
      background: $rct-label-hover;
    }

    &:active,
    &:focus {
      background: $rct-label-active;
    }
  }

  input {
    margin: 0 5px;
    cursor: pointer;

    &:focus {
      outline-offset: $rct-checkbox-outline-offset;
    }
  }

  &:not(.rct-native-display) input {
    // Hide the native checkbox (but keep in accessibility tree and accessible via touch)
    position: absolute;
    opacity: 0;

    // Show focus effect on pseudo-checkbox
    &:focus {
      + .rct-checkbox {
        outline: $rct-outline-size solid $rct-outline-color;
        outline-offset: $rct-outline-offset;
        border-radius: $rct-outline-radius;
      }

      &:not(:focus-visible) + .rct-checkbox {
        outline: none;
      }
    }
  }

  .rct-icon {
    display: inline-block;
    font-family: $rct-icon-font-family;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-align: center;
    text-rendering: auto;
  }
}

.rct-disabled > .rct-text > label {
  cursor: not-allowed;
  opacity: 0.75;

  &:hover {
    background: transparent;
  }

  &:active {
    background: transparent;
  }
}

.rct-text {
  display: flex;
  align-items: center;
}

.rct-actions {
  flex: 0 0 auto;
  margin-left: 0.5rem;
  text-align: right;
}

.rct-action {
  padding: 0 4px;
  font-size: 18px;
  cursor: pointer;
  background: none;
  border: 0;
  opacity: 0.75;

  &:hover {
    opacity: 1;
  }
}

.rct-collapse,
.rct-checkbox,
.rct-node-icon {
  padding: 0 5px;

  * {
    display: inline-block;
    width: 14px;
    margin: 0;
  }
}

.rct-collapse {
  align-self: stretch;
  font-size: 12px;
  line-height: normal;
  color: inherit;
  background: none;
  border: 0;

  &.rct-collapse-btn {
    cursor: pointer;
  }

  > .rct-icon-expand-close {
    opacity: 0.5;

    &:hover {
      opacity: 1;
    }
  }
}

.rct-native-display .rct-checkbox {
  display: none;
}

.rct-node-clickable {
  cursor: pointer;

  &:hover {
    background: $rct-clickable-hover;
  }

  &:focus {
    outline: 0;
    background: $rct-clickable-focus;
  }
}

.rct-node-icon {
  color: $rct-icon-color;
}

.rct-label {
  padding: 0 5px;
}

// Font Awesome 4 style
.rct-icons-fa4 {
  .rct-icon-expand-close::before {
    content: "\f054";
  }

  .rct-icon-expand-open::before {
    content: "\f078";
  }

  .rct-icon-uncheck::before {
    content: "\f096";
  }

  .rct-icon-check::before {
    content: "\f046";
  }

  .rct-icon-half-check::before {
    content: "\f046";
    opacity: 0.5;
  }

  .rct-icon-leaf::before {
    content: "\f016";
  }

  .rct-icon-parent-open::before {
    content: "\f115";
  }

  .rct-icon-parent-close::before {
    content: "\f114";
  }

  .rct-icon-expand-all::before {
    content: "\f0fe";
  }

  .rct-icon-collapse-all::before {
    content: "\f146";
  }
}

// Font Awesome 5 and 6 styles
.rct-icons-fa5,
.rct-icons-fa6 {
  .rct-icon-expand-close::before {
    font-weight: 900;
    content: "\f054";
  }

  .rct-icon-expand-open::before {
    font-weight: 900;
    content: "\f078";
  }

  .rct-icon-uncheck::before {
    content: "\f0c8";
  }

  .rct-icon-check::before {
    content: "\f14a";
  }

  .rct-icon-half-check::before {
    content: "\f14a";
    opacity: 0.5;
  }

  .rct-icon-leaf::before {
    content: "\f15b";
  }

  .rct-icon-parent-open::before {
    content: "\f07c";
  }

  .rct-icon-parent-close::before {
    content: "\f07b";
  }

  .rct-icon-expand-all::before {
    content: "\f0fe";
  }

  .rct-icon-collapse-all::before {
    content: "\f146";
  }
}

// RTL support
.rct-direction-rtl {
  direction: rtl;

  ol ol {
    padding-right: 24px;
    padding-left: 0;
  }

  &.rct-icons-fa4 .rct-icon-expand-close::before {
    content: "\f105";
  }

  &.rct-icons-fa5 .rct-icon-expand-close::before {
    content: "\f053";
  }
}
