/* Buttons & Button Groups - Bootstrap Compatible */

.btn(@type) {
  background: ~"var(--button-@{type}-background-color)";
  color: ~"var(--button-@{type}-text-color)";
  border: 1px solid ~"var(--button-@{type}-border-color)";
  text-decoration: none;
  &:hover:not(.active):not(.disabled):not([disabled]) {
    background: ~"var(--button-@{type}-background-color-hover)";
  }
  &.active {
    background: ~"var(--button-@{type}-background-color-active)";
    border-color: ~"var(--button-@{type}-border-color)";
  }
}

.btn {
  cursor: pointer;
  display: inline-block;
  padding: var(--input-padding-y) 1.5em; /* Compensate 1px for border */
  text-decoration:  none;
  font-weight: normal;
  border-radius: var(--border-radius);
  //box-shadow: 0 1px 0px rgba(0, 0, 0, .25);
  line-height: var(--input-line-height);
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  border: none;

  touch-action: manipulation;
  user-select: none;

  &.btn-default { .btn("default"); }
  &.btn-success { .btn("success"); }
  &.btn-danger { .btn("danger"); }

  &.btn-hover-outline {
    background: transparent;
    color: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    &:hover {
      border-color: var(--default-border-color);
    }
  }

  &.btn-app {
    border-inline-start: 5px solid var(--app-color);
  }

  &.btn-icon {
    padding-left: 1em;
    padding-right: 1em;
    .fa {
      margin-inline-end: 0;
    }
  }

  &.btn-sm { font-size: ~"calc(var(--default-text-size) * .75)"; padding: ~"calc(var(--input-padding-y) * .75)" ~"calc(var(--input-padding-x) * .75)"; }
  &.btn-lg { font-size: 1.2em; }

  &.active, &:active { box-shadow: inset 1px 1px 0px 0 rgba(0, 0, 0, .15); }
  &.disabled, &[disabled] { opacity: 0.5; cursor: not-allowed; }
  [data-type="toggle"] { display: none; }

  .fa {
    margin-inline-end: .25em;
  }
}

.btn-block {
  width: 100%;
}

.btn-group {
  position: relative;
  display: inline-flex;
  border-radius: var(--border-radius);
  .btn {
    flex: 1 0 auto;
    margin-inline-start: -1px;
  }
  &:not(.btn-group-vertical) > .btn:not(:first-child) {
    border-inline-start: 1px solid var(--default-border-color);
  }
  >.btn:first-child:not(:last-child):not([data-toggle="dropdown"]) {
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }
  >.btn:not(:first-child):not(:last-child):not([data-toggle="dropdown"]) {
    border-radius: 0;
  }
  >.btn:last-child:not(:first-child), >[data-toggle="dropdown"]:not(:first-child) {
    border-start-start-radius: 0;
    border-end-start-radius: 0;
  }
}

.btn-group-vertical {
  .btn {
    display: block;
    border-radius: 0;
    font-size: inherit;
    margin-top: -1px;
    &:first-child {
      border-start-start-radius: var(--border-radius);
      border-start-end-radius: var(--border-radius);
    }
    &:last-child {
      border-end-start-radius: var(--border-radius);
      border-end-end-radius: var(--border-radius);
    }
  }
}
