/*!
 *  Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 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/mixins';
@import '../mixins';

$gridGap: $grid-size * 4;

:host {
  display: flex;
  flex-direction: column;
  height: 100%;
}

::ng-deep .widget-catalog-dialog {
  width: 68vw !important;

  .mat-mdc-dialog-container {
    padding-left: $grid-size * 2;
    padding-right: $grid-size * 2;
    height: inherit;
  }
}

button.mat-icon-button {
  width: auto;
  display: inline-flex;
  padding: 12px;
  border: 0;
}

.mdc-dialog__title {
  padding: 0;
}

.dialog-header {
  padding-left: 2 * $grid-size !important;
  padding-right: 2 * $grid-size !important;
}

// Added to avoid dialog height fluctuation when filters are added
.mat-mdc-dialog-content {
  margin: 0;
  padding: 0 $grid-size * 2 $grid-size * 2 $grid-size * 2;
  font-family: Bosch-Sans;
  font-weight: 300;
  font-size: $font-size-base; // 14px
  max-height: 475px;
}

mat-form-field {
  margin: 0 $grid-size * 2;
}

.close-button {
  position: absolute;
  top: $grid-size * 2;
  right: $grid-size * 2;
}

.empty-message {
  @include generateEmptyMessage();
}

.catalog-note {
  display: block;
  margin-top: $grid-size;
}

.catalog-filter {
  display: grid;
  grid-gap: $gridGap;
  grid-template-columns: repeat(3, 1fr);
  justify-content: space-around;
  margin: 22px 0 $grid-size * 2 0;

  mat-form-field {
    margin: 0;
    padding: 0;
  }
}

.category-title:first-child {
  margin-top: 0;
}

.category-title {
  font-size: $font-size-h5;
  line-height: $grid-size * 3;
  display: block;
  margin: $grid-size * 1.5 0;
}

.catalog-category-items-container {
  display: grid;
  grid-gap: $gridGap;
  grid-template-columns: repeat(3, 1fr);
  justify-content: space-around;
  margin: auto;
  margin-bottom: $grid-size * 3;
}

.catalog-item {
  padding: $grid-size * 3;
  background-color: $boschGray95;
  border-top: $grid-size solid $boschGray40;
  position: relative;
  cursor: pointer;
  overflow: hidden;

  .widget-header {
    .widget-category {
      display: block;
      font-size: $font-size-small;
      color: $boschGray70;
      line-height: $grid-size * 2.25; // 18px
    }

    .widget-heading {
      font-size: $font-size-h4;
      line-height: $grid-size * 3.5; // 28px
      font-weight: 400;
    }

    .widget-select {
      position: absolute;
      right: $grid-size * 3;
      top: $grid-size * 2;
    }

    .widget-linkable {
      position: absolute;
      right: $grid-size * 8;
      top: $grid-size * 2;
      color: $boschGray70;
    }
  }

  .widget-details {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 2 * $grid-size;
    margin-top: $grid-size * 2;

    .preview {
      .icon-img {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: $grid-size * 13;
        height: $grid-size * 13;
        background: $boschWhite;
        border: 1px solid $boschGray90;
      }

      img {
        width: $grid-size * 13;
        height: $grid-size * 13;
        border: 1px solid $boschGray90;
      }
    }

    .description {
      font-size: $font-size-small;

      span.widget-description {
        line-height: $grid-size * 2.25; // 18px
        word-break: break-word;
      }

      span.long-description {
        display: block;
        height: $grid-size * 7;
        overflow: hidden;
        margin-bottom: 0;
      }

      span.show-more {
        display: block;
        margin-top: $grid-size;
        cursor: pointer;
      }

      button {
        padding: 0 $grid-size * 1.5;
        line-height: $grid-size * 4.5;
        white-space: nowrap;
      }
    }
  }
}

.mat-mdc-dialog-actions {
  padding: $grid-size * 4 $grid-size * 2;
  border-top: 1px solid $boschGray85;
  min-height: unset;

  .button-primary {
    margin-right: $grid-size * 2;
  }
}

/****Large Screen Resolution****/
@media (max-width: 1400px) {
  ::ng-deep .widget-catalog-dialog {
    width: 95vw !important;
    max-width: 95vw !important;
  }
}

/****Tablet Resolution****/
@media (max-width: $screen-md-min) {
  ::ng-deep .widget-catalog-dialog {
    width: 100% !important;
    max-width: 100% !important;
  }

  .mat-mdc-dialog-content {
    height: initial;
    max-height: initial;
    overflow: initial;
  }

  .catalog-filter {
    grid-template-columns: repeat(2, 1fr);

    mat-form-field {
      margin: 0;
      padding: 0;
    }
  }

  .category-title {
    font-size: $font-size-h6;
  }

  .catalog-category-items-container {
    grid-template-columns: 1fr;
  }

  .mat-mdc-dialog-actions {
    padding: $grid-size * 3 0;

    button {
      width: 100%;
    }

    .button-primary {
      margin-right: 0;
      margin-bottom: $grid-size * 2;
    }
  }
}

/****Phone Resolution****/
@media screen and (max-width: $screen-sm-min) {
  .mat-mdc-dialog-title {
    font-size: $font-size-h4 !important;
  }

  .catalog-note {
    font-size: $font-size-base; // 14px
  }

  .catalog-filter {
    grid-template-columns: 1fr;

    mat-form-field {
      margin: 0;
      padding: 0;
    }
  }

  .category-title {
    font-size: $font-size-h6;
  }

  .catalog-category-items-container {
    grid-template-columns: 1fr;
  }

  .mat-mdc-dialog-actions {
    padding: $grid-size * 2 0;

    button {
      width: 100%;
    }

    button.button-primary {
      margin-right: 0;
      margin-bottom: $grid-size * 2;
    }
  }
}
