$btn-padding: 0 10px;
$btn-sm-padding: 0 7px 0 7px;
$btn-height: 32px;
$btn-sm-height: 32px;

// -----------------------------------------------------------------------------
// This file contains all styles related to the button component.
// -----------------------------------------------------------------------------
.btn,
button,
[class^='btn-'] {
  align-items: center;
  display: inline-flex;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  border: 0;
  padding: $btn-padding;
  border-radius: var(--border-radius);
  // color: var(--lightest);
  line-height: $btn-height !important;
  height: $btn-height !important;
  min-width: 100px;
  justify-content: center;
  

  > .icon:not(:only-child) {
    margin-right: 6px;
  }

  &:hover {
    text-decoration: none;
    // color: var(--lightest);
  }

  &.bg-transparent {
    color: var(--body-text);
  }
}

.bg-primary {
  color: var(--lightest);
}

//icon button
.icon-btn {
  padding: 0;
  line-height: initial;

  &.btn-sm {
    padding: 0;
  }

  span {
    padding: 0 10px 0 5px;
    vertical-align: middle;
  }
}

.btn-sm,
.btn-group-sm > .btn,
.btn-sm .btn-label {
  padding: $btn-sm-padding;
  min-height: $btn-sm-height;
  line-height: 32px;
  min-width: 100px;
}

//btn roles
.role-primary {
  background: var(--primary);
  color: var(--primary-text);

  &:hover, &._hover {
    // background-color: var(--primary-hover-bg);
    color: var(--primary-text);
    box-shadow: 0 4px 6px 0 rgba(0,0,0,.2)!important;
  }

  &:focus, &.focused {
    background-color: var(--primary-hover-bg);
    color: var(--primary-text);
  }

  &:focus-visible {
    @include focus-outline;
    outline-offset: 2px;
  }
}

.role-secondary {
  background: transparent;
  color: var(--input-label) !important;
  // border: solid 1px var(--primary);
  border: solid 1px #d9d9d9;
  line-height: $btn-height - 2px;
  min-width: 100px;

  &:hover, &._hover {
    // color: var(--lightest) !important;
    color: var(--input-label) !important;
    box-shadow: 0 4px 6px 0 rgba(0,0,0,.2)!important;
  }

  &:focus, &.focused {
    background: transparent;
    box-shadow: 0 4px 6px 0 rgba(0,0,0,.2)!important;
    // background-color: var(--primary-hover-bg);
    // color: var(--lightest) !important;
    color: var(--input-label) !important;
    // color: var(--primary-text) !important;
  }

  &.btn-sm {
    line-height: $btn-sm-height - 2px;

    &:focus, &.focused {
      border: 0;
    }
  }
}

.role-tertiary {
  background: var(--accent-btn);
  border: solid 1px var(--primary);
  color: var(--primary);

  &:focus, &.focused, &:hover {
    // background-color: var(--primary-hover-bg);
    // color: var(--primary-text);
    background-color: var(--accent-btn);
    color: var(--primary);
  }

  &.btn:not(.btn-sm) {
    line-height: $btn-height - 2px;
  }

  &:focus-visible {
    @include focus-outline;
    outline-offset: 2px;
  }
}

.role-link {
  background: transparent;
  color: var(--link);

  &:hover, &._hover {
    // color: var(--lightest);
    color: var(--link);
  }

  &:focus, &.focused {
    background: transparent;
    color: var(--link);
    box-shadow: none;
  }

  &:focus-visible {
    @include focus-outline;
    outline-offset: 2px;
  }
}

.role-multi-action {
  //  background: var(--accent-btn);
  //  border: solid thin var(--primary);
   color: var(--primary) !important;
   border-radius: 2px;
   min-width: 32px;
   height: 32px;
   width: 32px;
}

.icon-group i {
  font-size: 1.5em;
}

//disabled
.btn-disabled,
.btn.disabled,
.btn[disabled],
fieldset[disabled] .btn {
  cursor: not-allowed;
  color: var(--disabled-text) !important;
  &:not(.role-link){
    background-color: var(--disabled-bg) !important;
    border-color: var(--disabled-bg) !important;
  }
}

.btn-group {
  position: relative;
  text-align: initial;
  vertical-align: middle;
  padding: 0;
  border-radius: var(--border-radius);

  .btn {
    position: relative;
    display: inline-flex;
    border-radius: 0;
    text-align: center;

    &:focus {
      // Move the focused one to the top so that the focus ring is all visible
      z-index: 1;
    }

    &:focus-visible {
      z-index: 1;
      @include focus-outline;
    }
    
    &.active {
      @extend .bg-primary;
    }

    &:first-child {
      border-top-left-radius: var(--border-radius);
      border-bottom-left-radius: var(--border-radius);
    }

    &:last-child {
      border-top-right-radius: var(--border-radius);
      border-bottom-right-radius: var(--border-radius);
    }
  }

  .btn-disabled,
  .btn[disabled] {
    // Ensure disabled button's border remains as-is, otherwise button appears vertically shorter than others in group
    border: inherit;
  }
}
