@use '@angular/material' as mat;

@import '@angular/material';

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

// Styles
@import 'style/utilities/design-system-utilities';
@import 'style/typography';
@import 'style/common';
@import 'style/static-colors';
@import 'style/colors';
@import 'style/angular-material/angular-material-components';
@import 'style/design-system/design-system-components';
@import 'style/font-michelin-unit-titling';
@import 'style/font-noto-sans';
@import 'style/material-icons';
@import 'style/icons';
@import '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($mic-grey, A400, A100, A700)) {
  mat.$theme-ignore-duplication-warnings: true;
  @include mat.core();

  $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: $primary,
        warn: $warn
      ),
      density: 0
    )
  );

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

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

  @if not $init {
    @include mat.core-color($theme);
  }

  @include design-system-utilities();
  @include angular-material-components-override($theme, $secondary);
  @include 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);
  }
}
