@use 'sass:map';
@use '~@mtna/core-angular' as mtna;
@use '~@angular/material' as mat;

@mixin color($theme) {
  $config: mat.get-color-config($theme);
  $is-dark-theme: map.get($config, is-dark);
  $background: map.get($config, background);
  $foreground: map.get($config, foreground);
  $focusBackground: if($is-dark-theme, map_get(mat.$grey-palette, 800), map_get(mat.$grey-palette, 100));
  $inspectedBackground: if($is-dark-theme, map_get(mat.$grey-palette, 700), map_get(mat.$grey-palette, 200));

  rds-c-select-table {
    @include mtna.resizable-table-theme($theme);
    @include mtna.ghost-table-theme($theme);

    .mat-table {
      // hovering over a header cell, not when ghost, not when another cell is being resized
      &:not(.mtna-ghost-table):not(.resize-active) th.mat-header-cell.rds-c-can-inspect-cell {
        &:hover,
        &:focus-within {
          background-color: $focusBackground;
        }
      }
      th.mat-header-cell {
        &.inspected {
          background-color: $inspectedBackground;
          color: mat.get-color-from-palette($foreground, text);
        }
      }
      td.rds-c-select-table-locked-column {
        background: mat.get-color-from-palette($background, card);
      }
      .rds-c-select-table-last-locked-column {
        border-right-color: mat.get-color-from-palette($foreground, divider);
      }
      rds-c-select-table-decorators svg {
        fill: mat.get-color-from-palette($foreground, icon);
      }
    }
  }
}

@mixin typography($theme) {
}

@mixin theme($theme) {
  $config: mat.get-color-config($theme);
  @if $config != null {
    @include color($theme);
  }

  $typography-config: mat.get-typography-config($theme);
  @if $typography-config != null {
    @include typography($theme);
  }
}
