/*
 * Copyright (C) 2021 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@use '@angular/material' as mat;

@use '../gio-mat-palettes' as palettes;

@mixin mat-button() {
  @include mat.button-overrides(
    (
      outlined-label-text-weight: 700,
      filled-label-text-weight: 700,
      protected-label-text-weight: 700,
      text-label-text-weight: 700,
      outlined-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-space-palette, lighter10),
      text-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-space-palette, lighter10),
    )
  );

  .mdc-button {
    &:has(.mdc-button__label:empty) {
      min-width: 36px;

      .mat-icon {
        width: 22px;
        height: 22px;
        margin-right: -6px;
        margin-left: -6px;
        font-size: 22px;
      }
    }

    &[color='primary'] {
      &:not(:disabled, :hover) {
        @include mat.button-overrides(
          (
            filled-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-gradient-palette, button-contrast),
            text-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-gradient-palette, button-contrast),
            outlined-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-gradient-palette, button-contrast),
          )
        );

        background-image: mat.m2-get-color-from-palette(palettes.$mat-gradient-palette, button);
      }

      &[mat-stroked-button]:hover,
      &[mat-button]:hover {
        @include mat.button-overrides(
          (
            outlined-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-gradient-palette, button-contrast),
            outlined-ripple-color: var(--mat-ripple-color, rgba(0, 0, 0, 0.1)),
            text-label-text-color: mat.m2-get-color-from-palette(palettes.$mat-gradient-palette, button-contrast),
            text-ripple-color: var(--mat-ripple-color, rgba(0, 0, 0, 0.1)),
          )
        );

        background-color: mat.m2-get-color-from-palette(palettes.$mat-primary-palette, default);
      }
    }
  }
}
