@import './base';

$mbsc-material-accent: #009688 !default;
$mbsc-material-background: #eee !default;
$mbsc-material-text: #5b5b5b !default;

$mbsc-material-dark-accent: #81ccc4 !default;
$mbsc-material-dark-background: #303030 !default;
$mbsc-material-dark-text: #c2c2c2 !default;

/* Base colors */
$mbsc-material-primary: #3f97f6 !default;
$mbsc-material-secondary: #90979E !default;
$mbsc-material-success: #43BE5F !default;
$mbsc-material-danger: #f5504e !default;
$mbsc-material-warning: #f8b042 !default;
$mbsc-material-info: #5BB7C5 !default;
$mbsc-material-light: #fff !default;
$mbsc-material-dark: #47494A !default;

$mbsc-material-colors: ( // Colors map
  'background': $mbsc-material-background,
  'text': $mbsc-material-text,
  'accent': $mbsc-material-accent,
);

$mbsc-material-dark-colors: ( // Colors map
  'background': $mbsc-material-dark-background,
  'text': $mbsc-material-dark-text,
  'accent': $mbsc-material-dark-accent,
);

@function mbsc-material-colors($params) {
  $background: map-get($params, 'background');
  $text: map-get($params, 'text');
  $accent: map-get($params, 'accent');

  $snackbar-btn: hsl(hue($accent), saturation($accent), max(lightness($accent), 34%));

  $border: '';
  $gray-background: '';
  $snackbar: '';
  $background-contrast: '';
  $lv-item: '';

  // Light background
  @if (lightness($background) > 50%) {
    $border: lighten($text, 40%);
    $gray-background: darken($background, 23%);
    $snackbar: #323232;
    $background-contrast: #000;
  }
  // Dark background
  @else {
    $border: darken($text, 40%);
    $gray-background: lighten($background, 17%);
    $snackbar: #5b5b5b;
    $background-contrast: #fff;
  }

  @return ('ripple': $background-contrast,
    'border': $border,
    'gray-background': $gray-background,
    'background-contrast': $background-contrast,
    'snackbar': $snackbar,
    'snackbar-btn': $snackbar-btn,
    // Static colors
    'white-text': #fff,
    'dark-text': #000,
    'light-text': #eee,
    'error': #de3226,
  );
}

@mixin mbsc-material-common($theme, $params) {
  @include exports("common.#{$theme}.colors") {

    $text: map-get($params, text);
    $colors: mbsc-material-colors($params);
    $ripple: map-get($colors, ripple);

    .mbsc-#{$theme} {
      .mbsc-ripple {
        background: $ripple;
      }

      .mbsc-empty {
        color: $text;
      }
    }
  }
}
