@use '@angular/material' as mat;

@mixin form-theme($theme) {
  $primary-color: mat.get-theme-color($theme, primary, 70);
  $secondary-color: mat.get-theme-color($theme, secondary, 70);

  .secondary-container-background {
    background-color: mat.get-theme-color($theme, secondary-container);
  }

  .mdc-text-field--outlined:not(.mdc-text-field--disabled) {
    .mat-mdc-notch-piece {
      border-width: 2px;
      border-color: rgba(mat.get-theme-color($theme, primary, 80), 0.4);
    }

    &:not(.mdc-text-field--focused):hover .mat-mdc-notch-piece {
      border-color: rgba(mat.get-theme-color($theme, primary, 80), 0.6);
    }

    &.mdc-text-field--focused .mat-mdc-notch-piece {
      border-color: mat.get-theme-color($theme, primary, 80);
    }
  }

  .mat-mdc-unelevated-button:not(.mat-warn):not(:disabled) {
    background-color: mat.get-theme-color($theme, secondary, 60);
    color: mat.get-theme-color($theme, on-secondary);
  }

  .mat-radio-button {
    @include mat.radio-theme(
      (
        color: (
          selected: $secondary-color,
          unselected: $primary-color,
        ),
      )
    );
  }

  .mat-mdc-table {
    .mat-mdc-header-cell {
      font-weight: 600;
      border-bottom-color: rgba(mat.get-theme-color($theme, on-surface), 0.2);
    }

    .mat-mdc-row {
      &:hover {
        background-color: rgba(mat.get-theme-color($theme, on-surface), 0.02);
      }
    }

    .mat-mdc-cell {
      border-bottom-color: rgba(mat.get-theme-color($theme, on-surface), 0.1);
    }
  }

  .mat-mdc-checkbox {
    .mdc-checkbox__native-control:enabled:checked ~ .mdc-checkbox__background,
    .mdc-checkbox__native-control:enabled:indeterminate
      ~ .mdc-checkbox__background {
      background-color: mat.get-theme-color($theme, primary, 70);
      border-color: mat.get-theme-color($theme, primary, 70);
    }

    .mdc-checkbox__checkmark {
      color: mat.get-theme-color($theme, on-primary);
    }
  }

  .mat-checkbox {
    @include mat.checkbox-theme(
      (
        color: (
          selected: $primary-color,
          unselected: $primary-color,
        ),
      )
    );
  }
}
