@use '@angular/material' as mat;
@use 'sass:map';
@use '../../styles/typography';
@use '../../styles/mixins';

@mixin paginated-table-theme($theme) {
  $color-config: mat.get-color-config($theme);
  $accent-palette: map.get($color-config, accent);
  $accent: mat.get-color-from-palette($accent-palette);
  $accent-100: mat.get-color-from-palette($accent-palette, 100);

  .paginated-table-paginator {
    --mat-paginator-enabled-icon-color: #{$accent};
    --mat-select-enabled-arrow-color: #{$accent};
  }

  .paginated-table {
    a {
      color: $accent;
    }

    .mat-mdc-row.selected-row {
      background-color: $accent-100 !important;

      &:hover {
        background: darken($accent-100, 3%) !important;
      }
    }
  }
}

.paginated-table {
  --mat-table-row-item-outline-width: 0;
  --mat-table-row-item-container-height: 28px;
  --mat-table-header-container-height: 40px;
  --mat-table-header-headline-weight: #{map.get(typography.$font-weights, semibold)};
  --mat-table-row-item-outline-color: #999;

  border: 1px solid #e7e7e7;
  border-radius: 10px;
  overflow: auto hidden;

  .table-container {
    min-width: 100%;
    filter: drop-shadow(10px 20px 40px rgba(0, 0, 0, 0.05));
    border-collapse: collapse;
    overflow: hidden;
  }

  .mat-mdc-header-cell,
  .mat-mdc-cell {
    @include typography.text-sm;
    color: #333;
    padding: 2px 16px;
    text-align: center;
    white-space: nowrap;
    width: 187.33px;
    max-width: 187.33px;
  }

  .mat-column-__epagSelection__ {
    min-width: 44px;
    width: 44px;
    max-width: 44px;
  }

  .selection-cell {
    padding: 0;
  }

  .selection-cell .mat-mdc-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;

    .mdc-checkbox__native-control {
      width: 100%;
      height: 100%;
    }
  }

  .header-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
  }

  .header-icon {
    @include typography.text-xs;
    color: #777;
    cursor: help;
    height: 14px;
    line-height: 14px;
    width: 14px;
  }

  .mat-mdc-header-cell:not(:last-child),
  .mat-mdc-cell:not(:last-child) {
    border-right: 1px solid #999;
  }

  .mat-mdc-row:nth-child(odd) {
    background-color: #f0f0f0;
  }

  .copy-cell {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .truncated-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 30px);
    min-width: 120px;
    text-align: center;
  }

  .mat-icon {
    padding-top: 1px;
    height: 15px;
    width: 15px;
    font-size: 15px;
  }

  .mdc-checkbox {
    padding: 0;

    .mdc-checkbox__background {
      top: 0;
      left: 0;
    }
  }

  .centered-cell {
    text-align: center;
    vertical-align: middle;
    padding: 0;
    text-align: -webkit-center;
  }

  .centered-cell lib-general-status-card {
    display: inline-block;
    margin: 0 auto;
  }

  ::ng-deep {
    > lib-loader .spinner {
      @include mixins.flexCentering;
      margin: 10px 0;
    }
  }
}

.paginated-table-paginator {
  @include typography.text-sm;

  ::ng-deep {
    .mdc-text-field {
      --mdc-outlined-text-field-outline-width: 0;
      --mat-paginator-select-trigger-text-size: #{map.get(typography.$font-sizes, 'sm', 'size')};
      padding: 0 12px;
    }

    .mat-mdc-paginator-page-size-select {
      width: 58px;
    }

    .mat-mdc-paginator-container {
      padding: 0;
    }

    .mat-mdc-paginator-page-size {
      margin-right: 0;
    }
  }
}
