@use './typography';
@use './colors';
@use 'sass:color';

@mixin icon-button {
  .seam-icon-btn {
    border-radius: 6px;
    border: 1px solid rgba(colors.$primary, 50%);
    cursor: pointer;
    background: colors.$white;
    padding: 2px;
    line-height: 0;
    width: 30px;
    height: 30px;
    font-size: 18px;
    color: colors.$primary;

    path {
      fill: colors.$primary;
    }

    &:hover {
      background: rgba(colors.$primary, 0.08);
    }

    &.seam-icon-btn-disabled,
    &:disabled {
      color: colors.$text-gray-2-5;
      border-color: colors.$text-gray-3;
      background: colors.$white;
      cursor: not-allowed;

      path {
        fill: colors.$text-gray-2-5;
      }
    }
  }
}

@mixin text-button {
  .seam-text-btn {
    color: colors.$primary;
    padding: 0;
    cursor: pointer;
    background: transparent;
    border: 0;

    &:hover {
      text-decoration: underline;
    }

    &.seam-btn-disabled,
    &:disabled {
      cursor: not-allowed;
      text-decoration: none;
    }
  }
}

@mixin button-size {
  &.seam-btn-small {
    font-size: 14px;
    line-height: 22px;
    border-radius: 6px;
    padding: 4px 10px;
  }

  &.seam-btn-medium {
    font-size: 16px;
    line-height: 26px;
    border-radius: 7px;
    padding: 6px 16px;
  }

  &.seam-btn-large {
    font-size: 19px;
    line-height: 30px;
    border-radius: 8px;
    padding: 8px 22px;
  }
}

@mixin button-variant {
  &.seam-btn-solid {
    background: colors.$primary;
    color: colors.$white;
    border: 1px solid colors.$primary;

    &:hover {
      background: colors.$primary-dark;
      border-color: colors.$primary-dark;
    }

    &.seam-btn-disabled,
    &:disabled {
      background: colors.$primary-dim;
      border-color: colors.$primary-dim;
    }
  }

  &.seam-btn-outline {
    color: colors.$primary;
    border: 1px solid colors.$primary-50;
    background: transparent;

    &:hover {
      background: colors.$primary-5;
    }

    &.seam-btn-disabled,
    &:disabled {
      background: transparent;
      color: colors.$primary-50;
    }
  }

  &.seam-btn-danger {
    color: colors.$status-red;
    border: 1px solid colors.$status-red;
    background: transparent;

    &:hover {
      color: color.scale(colors.$status-red, $lightness: 30%);
      border-color: color.scale(colors.$status-red, $lightness: 30%);
    }

    &.seam-btn-disabled,
    &:disabled {
      color: colors.$text-gray-2-5;
      border-color: colors.$text-gray-2-5;
    }
  }

  &.seam-btn-neutral {
    color: colors.$text-gray-1;
    border: 1px solid colors.$text-gray-2-5;

    &:hover {
      background: colors.$bg-a;
      border-color: colors.$text-gray-2-5;
    }

    &.seam-btn-disabled,
    &:disabled {
      color: colors.$text-gray-2-5;
      border-color: colors.$text-gray-3;
      background: colors.$white;
    }
  }
}

@mixin button {
  .seam-btn {
    @include typography.font-family;
    @include button-size;
    @include button-variant;

    position: relative;
    font-weight: 600;
    cursor: pointer;

    &.seam-btn-disabled,
    &:disabled {
      cursor: not-allowed;
    }

    .seam-btn-loading {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;

      --spinner-color: currentcolor;
    }

    .seam-btn-content {
      display: contents;
    }

    &.seam-btn-loading {
      .seam-btn-content {
        visibility: hidden;
      }
    }
  }
}

@mixin all {
  @include button;
  @include icon-button;
  @include text-button;
}
