.c8y-list {
  &__group {
    margin: 0;
    padding: 0;
    list-style: none;

    &:not(.dropdown-menu) {
      display: block;
    }

    &.separator-top {
      // spacing for proper displaying of the border
      padding-top: 1px;
    }

    &.dropdown-menu {
      width: 100%;
      max-height: 240px;
      overflow-y: auto;
    }
  }

  &__item {
    display: block;
    background-color: @component-background-default;
    color: @component-color-default;
    box-shadow: inset 0 -1px 0 @component-border-color;

    [class*='bg-level-'] & {
      background-color: inherit;
    }

    .c8y-list__item__title {
      white-space: normal;
      word-break: break-word;
    }

    .card &,
    .dropdown & {
      box-shadow: inset 0 -1px 0 0 @component-border-color;
      margin-bottom: 0;
    }

    /* typeahead dropdown list items styling */

    bs-dropdown-container & {
      &.active,
      &:active {
        color: @component-color-active;
      }

      &:hover {
        color: @component-color-active;
      }

      &:focus {
        outline: 2px solid @component-color-focus;
        outline-offset: -2px;
        border-radius: @component-border-radius-focus !important;
      }
    }

    &.disabled {
      opacity: @component-disabled-opacity;
      pointer-events: none;
    }

    > .expanded,
    &.expanded {
      background-color: @component-background-expanded;
      .separator-bottom();
      --c8y-nav-tabs-background-active: @component-background-expanded;
      --c8y-component-color-link: var(--c8y-brand-20);

      .c8y-list__item__title {
        font-weight: 500;
      }

      .sticky-top {
        background-color: inherit;
      }
    }

    &--empty-actions {
      padding-right: 40px;

      .c8y-list__item__body {
        padding-right: 0 !important;
      }
    }

    &.has-error {
      box-shadow: inset 0 -2px 0 @alert-danger-border;
    }

    .c8y-list__group--strip & {
      &:nth-child(odd) {
        background-image: @component-background-odd;
      }
    }

    // don't display the bottom border in the last item when inside a card
    .no-border-last & {
      &:last-child {
        box-shadow: none;
      }
    }

    .no-border-2nd-last & {
      &:nth-last-child(2) {
        box-shadow: none;
      }
    }

    &--double-actions {
      .c8y-list__item__actions {
        min-width: 80px;
      }
    }

    // hide collapse-btn when displaying in a modal for instance
    &--no-expand {
      .collapse-btn {
        display: none;
        pointer-events: none;
      }
    }

    &--link {
      cursor: pointer;

      &:hover {
        color: @component-color-link-hover;
      }

      &:focus {
        outline: 2px solid @component-color-focus;
        outline-offset: -2px;
        border-radius: @component-border-radius-focus !important;
      }
    }
  }

  &--pulse {
    .component-pulse();
  }
}

a.c8y-list__item {
  &:hover {
    text-decoration: none;
  }

  &:focus {
    outline: 2px solid @component-color-focus;
    outline-offset: -2px;
    border-radius: @component-border-radius-focus !important;
  }
}

c8y-load-more.c8y-list__item {
  .btn {
    margin-top: @margin-8;
    margin-bottom: @margin-8;
  }
}

.c8y-list__item__block {
  display: flex;
  flex-flow: row nowrap;
  align-items: flex-start;

  &.sticky-top {
    background-color: unset;
  }

  // remove marging bottom from progress bar
  .progress {
    margin-top: 3px;
    margin-bottom: 0;
  }
}

c8y-li-drag-handle {
  display: flex;
  align-items: center;
  align-self: stretch;
  flex-shrink: 0;
  max-width: 0;
  overflow: hidden;
  transition: all 0.25s ease;

  c8y-li-drag-handle {
    padding: 0 !important;
    cursor: move;
    max-width: fit-content !important;
  }

  &[cdkdraghandle] {
    cursor: move;

    &:hover {
      color: @component-brand-primary;
    }
  }

  .cdk-drag-disabled & {
    display: none;

    + * {
      padding-left: 0 !important;
    }
  }
}

