@use '@/styles/variables' as *;
@use '@/styles/mixins' as *;

.button {
  @include button-base;
  position: relative;

  &--primary {
    background-color: $primary-color;
    color: #ffffff;

    &:hover:not(:disabled) {
      background-color: $primary-light;
    }

    &:active:not(:disabled) {
      background-color: $primary-dark;
    }
  }

  &--secondary {
    background-color: #ffffff;
    color: $primary-color;
    border: 1px solid $primary-color;

    &:hover:not(:disabled) {
      background-color: rgba($primary-color, 0.05);
    }

    &:active:not(:disabled) {
      background-color: rgba($primary-color, 0.1);
    }
  }

  &--outline {
    background-color: transparent;
    color: $text-primary;
    border: 1px solid $border-color;

    &:hover:not(:disabled) {
      border-color: $text-secondary;
      background-color: $background-color;
    }
  }

  &--ghost {
    background-color: transparent;
    color: $text-primary;

    &:hover:not(:disabled) {
      background-color: $background-color;
    }
  }

  &--danger {
    background-color: $error-color;
    color: #ffffff;

    &:hover:not(:disabled) {
      background-color: darken($error-color, 5%);
    }

    &:active:not(:disabled) {
      background-color: darken($error-color, 10%);
    }
  }

  &--sm {
    padding: $spacing-sm $spacing-base;
    font-size: $font-size-sm;
    border-radius: $border-radius-sm;
  }

  &--md {
    padding: $spacing-md $spacing-lg;
    font-size: $font-size-base;
  }

  &--lg {
    padding: $spacing-base $spacing-xl;
    font-size: $font-size-md;
  }

  &--fullWidth {
    width: 100%;
  }

  &--loading {
    pointer-events: none;
  }

  &__spinner {
    @include flex-center;
    width: 16px;
    height: 16px;

    svg {
      width: 100%;
      height: 100%;
      animation: spin 1s linear infinite;
    }
  }

  &__icon {
    @include flex-center;
    width: 16px;
    height: 16px;

    svg {
      width: 100%;
      height: 100%;
    }
  }

  &__text {
    flex: 1;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
