
/**
 * Asset Property List - Tree view component for asset properties
 *
 * Note: Uses @size-* tokens for spacing and @size-base for calculations.
 *
 * Intentionally hardcoded values:
 * - Off-token spacing (6px, 7px, 14px, 18px, 42px, 44px, 96px): Tree indentation and positioning not in token system
 * - Border widths (1px): Standard borders
 * - Percentages (50%, 100%): Layout and positioning
 * - Font size (0.7em): Relative size for drag handle
 * - Transition duration (0.15s): Animation timing
 * - Calc expressions: Complex computed values for tree structure
 */

c8y-asset-property-list {
  .cdk-tree {
    background: inherit;
    max-width: 100%;
    display: block;
    overflow: hidden;

    &:has(.drag-handle-wrapper) {
      padding-left: @size-8;
    }
  }

  .tree-container:has(.drag-handle-wrapper) {
    .select-all-container {
      > .separator-bottom,
      > .overflow-hidden {
        padding-left: @size-8;
      }
    }
  }

  .cdk-tree-node {
    height: @size-40;
    background: inherit;

    .drag-handle-wrapper {
      z-index: 5;
      display: flex;
      align-items: center;
      position: absolute;
      height: 100%;
      font-size: 0.7em;
      opacity: 0;
      transition: opacity 0.15s linear;
    }

    &:hover {
      .drag-handle-wrapper {
        opacity: 1;
      }
    }
  }

  .cdk-tree-node > .d-flex::before {
    position: absolute;
    content: '';
    top: 0;
    left: -6px;
    width: @size-20;
    bottom: 0;
    display: block;
    border-left: 1px solid
      var(
        --c8y-component-icon-dark-color-light,
        var(--c8y-root-component-icon-dark-color-light, var(--brand-light, var(--c8y-brand-light)))
);
    z-index: 1;
  }

  .cdk-tree-node:last-of-type > .d-flex::before {
    bottom: 50%;
  }

  .cdk-tree-node:not([aria-level='1']) {
    > .d-flex::after {
      content: '';
      top: 50%;
      left: -6px;
      width: @size-20;
      /* bottom: 0,*/
      display: block;
      border-bottom: 1px solid
        var(
          --c8y-component-icon-dark-color-light,
          var(
            --c8y-root-component-icon-dark-color-light,
            var(--brand-light, var(--c8y-brand-light))
)
);
      z-index: 1;
      position: absolute;
      pointer-events: none;
    }

    &.nonSelectable {
      > .d-flex::after {
        width: @size-40;
      }
    }

    .drag-handle-wrapper {
      left: calc(-1 * @size-24);
    }
  }

  .cdk-tree-node[aria-level]:not([aria-level='1']):not([aria-level='2']) {
    position: relative;

    &::after {
      position: absolute;
      content: '';
      top: 0;
      left: 18px;
      width: @size-20;
      bottom: 0;
      display: block;
      border-left: 1px solid
        var(
          --c8y-component-icon-dark-color-light,
          var(
            --c8y-root-component-icon-dark-color-light,
            var(--brand-light, var(--c8y-brand-light))
)
);
      z-index: 1;
    }

    &[aria-level='4'] {
      &::before {
        position: absolute;
        content: '';
        top: 0;
        left: 42px;
        width: @size-20;
        bottom: 0;
        display: block;
        border-left: 1px solid
          var(
            --c8y-component-icon-dark-color-light,
            var(
              --c8y-root-component-icon-dark-color-light,
              var(--brand-light, var(--c8y-brand-light))
)
);
        z-index: 1;
      }
    }
  }

  .cdk-tree-node.nonCollapsible:not([aria-level='1']) {
    > .d-flex::before {
      left: calc(-1 * @size-5);
    }

    > .d-flex::after {
      width: 14px;
      left: calc(-1 * @size-5);
    }

    &.nonSelectable {
      > .d-flex::before {
        left: 0;
      }

      > .d-flex::after {
        width: @size-10;
        left: 0;
      }
    }
  }

  .cdk-tree-node[aria-level='1'] > .d-flex::before {
    display: none;
  }

  .cdk-tree-node[aria-level='1'] {
    overflow: visible;
  }

  .cdk-tree-node {
    .c8y-list__item__check,
    .c8y-list__item__radio {
      z-index: 4;
    }

    &[aria-level='1'],
    &[aria-level='2'],
    &[aria-level='3'] {
      &:before {
        content: '';
        background: inherit;
        width: 44px;
        height: 100%;
        position: absolute;
        left: 0;
        bottom: calc(50% - 1px);
        z-index: 3;
        pointer-events: none;
      }

      &.nonCollapsible {
        &::before {
          width: 18px;
          bottom: calc(100% - 1px);
          height: 50%;
        }

        + .cdk-tree-node[aria-level='1'] {
          &::before {
            background: transparent;
          }
        }
      }
    }

    &[aria-level='2'] {
      &::before {
        left: @size-24;
        z-index: 1;
      }

      &.nonCollapsible {
        + .cdk-tree-node[aria-level='2'] {
          &::before {
            background: transparent;
          }
        }
      }
    }

    &[aria-level='3'] {
      &::before {
        left: @size-48;
        z-index: 1;
      }

      &.nonCollapsible {
        + .cdk-tree-node[aria-level='3'] {
          &::before {
            background: transparent;
          }
        }
      }
    }
  }

  .cdk-tree-node .collapse-btn {
    background-color: inherit;
    position: relative;
    z-index: 4;
  }

  .cdk-tree-node .c8y-list__item__radio {
    padding-top: 7px !important;
    padding-bottom: 7px !important;
    max-height: @size-40 !important;
    min-height: unset !important;
  }

  .cdk-tree-node .c8y-list__item__icon {
    padding-top: 7px;
    padding-bottom: 7px;
    z-index: 2;
  }

  c8y-asset-property-list:has(.asset-property-list__actions.has-computed) {
    .asset-property-list__actions {
      min-width: 96px;
    }
  }
}

.c8y-list__item--dense.cdk-drag-preview {
  background-color: @component-background-default;
  &::before,
  .drag-handle-wrapper {
    display: none;
  }
}
