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

// Assets
@use 'overlayscrollbars/overlayscrollbars.css';

// Styles
@use 'style/utilities/design-system-utilities' as ds-utilities;
@forward 'style/typography';
@use 'style/common';
@use 'style/static-colors' as static-colors;
@forward 'style/colors';
@use 'style/colors' as colors;
@use 'style/angular-material/angular-material-components' as mat-components;
@use 'style/design-system/design-system-components' as ds-components;
@use 'style/font-michelin-unit-titling';
@use 'style/font-noto-sans';
@use 'style/material-icons';
@use 'style/icons';
@use 'style/print';

$michelin-typography: mat.m2-define-typography-config(
  $font-family: 'Noto Sans'
);

// Theme definition
@mixin design-system-theme($theme, $init, $secondary: mat.m2-define-palette(colors.$mic-grey, A400, A100, A700)) {
  mat.$theme-ignore-duplication-warnings: true;
  @include mat.elevation-classes();
  @include mat.app-background();

  $primary: map.get($theme, primary);
  $warn: map.get($theme, warn);
  $accent: map.get($theme, accent);
  $is-dark: map.get($theme, is-dark);

  $full-primary-theme: mat.m2-define-light-theme(
    (
      color: (
        primary: $primary,
        accent: $accent,
        warn: $warn
      ),
      density: 0
    )
  );

  $full-primary-dark-theme: mat.m2-define-dark-theme(
    (
      color: (
        primary: $primary,
        accent: $accent,
        warn: $warn
      ),
      density: 0
    )
  );

  @if $is-dark {
    $theme: static-colors.angular-material-override-dark-colors($theme);
    @include mat.all-component-themes($full-primary-dark-theme);
  } @else {
    $theme: static-colors.angular-material-override-light-colors($theme);
    @include mat.all-component-themes($full-primary-theme);
  }

  @if not $init {
    @include mat.elevation-classes();
    @include mat.app-background();
  }

  @include ds-utilities.design-system-utilities();
  @include mat-components.angular-material-components-override($theme, $secondary);
  @include ds-components.design-system-components-override($theme);

  @include mat.progress-bar-color($full-primary-theme);
  @include mat.progress-spinner-color($full-primary-theme);
  @include mat.slide-toggle-color($full-primary-theme);
  @include mat.pseudo-checkbox-color($full-primary-theme);

  @if $is-dark {
    @include mat.checkbox-color($full-primary-dark-theme);
    @include mat.radio-color($full-primary-dark-theme);
    @include mat.tabs-color($full-primary-dark-theme);
    @include mat.form-field-color($full-primary-dark-theme);
    @include mat.stepper-color($full-primary-dark-theme);
    @include mat.select-color($full-primary-dark-theme);
  } @else {
    @include mat.checkbox-color($full-primary-theme);
    @include mat.radio-color($full-primary-theme);
    @include mat.tabs-color($full-primary-theme);
    @include mat.form-field-color($full-primary-theme);
    @include mat.stepper-color($full-primary-theme);
    @include mat.select-color($full-primary-theme);
  }
}
