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

@mixin color($theme) {
  $config: mat.get-color-config($theme);
  $foreground: map.get($config, foreground);
  $background: map.get($config, background);
  $is-dark-theme: map.get($config, is-dark);
  $popoverBackground: if($is-dark-theme, map_get(mat.$grey-palette, 900), map_get(mat.$grey-palette, 200));
  $cardBackground: mat.get-color-from-palette($background, card);
  $divider: mat.get-color-from-palette($foreground, divider);

  mtna-popover-component {
    .popover-div {
      background: $cardBackground;
      color: mat.get-color-from-palette($foreground, text);
      border-color: $divider;
      .popover-title {
        background: $popoverBackground;
        border-bottom-color: $divider;
      }
      .popover-arrow {
        border-color: transparent;
        &:after {
          border-color: transparent;
        }
        &.left,
        &.before {
          border-left-color: $divider;
          &:after {
            border-left-color: $cardBackground;
          }
        }
        &.below {
          border-bottom-color: $divider;
          &:after {
            border-bottom-color: $popoverBackground;
          }
        }
        &.right,
        &.after {
          border-right-color: $divider;
          &:after {
            border-right-color: $cardBackground;
          }
        }
        &.above {
          border-top-color: $divider;
          &:after {
            border-top-color: $cardBackground;
          }
        }
      }
    }
  }
}

@mixin typography($theme) {
  $typography-config: mat.get-typography-config($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);
  }
}
