/*
 * 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.
 */

@mixin button-core-styles() {
  $mdc-button-disabled-container-fill-color: #cccccc;
  $mdc-button-density-scale: -2;
  $query: mdc-feature-all();
  @include mdc-button-core-styles;
  @include mdc-button-theme-baseline;

  .theme-button {
    @extend .mdc-button;
    height: 32px;

    &[disabled] {
      opacity: 1;
    }
  }

  .theme-button__label {
    @extend .mdc-button__label;
  }

  .theme-button__icon {
    @extend .mdc-button__icon;
  }

  .theme-button_ripple {
    @extend .mdc-button__ripple;
  }

  .theme-button_raised {
    @extend .mdc-button--raised;
  }

  .theme-button_unelevated {
    @extend .mdc-button--unelevated;
  }

  .theme-button_outlined {
    @extend .mdc-button--outlined;

    &[disabled] {
      border-color: change-color($color: $mdc-theme-on-surface, $alpha: 0.37);
      color: change-color($color: $mdc-theme-on-surface, $alpha: 0.37);
      cursor: default;
      pointer-events: none;
    }
  }

  .theme-button_secondary {
    @include mdc-button-ink-color(secondary, $query);
    @include mdc-states($color: secondary, $query: $query, $ripple-target: $mdc-button-ripple-target);

    &.theme-button_outlined {
      @include mdc-button-outline-color(secondary, $query);
    }

    &.theme-button_raised,
    &.theme-button_unelevated {
      @include mdc-button-container-fill-color(secondary, $query);
      @include mdc-button-ink-color(on-secondary, $query);
      @include mdc-states($color: on-secondary, $query: $query, $ripple-target: $mdc-button-ripple-target);
    }
  }

  .theme-button_background {
    @include mdc-button-ink-color(background, $query);
    @include mdc-states($color: background, $query: $query, $ripple-target: $mdc-button-ripple-target);

    &.theme-button_outlined {
      @include mdc-button-outline-color(background, $query);
    }

    &.theme-button_raised,
    &.theme-button_unelevated {
      @include mdc-button-container-fill-color(background, $query);
      @include mdc-button-ink-color(on-secondary, $query);
      @include mdc-states($color: on-secondary, $query: $query, $ripple-target: $mdc-button-ripple-target);
    }
  }
}
