@import "../colors";

button {
  width: auto !important;
}
input[type='submit'],
.btn {
  -webkit-appearance: none;
  align-items: center;
  border: 0;
  border-radius: 0.75rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.125);
  @include gradient(info);
  color: $white;
  cursor: pointer;
  display: inline-flex;
  font-size: 1.125rem;
  font-weight: 600;
  justify-content: center;
  letter-spacing: 0;
  line-height: 1.5;
  overflow: hidden;
  padding: 0.5rem 1.25rem;
  position: relative;
  text-align: center;
  text-decoration: none;
  transform: scale(1);
  transition:
    transform 0.125s ease-in-out,
    box-shadow 0.25s ease-in-out;
  user-select: none;

  &:hover,
  &:focus,
  &[aria-expanded='true'] {
    color: $white;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1875);
    // transform: scale(1.0625);
  }

  &.disabled,
  &[disabled='disabled'],
  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }

  svg {
    width: 24px;
    height: 24px;
    margin-left: -4px;
    margin-right: 6px;
  }

  &.primary {
    @include gradient(primary);
  }

  &.smoke {
    background-color: lighten(map-get($palette, smoke), 3%);
    color: darken(map-get($palette, smoke), 50%) !important;

    html[data-dark='true'] & {
      background-color: darken(map-get($palette, slate), 13%);
      color: lighten(map-get($palette, slate), 50%) !important;
    }
  }

  &.muted {
    @include gradient(muted);
  }

  &.warning {
    @include gradient(warning);
  }

  &.purple {
    @include gradient(purple);
  }

  &.ai {
    @include gradient(ai);
  }

  &.success {
    @include gradient(success);
    color: darken(map-get($palette, success), 33.3%) !important;
  }

  &.accent {
    @include gradient(accent);
    color: darken(map-get($palette, accent), 33.3%) !important;
  }

  &.danger,
  &.btn--destroy {
    @include gradient(error);
  }

  &.outlined {
    background: transparent;
    box-shadow: none;
    border: 2px solid map-get($palette, info);
    color: map-get($palette, info);

    &:hover,
    &:focus,
    &[aria-expanded='true'] {
      box-shadow: none;
      background: rgba(map-get($palette, info), 0.1);
    }

    &.primary {
      border-color: map-get($palette, primary);
      color: map-get($palette, primary);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, primary), 0.1);
      }
    }

    &.info {
      border-color: map-get($palette, info);
      color: map-get($palette, info);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, info), 0.1);
      }
    }

    &.warning {
      border-color: map-get($palette, warning);
      color: map-get($palette, warning);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, warning), 0.1);
      }
    }

    &.success {
      border-color: map-get($palette, success);
      color: map-get($palette, success) !important;
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, success), 0.1);
      }
    }

    &.danger {
      border-color: map-get($palette, error);
      color: map-get($palette, error);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, error), 0.1);
      }
    }

    &.accent {
      border-color: map-get($palette, accent);
      color: map-get($palette, accent);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, accent), 0.1);
      }
    }

    &.purple {
      border-color: map-get($palette, purple);
      color: map-get($palette, purple);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, purple), 0.1);
      }
    }

    &.ai {
      border-color: map-get($palette, ai);
      color: map-get($palette, ai);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, ai), 0.1);
      }
    }

    &.muted {
      border-color: map-get($palette, muted);
      color: map-get($palette, muted);
      &:hover, &:focus, &[aria-expanded='true'] {
        background: rgba(map-get($palette, muted), 0.1);
      }
    }
  }
}

.btn--form-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 0.75rem;
  text-align: center;
  line-height: 1.25;
  color: map-get($palette, info);
  background-color: rgba(map-get($palette, accent), 0.25);

  &:hover,
  &:focus {
    color: map-get($palette, info);
  }

  html[data-dark='true'] & {
    color: map-get($palette, white);
  }
}

.btn--form-option--disabled {
  background-color: rgba(map-get($palette, accent), 0.12);
  color: rgba(map-get($palette, info), 0.7);

  html[data-dark='true'] & {
    color: rgba(map-get($palette, white), 0.7);
  }

  cursor: default;
  pointer-events: none;
  user-select: none;
}

.btn-small {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.75;
  padding: 0.25rem 1rem;
}

.btn-tiny {
  padding: 0rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.75;
}

form .flex-auto + input[type='submit'] {
  height: 2.5rem;
}

.btn-group {
  display: inline-flex;
  align-items: center;

  @media (max-width: 32em) {
    .btn {
      margin-right: 8px;
    }

    &:not(.btn-group--no-wrap) {
      flex-wrap: wrap;

      .btn {
        margin-bottom: 8px;
      }
    }

    &.center {
      justify-content: center;
      .btn {
        margin: 8px;
      }
    }
  }

  @media (min-width: 32em) {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.125);
    border-radius: 0.75rem;

    .btn:first-child {
      border-radius: 0.75rem 0 0 0.75rem;
    }
    .btn {
      border-radius: 0;
      box-shadow: none;
      margin: 0;

      &:hover,
      &:focus {
        z-index: 2;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.125);
      }
    }
    .btn:last-child {
      border-radius: 0 0.75rem 0.75rem 0;
    }
  }
}


a.btn {
  display: inline-flex;
  align-items: center;
  line-height: 1.5;
  font-size: 1.125rem;
  font-weight: 600;
}