@import "~nord/src/sass/nord.scss";

$dark-icon-themes: "theme_dark", "theme_nord";

$font-family-sans-serif: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
$font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace;
$font-size-base: 14px;
$font-size-large: 18px;
$font-size-small: 12px;
$text-color: #000000;
$border-color: #f0f0f0;
$border-color-dark: #ddd;
$list-item-hover: #fbfbfb;
$list-icon-color: #c7c7cd;
$border-radius: 3px;
$line-height-base: 1.42857143;

$gray: #555;
$gray-light: #777;
$text-muted: $gray-light;

$brand-primary: #175ddc;
$brand-danger: #c83522;
$brand-success: #017e45;
$brand-info: #555555;
$brand-warning: #8b6609;
$brand-primary-accent: #1252a3;

$background-color: white;
$background-color-alt: #f9f9f9;
$background-color-alt2: #ededed; // Ensure the `window.main.ts` is updated with this value

$box-background-color: $background-color;
$box-background-hover-color: $list-item-hover;
$box-border-color: $border-color;
$border-color-alt: #c3c5c7;

$button-border-color: darken($border-color-dark, 12%);
$button-background-color: white;
$button-color: lighten($text-color, 40%);
$button-color-primary: darken($brand-primary, 8%);
$button-color-danger: darken($brand-danger, 10%);

$code-color: #c01176;
$code-color-dark: #f08dc7;
$code-color-nord: #dbb1d5;

