/*!
  Copyright (C) 2022 Robert Bosch GmbH Copyright (C) 2022 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
*/
@import '@bci-web-core/common-styles/sass/bci/bci-variables';
@import '@bci-web-core/common-styles/sass/bci/colors';
@import '@bci-web-core/common-styles/sass/bci/mixins';

.bci-select {
  position: relative;
  min-width: 192px;
  width: 192px;
  max-width: 100%;

  &-trigger {
    padding: 0;
    min-width: 192px;
    width: 100%;
    border: none;
    outline: none;
    height: 48px;
    display: grid;
    grid-template-columns: 1fr 48px;
    cursor: pointer;
    background: $boschGray90;

    &-value {
      font-weight: 400;
      font-size: 16px;
      line-height: 1.5;
      padding-left: 16px;
      width: calc(100% - 12px);
      text-align: left;
      overflow: hidden;
      & > div {
        width: 100%;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
      }
      &:not(.hasLabel) {
        margin: auto 0;
      }
      &.hasLabel {
        padding: 20px 0px 4px 16px;
      }
    }

    &:hover,
    &:focus-within,
    &:focus {
      background: $boschGray80;

      .bci-select-trigger-placeholder.isOverflowing:not(.shouldNotScroll),
      .bci-select-trigger-text.isOverflowing:not(.shouldNotScroll) {
        display: inline-block;
        animation: scroll-text 8s forwards linear 0.5s;
      }
    }

    &:active {
      background: $boschGray70;
    }

    &:disabled {
      background: $boschGray90;
      color: $boschGray70;
      cursor: default;
    }

    &-label {
      position: absolute;
      padding-left: 16px;
      font-weight: 400;
      font-size: 12px;
      line-height: 18px;
      margin-top: 4px;
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
      max-width: calc(100% - 16px - 48px);

      &.withRequiredMark::after {
        content: ' *';
      }
    }

    &-panel-open-wrapper {
      width: 48px;
      height: 48px;
      display: grid;
      place-items: center;
    }
  }
  &-panel {
    @include make-select-panel();
    width: 100%;
    max-height: 240px;
    position: absolute;
    box-shadow: 0px 0px 8px rgb(0 0 0 / 25%);
    z-index: 9999;

    &-option {
      @include make-select-option();

      & > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      &.keyboardSelected {
        background: $dropdown-menu-not-selected-bg-color-hover;
      }

      &:hover,
      &.keyboardSelected:not(.selected) {
        .bci-select-panel-option-text.isOverflowing {
          display: inline-block;
          animation: scroll-text 8s infinite linear 0.5s;
        }
      }

      &:not(.multiple).selected {
        @include make-select-option-selected();
      }

      &.disabled {
        @include make-select-option-disabled();
      }

      mat-checkbox {
        margin: 0;
        padding: 0;
        height: 24px;
        border: none;
        bottom: 1px;
        max-width: 100%;
        margin-right: 8px;
      }
      &::before {
        content: none !important;
      }
    }
    &-optiongroup-label {
      @include make-select-optiongroup-label();
    }
  }
}

@keyframes scroll-text {
  0% {
    transform: translateX(0%);
  }
  80%,
  85% {
    transform: translateX(-100%);
  }
  86%,
  100% {
    transform: translateX(0%);
  }
}
