//
// Buttons
// --------------------------------------------------

// Base styles
// --------------------------------------------------

// Core
.btn {
  display: inline-block;
  font-weight: $btn-font-weight;
  line-height: $btn-line-height;
  font-size: $font-size-base;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  border: none;

  @include button-size($btn-padding-y, $btn-padding-x, $font-size-base, $btn-border-radius);

  &,
  &:active,
  &.active {
    &:focus,
    &.focus {
      @include tab-focus();
    }
  }

  @include hover-focus {
    text-decoration: none;
  }
  &.focus {
    text-decoration: none;
  }

  &:active,
  &.active {
    background-image: none;
    outline: 0;
  }

  &.disabled,
  &[disabled],
  &:disabled {
    cursor: $cursor-disabled;
    opacity: 0.65;
    @include box-shadow(none);
  }
}

// Button Sizes
// --------------------------------------------------
// XLarge
.btn-xlarge {
  @include button-size($btn-padding-y-xl, $btn-padding-x-xl, $font-size-lg, $btn-border-radius);
  font-weight: normal;
  padding-bottom: $btn-padding-y-xl - 3;
  .gicon {
    font-size: 31px;
    margin-right: 1rem;
  }
}

// Large
.btn-large {
  @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $font-size-lg, $btn-border-radius);
  font-weight: normal;
}

.btn-small {
  @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-sm, $btn-border-radius);
}

.btn-mini {
  @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-xs, $btn-border-radius);
}

.btn-link {
  color: $btn-link-color;
}

// Set the backgrounds
// -------------------------
.btn-primary {
  @include buttonBackground($btn-primary-bg, $btn-primary-bg-hl);
}
.btn-secondary {
  @include buttonBackground($btn-secondary-bg, $btn-secondary-bg-hl);
}
// Warning appears are orange
.btn-warning {
  @include buttonBackground($btn-warning-bg, $btn-warning-bg-hl);
}

// Danger and error appear as red
.btn-danger {
  @include buttonBackground($btn-danger-bg, $btn-danger-bg-hl);
}
// Success appears as green
.btn-success {
  @include buttonBackground($btn-success-bg, $btn-success-bg-hl);
}
// Info appears as a neutral blue
.btn-secondary {
  @include buttonBackground($btn-secondary-bg, $btn-secondary-bg-hl);
}
// Inverse appears as dark gray
.btn-inverse {
  @include buttonBackground($btn-inverse-bg, $btn-inverse-bg-hl, $btn-inverse-text-color, $btn-inverse-text-shadow);
  //background: $card-background;
  box-shadow: $card-shadow;
  //border: 1px solid $tight-form-func-highlight-bg;
}

.btn-transparent {
  background-color: transparent;
}

.btn-outline-primary {
  @include button-outline-variant($btn-primary-bg);
}
.btn-outline-secondary {
  @include button-outline-variant($btn-secondary-bg);
}
.btn-outline-inverse {
  @include button-outline-variant($btn-inverse-bg);
}
.btn-outline-success {
  @include button-outline-variant($btn-success-bg);
}
.btn-outline-warning {
  @include button-outline-variant($btn-warning-bg);
}
.btn-outline-danger {
  @include button-outline-variant($btn-danger-bg);
}
.btn-outline-disabled {
  @include button-outline-variant($gray-1);
  @include box-shadow(none);
  cursor: default;

  &:hover,
  &:active,
  &:active:hover,
  &:focus {
    color: $gray-1;
    background-color: transparent;
    border-color: $gray-1;
  }
}

// Extra padding
.btn-p-x-2 {
  padding-left: 20px;
  padding-right: 20px;
}

// External services
// Usage:
// <div class="btn btn-service btn-service--facebook">Button text</div>

$btn-service-icon-width: 35px;
.btn-service {
  position: relative;
}

@each $service, $data in $external-services {
  $serviceBgColor: map-get($data, bgColor);
  $serviceBorderColor: map-get($data, borderColor);

  .btn-service--#{$service} {
    background-color: $serviceBgColor;
    border: 1px solid $serviceBorderColor;

    .btn-service-icon {
      font-size: 24px; // Override
      border-right: 1px solid $serviceBorderColor;
    }
  }
}

.btn-service-icon {
  position: absolute;
  left: 0;
  height: 100%;
  top: 0;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  width: $btn-service-icon-width;
  text-align: center;

  &::before {
    position: relative;
    top: 4px;
  }
}

.btn-service--grafanacom {
  .btn-service-icon {
    background-image: url(/public/img/grafana_mask_icon_white.svg);
    background-repeat: no-repeat;
    background-position: 50%;
    background-size: 60%;
  }
}
