/*!
  *  Copyright (C) 2023 Robert Bosch GmbH Copyright (C) 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

@import '@bci-web-core/common-styles/sass/bci/colors';
@import '@bci-web-core/common-styles/sass/bci/bci-variables';
@import '@bci-web-core/common-styles/sass/bci/mixins/borders';

$drop-border-width: 1px;

.scroll-viewport {
  height: 240px;
  width: 100%;
  overflow-x: hidden;
}

.display-flex {
  display: flex;
}

.drag-preview-beta-container {
  box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.25);
  cursor: grabbing;
  .display-flex {
    .mat-mdc-list-option {
      width: calc(100% - 48px);
    }

    .mat-mdc-list-option,
    button {
      cursor: grabbing;
      background-color: $boschBlue95;
      height: 48px;
    }
  }
  mat-selection-list.mat-mdc-selection-list button.mat-mdc-icon-button {
    height: $grid-size * 6;
    width: $grid-size * 6;
    padding: 12px;
    border-bottom: 1px solid $boschGray60;
  }
}

.drag-drop-list-beta-container {
  position: relative;
  box-sizing: border-box;
  height: 100%;
  min-height: 216px;
  border-bottom: 1px solid $boschBlack;

  .item-selection-list:not(.cdk-drop-list-dragging):not(.cdk-drop-list-receiving) {
    .display-flex {
      background-color: $boschWhite;
      cursor: pointer;

      .mat-mdc-list-option {
        height: 48px;
        width: calc(100% - 48px);

        .mat-mdc-list-option-checkbox-before {
          display: none;
        }
      }

      .mat-mdc-list-option:hover,
      .mat-mdc-list-option:focus {
        background-color: $boschWhite;
        cursor: pointer;
      }

      &:hover {
        .mat-mdc-list-option,
        .mat-mdc-list-option:hover,
        .mat-mdc-list-option:focus,
        button {
          background-color: $boschGray90;
        }
      }

      &:focus,
      &:active {
        .mat-mdc-list-option,
        .mat-mdc-list-option:hover,
        .mat-mdc-list-option:focus,
        button {
          background-color: $boschGray80;
        }
      }

      &[disabled] {
        .mat-mdc-list-option,
        .mat-mdc-list-option:hover,
        .mat-mdc-list-option:focus,
        button {
          background-color: $boschWhite;
          cursor: default;
          .mdc-list-item__primary-text {
            color: $boschGray80;
          }
        }
      }
    }
  }

  .item-selection-list.cdk-drop-list-dragging,
  .item-selection-list.cdk-drop-list-receiving {
    .display-flex {
      background-color: $boschWhite;
      cursor: default;

      .mat-mdc-list-option {
        height: 48px;
        width: calc(100% - 48px);
        .mat-mdc-list-option-checkbox-before {
          display: none;
        }
      }

      .mat-mdc-list-option:hover,
      .mat-mdc-list-option:focus {
        background-color: $boschWhite;
      }

      &:hover {
        .mat-mdc-list-option,
        .mat-mdc-list-option:hover,
        .mat-mdc-list-option:focus,
        button {
          background-color: $boschWhite;
        }
      }

      &:focus,
      &:active {
        .mat-mdc-list-option,
        .mat-mdc-list-option:hover,
        .mat-mdc-list-option:focus,
        button {
          background-color: $boschWhite;
        }
      }

      &[disabled] {
        .mat-mdc-list-option,
        .mat-mdc-list-option:hover,
        .mat-mdc-list-option:focus,
        button {
          background-color: $boschWhite;
          cursor: default;
          .mdc-list-item__primary-text {
            color: $boschGray80;
          }
        }
      }
    }
  }

  mat-selection-list.mat-mdc-selection-list button.mat-mdc-icon-button {
    height: $grid-size * 6;
    width: $grid-size * 6;
    padding: 12px;
    border-bottom: 1px solid $boschGray60;
  }
}

::ng-deep .drag-drop-list-beta-container .mat-mdc-selection-list .mat-mdc-list-item .mdc-list-item__content,
::ng-deep .drag-preview-beta-container .mat-mdc-selection-list .mat-mdc-list-item .mdc-list-item__content {
  padding-right: 0px;

  .mdc-list-item__primary-text {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    column-gap: $grid-size;
    padding-left: 0px !important;
  }
}

::ng-deep .drag-drop-list-beta-container .mat-mdc-selection-list .mat-mdc-list-option-checkbox-before,
::ng-deep .drag-preview-beta-container .mat-mdc-selection-list .mat-mdc-list-option-checkbox-before {
  display: none;
}

::ng-deep .drag-drop-list-beta-container mat-checkbox {
  input.cdk-visually-hidden {
    height: 0;
    margin: 0;
  }
}

::ng-deep .drag-drop-list-beta-container.multiline .mat-mdc-selection-list .mat-mdc-list-item .mdc-list-item__content,
::ng-deep .drag-preview-beta-container.multiline .mat-mdc-selection-list .mat-mdc-list-item .mdc-list-item__content {
  padding: 4px 16px;
  padding-right: 0px;
}

.drop-zone-overlay {
  white-space: normal;
  text-align: center;
  overflow-x: hidden;
  overflow-y: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  pointer-events: none;
  color: transparent;
  border: 1px solid $boschGray60;

  &.empty {
    color: $boschBlack;
    padding: 0px 16px;
  }

  &.active {
    border: $drop-border-width solid $boschBlue50;
    color: $boschBlack;
    padding: 0px 16px;
  }
}

mat-selection-list.item-selection-list {
  width: 100%;
  height: 100%;
  overflow: overlay;
  padding: 0;
  border: none;

  & > mat-list-option.item {
    height: 48px;
    &:last-child {
      margin-bottom: 0;
    }
  }
}

@-moz-document url-prefix() {
  mat-selection-list.item-selection-list {
    overflow: auto;
  }
}

mat-list-item.item,
mat-list-option.item {
  user-select: none;

  &.selected.dragging {
    display: none;
  }
}

mat-list-item.item {
  background-color: $boschWhite;
  display: flex;
}

button.dragging {
  display: none;
}

.mat-list-option {
  cursor: default;
}

.overlay-icon {
  height: 50px;
  width: 50px;
  font-size: $icon-font-size-xlarge;
}

.item-label {
  width: calc(100% - 48px);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  position: absolute;
  line-height: 24px;
  margin-left: 32px !important;
}

.drag-preview-beta-container {
  background-color: $boschGray80;
}

.source,
.target:not(.sortable) {
  .item {
    // !important is needed here because the CDK uses transform: translate to move the items but we want it disabled
    transform: none !important;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;

    .drag-placeholder {
      height: 0;
    }
  }
}

.target.sortable {
  .drag-placeholder {
    height: 6 * $grid-size;
  }
}

.m-b-8 {
  margin-bottom: 8px;
}

//VP1
@media screen and (max-width: $screen-xs-min) {
  .drag-drop-list-beta-container,
  .drag-preview-beta-container {
    min-width: 288px;
    max-width: 288px;
    max-height: 216px;
  }
}

//VP2
@media screen and (min-width: ($screen-xs-min + 1)) and (max-width: ($screen-sm-min)) {
  .drag-drop-list-beta-container,
  .drag-preview-beta-container {
    min-width: 252px;
    max-width: 252px;
    max-height: 264px;
  }
}

//VP3
@media screen and (min-width: ($screen-sm-min + 1)) {
  .drag-drop-list-beta-container,
  .drag-preview-beta-container {
    min-width: 336px;
    max-width: 336px;
    max-height: 312px;
  }
}
