@import "variables";

:host {
  ::ng-deep th.resize-enabled span.p-column-resizer {
    width: 8px;
    z-index: 20;

    &:hover {
      background: $blue-300;
      background-clip: content-box;
    }
  }

  th.resize-disabled {
    ::ng-deep span.p-column-resizer {
      cursor: auto;
    }
  }

  ::ng-deep .p-column-resizer-helper {
    background-color: $blue-300;
    z-index: 1000;
  }

  .has-header {
    ::ng-deep .p-datatable-scrollable, ::ng-deep .p-datatable {
      & > .p-datatable-wrapper > .p-datatable-table > .p-datatable-thead {
        z-index: 20;

        &:after {
          content: "";
          position: absolute;
          z-index: -1;
          left: 0;
          right: 0;
          top: 0;
          height: var(--table-row-height);
          background-color: $blue-700;
        }
      }
    }
  }

  ::ng-deep .p-datatable-wrapper {
    .p-datatable-tbody {
      height: calc(100% - var(--table-row-height, 48px));
    }
  }

  .card-header {
    box-shadow: 0 0 12px 6px rgba($blue-800, 0.9);
  }

  .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .table-header-title {
    font-weight: 500;
    text-transform: uppercase;
    padding-left: 8px;
    margin-right: 12px;
  }

  .collapse-button {
    cursor: pointer;
    margin-right: auto;
    margin-top: -2px;

    &.active {
      color: $neon-yellow;
    }

    &:hover:not(.active) {
      color: $blue-200;
    }

  }

  .table-actions {
    padding-top: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 24px;
  }

  .selected-col-header {
    pointer-events: none;
  }


  .table-load-more {
    background-color: transparent !important;
    border-bottom: none !important;
    height: 100px;
    position: relative;

    &.hidden {
      height: 0;
    }
  }

  .load-more-wrapper {
    position: absolute;
    width: 100%;
    bottom: 32px;

    button, sm-dots-load-more {
      padding: 8px 40px;
      width: 175px;
      position: sticky;
      left: 50%;
      transform: translateX(-50%);
    }

    .load-spinner {
      display: inline-block;
      vertical-align: middle;
      background-image: url("../../../../assets/icons/Spinner.svg");
      background-repeat: no-repeat;
      background-size: 16px;
      width: 16px;
      height: 16px;
      margin-right: 6px;

    }
  }

  .no-data-wrapper {
    display: flex;
    position: absolute;
    width: 100%;

    span {
      position: sticky;
      left: 50%;
      transform: translateX(-50%);
    }
  }

  tr:not(.cards-table) {
    &:not(.no-data-row):not(.load-more-wrapper) {
      border-bottom: 1px solid $blue-600;
    }

    &:not(.header):not(.selected):not(.checked):not(.no-data-row):not(.simple):not(.load-more-wrapper) {
      &:hover, &.contexted {
        background-color: $blue-650;
        border-bottom: 1px solid $blue-600;

        .p-frozen-column {
          background-color: $blue-650 !important;
          z-index: 1;
        }
      }
    }

    &.checked:not(.header):not(.selected):not(.no-data-row):not(.simple) {
      background-color: $blue-500;

      .card-wrapper {
        border-bottom: none;
      }

      &:hover, &.contexted {
        &:not(.cards-table) {
          background-color: $blue-550;
        }

        .card-wrapper {
          background-color: $blue-550;
        }
      }
    }

    &.selected {
      .card-wrapper {
        border-bottom-color: $blue-600;
      }

      background-color: $blue-400;

      &:hover {
        background-color: $blue-480;
      }
    }
  }

  tr {
    position: relative;
    transition: height 0.35s ease-in-out;

    &.header {
      height: var(--table-row-height, 48px);
      background-color: $blue-700;
    }

    th {
      color: $blue-300;
      border-bottom: none;
      padding: 0 8px;

      &:first-child {
        padding-left: 24px;
      }

      &.disable-drag {
        cursor: initial !important;
      }

      .col-header {
        text-align: left;
        font-size: 12px !important;
        font-weight: 500;
        white-space: nowrap;
      }

      &:hover {
        background-color: $blue-600;
      }
    }

    td {
      align-items: center;
      color: $blue-100;
      font-size: 1rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      padding: 0 8px;

      &:first-child {
        padding-left: 24px;
      }

      &:not(.no-data):not(.load-more-wrapper) {
        &.simple {
          border-bottom-color: $blue-100;

        }
      }

      &.no-data {
        color: $blue-250;
        text-align: center;
        padding: 15px 0 10px 0;;
      }

      &.p-frozen-column {
        background-color: $blue-800;
        z-index: 1;
      }
    }

    &:hover {
      .context-button {
        opacity: 1;
      }
    }

    .context-button-wrapper {
      width: 100%;
      height: 0;
      position: absolute;
      left: 0;
    }

    .context-button {
      position: sticky;
      z-index: 2;
      left: calc(100% - 46px);
      cursor: pointer;
      opacity: 0;
      transition: opacity 0.35s ease-in-out;
      margin-top: calc(var(--table-row-height) * 0.166);
      width: calc(var(--table-row-height) * 0.666);
      height: calc(var(--table-row-height) * 0.666);
      padding: 3px;
      color: $blue-400;
      background-color: rgba($blue-600, 95%);
      border-radius: 4px;
      border: solid 1px $blue-400;

      &:hover {
        color: $blue-300;
        background-color: lighten($blue-600, 5%);
      }
    }

    &.cards-table {

      .card-wrapper {
        margin: 6px 2px 6px 12px;
        border: 1px solid $dark-border;
        border-radius: 4px;
        overflow: hidden;
        animation-name: expand;
        animation-duration: 0.35s;
        animation-timing-function: ease-in-out;

        .collapse-animation {
          transition: max-height 0.35s ease;
        }
      }

      &:first-child {
        .card-wrapper {
          margin-top: 12px;
        }
      }

      &:hover:not(.selected):not(.simple) .card-wrapper {
        background-color: $blue-650;
      }

      &.selected {
        .card-wrapper {
          background-color: $blue-400;
        }

        &:hover .card-wrapper {
          background-color: $blue-480;
        }
      }

      &.checked:not(.selected):not(.simple) {
        .card-wrapper {
          background-color: $blue-500;
        }

        &:hover, &.contexted {
          .card-wrapper {
            background-color: $blue-550;
          }
        }
      }
    }
  }

  :host-context(.light-theme) {
    tr:not(.cards-table) {
      &:not(.no-data-row):not(.load-more-wrapper) {
        border-bottom: 1px solid $blue-100;
      }

      &:not(.header):not(.selected):not(.no-data-row):not(.simple):not(.load-more-wrapper) {
        &:hover, &.contexted {
          background-color: $blue-50;
          border-bottom: 1px solid $blue-50;
        }
      }

      &.checked:not(.header):not(.selected):not(.no-data-row):not(.simple) {
        background-color: $blue-100;
        border-bottom-color: $blue-50;

        &:hover, &.contexted {
          .simple-row, .card-wrapper {
            background-color: $blue-50;
          }
        }

        &.selected {
          .card-wrapper {
            border-bottom-color: $blue-50;
          }

          background-color: $blue-100;

          &:hover {
            background-color: $blue-50;
          }
        }
      }

      &.header {
        background-color: $blue-50;
        @supports (-moz-appearance:meterbar) {
          border-bottom: 3px solid $blue-100;
        }
      }

      th {
        color: $blue-400;
        font-weight: 500;
        border-bottom: none;

        &:hover {
          background-color: $blue-50;
        }
      }

      td {
        color: $blue-400;
        border-bottom: none;

        &.no-data {
          color: $blue-300;
        }

        &.p-frozen-column {
          background-color: $blue-100;
          z-index: 1;
        }

      }

      &.selected {
        background-color: $blue-100;

        &:hover {
          background-color: $blue-200;
        }
      }
    }

    .has-header ::ng-deep .p-datatable-scrollable > .p-datatable-wrapper > .p-datatable-table > .p-datatable-thead {
      &:after {
        background-color: $blue-50;
      }
    }
  }

  @supports (-moz-appearance:none) {
    tr.cards-table .card-wrapper {
      margin: 6px 12px;
    }
  }
}

:host-context(.dark-theme-table.table-first-column-color) {
  tr td:not(.no-data):not(.load-more-wrapper).simple {
    border-bottom-color: $dark-grey-blue;
    color: $blue-280;

    &:first-child {
      color: $blue-400;
    }
  }
}

:host-context(.snippets-sources-container) {
  tr td.p-frozen-column {
    background-color: transparent;
  }
}

@keyframes expand {
  from {
    height: var(--table-row-height);
  }

  to {
    height: var(--card-height, 90px);
  }
}