.no-card-context {
  .c8y-list__item:not(:hover) {
    c8y-li-drag-handle:not(.cdk-drag-disabled) + * {
      padding-left: 0;
    }
  }
}

.c8y-list__item:hover {
  c8y-li-drag-handle:not(:empty) {
    max-width: 100px;
    padding-left: @margin-8;
  }
}

.c8y-list__item__actions {
  display: flex;
  padding: @margin-base 0;

  .c8y-dropdown,
  .collapse-btn {
    opacity: @component-actions-opacity;
    min-width: 40px;

    &:hover {
      opacity: 1;
      color: @component-color-link-hover;
      outline: 2px solid @component-color-focus;
      outline-offset: -2px;
    }

    &:focus {
      .c8y-focus-inset();
      opacity: 1;
    }

    &.disabled,
    &[disabled] {
      color: @component-color-disabled;

      &:hover {
        opacity: 0.5;
        pointer-events: auto !important;
        cursor: not-allowed !important;
      }
    }
  }
}

.c8y-list__item__icon,
.c8y-list__item__check,
.c8y-list__item__appicon,
.c8y-list__item__radio,
.c8y-list__item__colorpicker {
  padding: @component-padding;
  display: flex;
  flex-direction: column;
  justify-content: center;

  .c8y-list__item__body & {
    min-height: auto;
  }
}

// sizing constraints
.c8y-list__item__icon,
.c8y-list__item__check,
.c8y-list__item__appicon,
.c8y-list__item__radio,
.c8y-list__item__colorpicker,
.c8y-list__item__actions {
  min-height: 56px;
}

.c8y-list__item__body {
  padding-top: calc(@margin-base + 10px);
  padding-bottom: calc(@margin-base + 10px);
}