$themes: (
  light: (
    textColor: $text-color,
    borderColor: $border-color-dark,
    backgroundColor: $background-color,
    borderColorAlt: $border-color-alt,
    backgroundColorAlt: $background-color-alt,
    // Ensure the `window.main.ts` is updated with this value
    backgroundColorAlt2: $background-color-alt2,
    scrollbarColor: rgba(100, 100, 100, 0.2),
    scrollbarHoverColor: rgba(100, 100, 100, 0.4),
    boxBackgroundColor: $box-background-color,
    boxBackgroundHoverColor: $box-background-hover-color,
    boxBorderColor: $box-border-color,
    headerBackgroundColor: $brand-primary,
    headerBorderColor: darken($brand-primary, 7%),
    headerInputBackgroundColor: darken($brand-primary, 8%),
    headerInputBackgroundFocusColor: darken($brand-primary, 10%),
    headerInputColor: #ffffff,
    headerInputPlaceholderColor: lighten($brand-primary, 35%),
    listItemBackgroundColor: $background-color,
    listItemBackgroundHoverColor: $list-item-hover,
    listItemBorderColor: $border-color,
    disabledIconColor: $list-icon-color,
    headingColor: $gray-light,
    headingButtonColor: lighten($gray-light, 30%),
    headingButtonHoverColor: $gray-light,
    labelColor: $gray-light,
    mutedColor: $text-muted,
    totpStrokeColor: $brand-primary,
    boxRowButtonColor: $brand-primary,
    boxRowButtonHoverColor: darken($brand-primary, 10%),
    inputBorderColor: darken($border-color-dark, 7%),
    inputBackgroundColor: #ffffff,
    inputPlaceholderColor: lighten($gray-light, 35%),
    buttonBackgroundColor: $button-background-color,
    buttonBorderColor: $button-border-color,
    buttonColor: $button-color,
    buttonPrimaryColor: $button-color-primary,
    buttonDangerColor: $button-color-danger,
    primaryColor: $brand-primary,
    primaryAccentColor: $brand-primary-accent,
    dangerColor: $brand-danger,
    successColor: $brand-success,
    infoColor: $brand-info,
    warningColor: $brand-warning,
    logoSuffix: "dark",
    passwordNumberColor: #007fde,
    passwordSpecialColor: #c40800,
    passwordCountText: #212529,
    calloutBorderColor: $border-color-dark,
    calloutBackgroundColor: $background-color,
    toastTextColor: #ffffff,
    accountSwitcherBackgroundColor: $background-color,
    accountSwitcherTextColor: #ffffff,
    svgSuffix: "-light.svg",
    hrColor: #eeeeee,
    codeColor: $code-color,
  ),
  dark: (
    textColor: #ffffff,
    borderColor: #15181e,
    backgroundColor: #1f242e,
    borderColorAlt: #6e788a,
    backgroundColorAlt: #2f343d,
    // Ensure the `window.main.ts` is updated with this value
    backgroundColorAlt2: #15181e,
    scrollbarColor: #6e788a,
    scrollbarHoverColor: #8d94a5,
    boxBackgroundColor: #2f343d,
    boxBackgroundHoverColor: #3c424e,
    boxBorderColor: #4c525f,
    headerBackgroundColor: #2f343d,
    headerBorderColor: #15181e,
    headerInputBackgroundColor: #3c424e,
    headerInputBackgroundFocusColor: #4c525f,
    headerInputColor: #ffffff,
    headerInputPlaceholderColor: #bac0ce,
    listItemBackgroundColor: #1f242e,
    listItemBackgroundHoverColor: #2f343d,
    listItemBorderColor: #4c525f,
    disabledIconColor: #6e7689,
    headingColor: #bac0ce,
    headingButtonColor: #bac0ce,
    headingButtonHoverColor: #ffffff,
    labelColor: #bac0ce,
    mutedColor: #bac0ce,
    totpStrokeColor: #4c525f,
    boxRowButtonColor: #bac0ce,
    boxRowButtonHoverColor: #ffffff,
    inputBorderColor: #4c525f,
    inputBackgroundColor: #2f343d,
    inputPlaceholderColor: #bac0ce,
    buttonBackgroundColor: #272b32,
    buttonBorderColor: #4c525f,
    buttonColor: #bac0ce,
    buttonPrimaryColor: #6f9df1,
    buttonDangerColor: #ff8d85,
    primaryColor: #6f9df1,
    primaryAccentColor: #6f9df1,
    dangerColor: #ff8d85,
    successColor: #52e07c,
    infoColor: #a4b0c6,
    warningColor: #ffeb66,
    logoSuffix: "white",
    passwordNumberColor: #6f9df1,
    passwordSpecialColor: #ff8d85,
    passwordCountText: #ffffff,
    calloutBorderColor: #4c525f,
    calloutBackgroundColor: #3c424e,
    toastTextColor: #1f242e,
    accountSwitcherBackgroundColor: #2f343d,
    accountSwitcherTextColor: #ffffff,
    svgSuffix: "-dark.svg",
    hrColor: #bac0ce,
    codeColor: $code-color-dark,
  ),
  nord: (
    textColor: $nord5,
    borderColor: $nord0,
    backgroundColor: $nord2,
    borderColorAlt: $nord5,
    backgroundColorAlt: $nord1,
    // Ensure the `window.main.ts` is updated with this value
    backgroundColorAlt2: $nord1,
    scrollbarColor: $nord4,
    scrollbarHoverColor: $nord6,
    boxBackgroundColor: $nord2,
    boxBackgroundHoverColor: $nord3,
    boxBorderColor: $nord1,
    headerBackgroundColor: $nord2,
    headerBorderColor: $nord0,
    headerInputBackgroundColor: $nord6,
    headerInputBackgroundFocusColor: $nord5,
    headerInputColor: $nord2,
    headerInputPlaceholderColor: $nord3,
    listItemBackgroundColor: $nord2,
    listItemBackgroundHoverColor: $nord3,
    listItemBorderColor: $nord1,
    disabledIconColor: $nord5,
    headingColor: $nord4,
    headingButtonColor: $nord5,
    headingButtonHoverColor: $nord6,
    labelColor: $nord4,
    mutedColor: $nord4,
    totpStrokeColor: $nord4,
    boxRowButtonColor: $nord4,
    boxRowButtonHoverColor: $nord6,
    inputBorderColor: $nord0,
    inputBackgroundColor: $nord2,
    inputPlaceholderColor: lighten($nord3, 20%),
    buttonBackgroundColor: $nord3,
    buttonBorderColor: $nord0,
    buttonColor: $nord5,
    buttonPrimaryColor: $nord8,
    buttonDangerColor: $nord11,
    primaryColor: $nord9,
    primaryAccentColor: $nord8,
    dangerColor: $nord11,
    successColor: $nord14,
    infoColor: $nord9,
    warningColor: $nord12,
    logoSuffix: "white",
    passwordNumberColor: $nord8,
    passwordSpecialColor: $nord12,
    passwordCountText: $nord5,
    calloutBorderColor: $nord1,
    calloutBackgroundColor: $nord2,
    toastTextColor: #000000,
    accountSwitcherBackgroundColor: $nord0,
    accountSwitcherTextColor: $nord5,
    svgSuffix: "-dark.svg",
    hrColor: $nord4,
    codeColor: $code-color-nord,
  ),
);

@mixin themify($themes: $themes) {
  @each $theme, $map in $themes {
    html.theme_#{$theme} & {
      $theme-map: () !global;
      @each $key, $submap in $map {
        $value: map-get(map-get($themes, $theme), "#{$key}");
        $theme-map: map-merge(
          $theme-map,
          (
            $key: $value,
          )
        ) !global;
      }
      @content;
      $theme-map: null !global;
    }
  }
}

@function themed($key) {
  @return map-get($theme-map, $key);
}
