/*
 * CloudBeaver - Cloud Database Manager
 * Copyright (C) 2020-2024 DBeaver Corp and others
 *
 * Licensed under the Apache License, Version 2.0.
 * you may not use this file except in compliance with the License.
 */

@import '@material/switch/mixins';

@mixin switch-core-styles($query: mdc-feature-all()) {
  @include mdc-switch-core-styles($query);

  .theme-switch {
    @extend .mdc-switch;
  }
  .theme-switch_native-control {
    @extend .mdc-switch__native-control;

    &:disabled {
      opacity: 0;
    }
  }
  .theme-switch__track {
    @extend .mdc-switch__track;
  }
  .theme-switch__thumb-underlay {
    @extend .mdc-switch__thumb-underlay;
  }
  .theme-switch__thumb {
    @extend .mdc-switch__thumb;
  }
  .theme-switch--checked {
    @extend .mdc-switch--checked;
  }
  .theme-switch--disabled {
    @extend .mdc-switch--disabled;
  }

  .theme-switch_dense {
    @include switch-core-styles-dense($query);
  }

  .theme-switch_dense .theme-switch_primary,
  .theme-switch_primary {
    $mdc-switch-baseline-theme-color: primary;

    @include mdc-switch-toggled-on-track-color($mdc-switch-baseline-theme-color, $query);
    @include mdc-switch-toggled-on-thumb-color($mdc-switch-baseline-theme-color, $query);
    @include mdc-switch-toggled-off-track-color($mdc-switch-toggled-off-track-color, $query);
    @include mdc-switch-toggled-off-thumb-color($mdc-switch-toggled-off-thumb-color, $query);
  }
}

@mixin switch-core-styles-dense($query: mdc-feature-all()) {
  $mdc-switch-baseline-theme-color: primary !global;
  $mdc-switch-track-width: 24px !global;
  $mdc-switch-track-height: 10px !global;
  $mdc-switch-thumb-diameter: 14px !global;
  $mdc-switch-ripple-size: 36px !global;
  $mdc-switch-toggled-off-thumb-color: lighten($mdc-switch-toggled-off-thumb-color, 5%) !global;

  $mdc-switch-minimum-size: 24px !global;
  $mdc-switch-maximum-size: $mdc-switch-ripple-size !global;
  $mdc-switch-density-scale: $mdc-density-default-scale !global;
  $mdc-switch-density-config: (
    size: (
      minimum: $mdc-switch-minimum-size,
      default: $mdc-switch-maximum-size,
      maximum: $mdc-switch-maximum-size,
    ),
  ) !global;

  $mdc-switch-thumb-offset: 2px !global;

  $mdc-switch-thumb-active-margin: $mdc-switch-track-width - $mdc-switch-thumb-diameter + $mdc-switch-thumb-offset * 2 !global;

  @include mdc-switch-core-styles($query);
}