.card,
.modal,
.cdk-drag {
  .c8y-list__item__icon,
  .c8y-list__item__check,
  .c8y-list__item__appicon,
  .c8y-list__item__radio,
  .c8y-list__item__colorpicker,
  .c8y-list__item__actions {
    min-height: 40px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .c8y-list__item__actions {
    padding-top: 0;
    padding-bottom: 0;
  }

  .c8y-list__item__body {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

//----

.c8y-list__item__check,
.c8y-list__item__radio {
  justify-content: center;

  .c8y-checkbox,
  .c8y-radio {
    line-height: 1.3;
  }
}

.c8y-list__item__appicon {
  font-size: 36px;
}

.c8y-list__item__icon {
  font-size: 20px;
  color: @component-icon-color;
  min-height: 40px;
  line-height: @line-height-computed;

  > device-status {
    line-height: 1;
  }

  &.changeIcon {
    position: relative;

    > button {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      opacity: 0;
    }

    &:hover {
      > button {
        opacity: 1;
      }
    }
  }
}

.c8y-list__item__body {
  flex-grow: 1;
  display: block;
  text-overflow: ellipsis;
  min-width: 0;

  &:last-child {
    padding-right: @component-padding;
  }

  &:first-child {
    padding-left: @component-padding;
  }
}

.c8y-list__item__footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: @font-size-small;
  line-height: 1.2;

  > * {
    padding: 0.5rem 0 0 0;
  }
  > c8y-li-footer{
    width: 100%;
  }
}

.c8y-list__item__collapse {
  width: 100%;
}

.c8y-list__item__collapse--container {
  padding: @component-padding;
  @media (min-width: @screen-md-min) {
    padding: @component-padding calc(@margin-48 + 6px) 2rem;
  }
}

// handling sticky elements

.card-header.sticky-top {
  z-index: 100;

  + .c8y-list__group .c8y-list__item__block.sticky-top {
    top: 48px;
  }
}

// TIMELINE LIST
.c8y-list--timeline {
  box-shadow: none;
  // --c8y-component-background-default: @palette-high;
  .c8y-list--timeline__item {
    position: relative;
    align-items: center;
    box-shadow: none;
    &:focus-within, &:has(.dropdown.open) {
      z-index: 10;
    }
    &::after {
      transition: all 1s linear 0.25s;
    }

    .c8y-list__item {
      background: @component-background-default;
      // transition: background 1s linear 0.25s, border 1s linear 0.25s;
      max-width: calc(100% - 104px);

      &::after {
        transition: inherit;
      }
    }

    .c8y-list__item__body {
      padding-right: @component-padding;
    }

    &.ng-enter {
      &:after {
        transition: none;
        background: @component-realtime-added !important;
      }

      .c8y-list__item {
        transition: none;
        background: @component-realtime-added !important;

        &::after {
          border-color: transparent @component-realtime-added transparent transparent;
        }
      }
    }

    &::before,
    &::after {
      position: absolute;
      top: 0;
      bottom: 1px;
      left: 80px;
      border: 1px dotted @component-border-color;
      content: '';
      transition: top 0.35s linear;
    }

    &:first-child::before {
      top: 50%;
    }

    &:last-of-type::before {
      bottom: 50%;
    }

    &::after {
      position: absolute;
      top: 50%;
      left: 80px;
      z-index: 3;
      margin: -10px 0 0 -6px;
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background-color: transparent;
      content: '';
      transition: all 0.25s linear;
      border: 6px double @gray-50;
    }

    &,
    &.expanded {
      background-color: transparent;
      display: flex;
      flex-flow: row nowrap;
    }

    &.expanded {
      .c8y-list__item__title {
        font-weight: 500;
      }

      &::after {
        background-color: @component-color-active;
        border-color: @component-color-active;
      }

      .c8y-list__item {
        background: @component-background-expanded;

        &::after {
          border-color: transparent @component-background-expanded transparent transparent;
        }
      }
    }
  }

  .c8y-list--timeline__item__date {
    margin-right: 40px;
    width: 64px;
    font-size: @font-size-xs;
    line-height: 1.2;
    text-align: right;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    color: @component-icon-color;

    &::first-line {
      font-weight: bold;
      font-size: @font-size-xs;
    }
  }

  .c8y-list__item__block {
    padding: 0 0 0 @component-padding;
  }

  .c8y-list__item {
    position: relative;
    overflow: visible;
    flex-grow: 1;
    margin-top: 0;
    margin-bottom: 8px;
    border-radius: 0.25rem;
    box-shadow: inset 0 0 0 1px @component-border-color;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    transition: all 0.15s linear !important;
    &:focus-within {
      z-index: 10;
    }

    &:not(:has(>button))::before {
      position: absolute;
      top: 50%;
      left: -10px;
      margin-top: -10px;
      width: 0;
      height: 0;
      border-width: 10px 10px 10px 0;
      border-style: solid;
      border-color: transparent @component-border-color transparent transparent;
      content: '';
      transition: border-color 0.15s linear !important;
    }

    &:not(:has(>button))::after {
      position: absolute;
      top: 50%;
      left: -8px;
      margin-top: -10px;
      width: 0;
      height: 0;
      border-width: 10px 10px 10px 0;
      border-style: solid;
      border-color: transparent var(--c8y-root-component-background-default) transparent transparent;
      content: '';
      transition: border 0.15s linear !important;
    }
  }

  .c8y-list__item__actions {
    margin-right: 0; //calc(@component-padding * -1);
  }

  .c8y-list__item__icon,
  .c8y-list__item__check,
  .c8y-list__item__radio {
    padding-left: 0;
  }
  .c8y-list--timeline__item.active {
    &::after {
      background-color: @component-color-accent;
      border-color: @component-color-active;
    }

    .c8y-list__item {
      outline: 2px solid @component-color-accent;
      outline-offset: -2px;

      &::before {
        left: -11px;
        margin-top: -11px;
        border-width: 11px 11px 11px 0;
        border-color: transparent @component-color-accent transparent transparent;
      }
    }
  }
  &.interactive .c8y-list--timeline__item:hover:not(.active) {
    .c8y-list__item {
      box-shadow: inset 0 0 0 1px @component-color-accent;
      &::before {
        left: -10px;
        margin-top: -10px;
        border-width: 10px 10px 10px 0;
        border-color: transparent @component-color-accent transparent transparent;
      }
      &::after {
        left: -9px;
      }
    }
  }
}
