@import '@angular/material';

@function angular-material-override-dark-colors($theme) {
  $theme: override-dark-background-properties($theme);

  @return $theme;
}

@function angular-material-override-light-colors($theme) {
  $theme: override-light-foreground-properties($theme);
  $theme: override-light-background-properties($theme);

  @return $theme;
}

@function override-dark-background-properties($theme) {
  $background-overridden: map-merge(
    map-get(map-get($theme, color), background),
    (
      status-bar: black,
      app-bar: map-get($mic-grey, 900),
      menu: map-get($mic-grey, 800),
      sub-menu: map-get($mic-grey, 700),
      nav: map-get($mic-grey, 800),
      nav-menu: map-get($mic-grey, 700),
      background: map-get($mic-grey, 900),
      hover: rgba(white, 0.04),
      // TODO(kara): check style with Material Design UX
      card: map-get($mic-grey, 800),
      dialog: map-get($mic-grey, 600),
      disabled-button: rgba(white, 0.12),
      raised-button: map-get($mic-grey, 700),
      selected-button: map-get($mic-grey, 900),
      selected-disabled-button: map-get($mic-grey, 700),
      disabled-button-toggle: black,
      unselected-chip: map-get($mic-grey, 600),
      disabled-list-option: black,
      tooltip: map-get($mic-grey, 600)
    )
  );

  @return map-merge(
    $theme,
    (
      background: $background-overridden
    )
  );
}

@function override-light-foreground-properties($theme) {
  $primary: map-get($theme, primary);

  $foreground-overridden: map-merge(
    map-get(map-get($theme, color), foreground),
    (
      text: black
    )
  );

  @return map-merge(
    $theme,
    (
      foreground: $foreground-overridden
    )
  );
}

@function override-light-background-properties($theme) {
  $background-overridden: map-merge(
    map-get(map-get($theme, color), background),
    (
      status-bar: map-get($mic-grey, 300),
      app-bar: map-get($mic-grey, 200),
      menu: map-get($mic-grey, A100),
      sub-menu: map-get($mic-grey, 200),
      nav: map-get($mic-grey, A100),
      nav-menu: map-get($mic-grey, 200),
      background: map-get($mic-grey, 50),
      hover: rgba(black, 0.04),
      // TODO(kara): check style with Material Design UX
      card: white,
      dialog: white,
      disabled-button: rgba(black, 0.12),
      raised-button: white,
      selected-button: map-get($mic-grey, 300),
      selected-disabled-button: map-get($mic-grey, 400),
      disabled-button-toggle: map-get($mic-grey, 200),
      unselected-chip: map-get($mic-grey, 300),
      disabled-list-option: map-get($mic-grey, 200),
      tooltip: map-get($mic-grey, 700)
    )
  );

  @return map-merge(
    $theme,
    (
      background: $background-overridden
    )
  );
}
