$border-fill: var(--wds-color-border-dark-secondary, var(--wsr-color-D60, #dfe5eb));
$placeholder-fill: var(--wds-color-black-500, var(--wsr-color-D50, #acafc4));
$list-fill: var(
  --wds-nestable-list-fill,
  var(--wds-color-fill-surface-default, var(--wsr-color-D80, #ffffff))
);

.nestable-list {
  padding: var(--wds-nestable-list-paddings, var(--wds-space-0, 0));
  background-color: $list-fill;

  &#{&}--drag-enabled {
    /* stylelint-disable-next-line plugin/use-baseline */
    user-select: none;
    -webkit-user-select: none;
  }

  &__item-wrapper {
    position: relative;
    /* stylelint-disable-next-line plugin/use-baseline */
    user-select: text;
    -webkit-user-select: text;

    &#{&}--drag-enabled {
      /* stylelint-disable-next-line plugin/use-baseline */
      user-select: none;
      -webkit-user-select: none;
    }
  }

  &__item {
    border: 1px solid $border-fill;
    border-right: none;
    box-sizing: border-box;
    margin-top: -1px;
    width: 100%;

    &#{&}--root#{&}--first-sibling {
      border-top: none;
    }

    &#{&}--dragging {
      pointer-events: none;
    }

    &#{&}--placeholder {
      border-left: 1px $border-fill dashed;
      background-color: var(
        --wds-table-list-item-fill,
        var(--wds-color-fill-standard-tertiary, var(--wsr-color-D60, #dfe5eb))
      );
    }
  }

  /* hoisted out of &--placeholder to stay within max-nesting-depth */
  &__item#{&}__item--placeholder > * {
    visibility: hidden;
  }

  &__item {
    &#{&}--without-bottom-border {
      border-bottom: none;
    }

    &#{&}--focused {
      z-index: 100;
      position: relative;
    }
  }

  &__item#{&}__item--preview &__table-list-item,
  &__item#{&}__item--focused &__table-list-item {
    box-shadow: 0 2px 4px 0 rgba(22, 45, 61, 0.12),
      0 0 6px 0 rgba(22, 45, 61, 0.12);
  }

  /* On master TableListItem's own :not(draggable):border rule came later and kept the
     border on static and drag-disabled items, so the reset only ever applied to items
     TableListItem itself marks draggable; `--draggable` mirrors that exact state. */
  &__item--preview
    &__table-list-item#{&}__table-list-item--draggable,
  &__item--focused
    &__table-list-item#{&}__table-list-item--draggable {
    border: none;
  }

  &__item#{&}__item--root {
    border-left: none;
  }

  &__action-item {
    margin-left: 84px;
    width: auto;

    &#{&}--indent-small {
      margin-left: 20px;
    }

    &#{&}--indent-medium {
      margin-left: 32px;
    }
  }

  &__item#{&}__item--root-action {
    border-left: none;
    margin-left: 0;
    position: relative;
  }

  &__item#{&}__item--without-dividers {
    border: none;
    margin-top: 0;
  }

  &__item#{&}__item--last#{&}__item--without-dividers:not(#{&}__item--without-bottom-border) {
    border-bottom: 1px solid $border-fill;
  }

  &__item#{&}__item--full-width:not(#{&}__item--placeholder) {
    border-left: none;
  }

  &__item#{&}__item--full-width#{&}__action-item {
    margin-left: 0;
  }

  &__arrow-container {
    position: absolute;
    height: calc(100% + 1px);
    width: 84px;
    transform: translateX(-100%);
    pointer-events: none;
    overflow: hidden;
    background-color: $list-fill;

    &#{&}--indent-small {
      width: 20px;
    }

    &#{&}--indent-medium {
      width: 32px;
    }
  }

  &__arrow {
    position: absolute;
    margin-left: 33px;
    height: 100%;
    display: flex;
    align-items: center;
    border-left: 1px solid $border-fill;

    &#{&}--offset-small {
      margin-left: 12px;
    }

    &#{&}--offset-medium {
      margin-left: 20px;
    }

    &#{&}--last-child {
      height: calc(50% - 4px);
      border-left: 1px solid $border-fill;
      align-items: flex-end;
    }

    &#{&}--preview {
      visibility: hidden;
    }

    &#{&}--placeholder {
      border-color: $placeholder-fill;
    }
  }

  &__horizontal-arrow {
    fill: $border-fill;
    margin-left: -1px;
  }

  &__arrow#{&}__arrow--placeholder
    &__horizontal-arrow {
    fill: $placeholder-fill;
  }

  &__arrow#{&}__arrow--last-child
    &__horizontal-arrow {
    transform: translateY(100%);
  }

  &__child-arrow {
    position: absolute;
    height: 100%;
    width: 1px;
    left: -51px;
    background-color: $border-fill;

    &#{&}--offset-small {
      left: -8px;
    }

    &#{&}--offset-medium {
      left: -12px;
    }
  }

  &__base-item {
    position: relative;
  }
}
