//Defualt button class (global styling)
.bh-btn {
  font-family: var(--bh-secondary-font-face);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--bh-border-radius);
  height: 36px;
  letter-spacing: 0.47px;
  transition: background-color 0.2s ease-out;
  text-decoration: none;
  padding: 0 16px;
  display: inline-block;
  margin: 0;
  -moz-appearance: none;
  -webkit-appearance: none;
  cursor: pointer;

  i {
      vertical-align: middle;

      &.left {
          margin-right: 5px
      }

      &.right {
          margin-left: 5px;
      }

  }

  //Primary button
  &.bh-primary {
      background-color: var(--surface-accent);
      color: var(--text-inverse);
      border: 0;

      i {
          color: var(--text-inverse);
      }

      &.bh-loading {
          background-color: var(--surface-accent-pressed);

          &::after {
              border: 2px solid var(--surface-base);
              border-top-color: transparent;
          }
      }

      &:focus-visible {
          background-color: var(--surface-accent);
          box-shadow: 0 0 0 2px var(--border-focus), inset 0 0 0 1px var(--text-inverse);
          outline-color: transparent;
          outline-width: 2px;
          outline-style: dotted;
      }

      &:hover {
          background-color: var(--surface-accent-hover);
          text-decoration: none;
          color: var(--text-inverse);
      }

      &:not(:disabled):active,
      &:not(:disabled).active {
          background-color: var(--surface-accent-pressed);
      }

      &:focus:active {
          box-shadow: none;
      }
  }

  //Secondary button
  &.bh-secondary {
      background-color: var(--surface-active);
      color: var(--text-inverse);
      border: 0;

      &.bh-loading {
          background-color: var(--surface-active-pressed);

          &::after {
              border: 2px solid var(--surface-base);
              border-top-color: transparent;
          }
      }

      &:focus-visible {
          background-color: var(--surface-active);
          box-shadow: 0 0 0 2px var(--border-focus), inset 0 0 0 3px var(--text-inverse);
          outline-color: transparent;
          outline-width: 2px;
          outline-style: dotted;
      }

      &:hover {
          background-color: var(--surface-active-hover);
          text-decoration: none;
          color: var(--text-inverse);
      }

      &:not(:disabled):active,
      &:not(:disabled).active {
          background-color: var(--surface-active-hover);
      }

      &:focus:active {
          box-shadow: none;
      }
  }

  //Outline buttons
  &.bh-outlined {
      &.outline-1 {
          background-color: var(--surface-base);
          color: var(--text-accent);
          border: 1px solid var(--border-base);

          &.bh-loading {
              background-color: var(--surface-base-pressed-accentblue);
  
              &::after {
                  border: 2px solid var(--surface-accent);
                  border-top-color: transparent;
              }
          }

          &:focus-visible {
              border: 1px solid var(--border-focus);
              box-shadow: 0 0 0 1px var(--border-focus);
              color: var(--text-accent);
              outline-color: transparent;
              outline-width: 2px;
              outline-style: dotted;
          }
  
          &:hover {
              text-decoration: none;
              background-color: var(--surface-base-hover-accentblue);
              color: var(--text-accent-hover);
          }

          &:not(:disabled):active, &:not(:disabled).active {
              background-color: var(--surface-base-pressed-accentblue);
              outline: 0;
              box-shadow: none;
              border: 1px solid var(--border-base);
              color: var(--text-accent-hover);
            }
          &.button-link {
              display: flex;
              justify-content: space-between;
              align-items: center;
              width: 304px;

              @media screen and (max-width: 640px) {
                  width: 100vw;
              }
          }
      }

      &.outline-2 {
          background-color: transparent;
          color: var(--text-inverse);
          border: 1px solid var(--icon-inverse);

          &.bh-loading {
              background-color: var(--surface-base-pressed);

              &::after {
                  border: 2px solid var(--surface-accent);
                  border-top-color: transparent;
              }
          }

          &:focus-visible {
              border: 1px solid var(--border-focus);
              box-shadow: 0 0 0 1px var(--text-inverse), 0 0 0 1px var(--border-focus);
              outline-color: transparent;
              outline-width: 2px;
              outline-style: dotted;
            }
          
            &:hover {
              text-decoration: none;
              background-color: var(--surface-base-hover);
              color: var(--text-subtle-hover);
            }
          
            &:focus:hover {
              border: 1px solid var(--border-focus);
            }

            &:not(:disabled):active, &:not(:disabled).active {
              background-color: var(--surface-base-pressed);
              outline: 0;
              box-shadow: none;
              color: var(--text-subtle-hover);
            }
      }

      &.outline-3 {
          background-color: var(--surface-base);
          color: var(--text-subtle);
          border: 1px solid var(--border-base);

          &.bh-loading {
              background-color: var(--surface-base-pressed);
  
              &::after {
                  border: 2px solid var(--surface-accent);
                  border-top-color: transparent;
              }
          }

          &:focus-visible {
              border: 1px solid var(--border-focus);
              box-shadow: 0 0 0 1px var(--border-focus);
              color: var(--text-subtle);
              outline-color: transparent;
              outline-width: 2px;
              outline-style: dotted;
          
              &.bh-outlined-3-button--loading {
                color: transparent;
              }
            }
          
            &:hover {
              text-decoration: none;
              background-color: var(--surface-base-hover);
              color: var(--text-subtle-hover);
            }

          &:not(:disabled):active, &:not(:disabled).active {
              background-color: var(--surface-base-pressed);
              outline: 0;
              box-shadow: none;
              border: 1px solid var(--border-base);
              color: var(--text-subtle-hover);
            }
      }

      &:focus:active {
          box-shadow: none;
      }

      &.disabled {
          background-color: var(--surface-disabled);
          color: var(--text-disabled);
          border: 1px solid var(--surface-disabled);
          cursor: not-allowed;
          pointer-events: none;
      }
  }

  //Text button
  &.bh-text-btn {
      background-color: var(--surface-base);
      color: var(--text-accent);
      border: 1px solid transparent;

      &.bh-loading {
          background-color: var(--surface-base-pressed-accentblue);

          &::after {
              border: 2px solid var(--surface-accent);
              border-top-color: transparent;
          }
      }

      &:focus-visible {
          border: 1px solid var(--border-focus);
          box-shadow: 0 0 0 1px var(--border-focus);
          color: var(--text-accent);
          outline-color: transparent;
          outline-width: 2px;
          outline-style: dotted;
      
          &.bh-text-button--loading {
            color: transparent;
          }
      }

      &:focus:hover {
          border: 1px solid var(--border-focus);
      }

      &:hover {
          background-color: var(--surface-base-hover-accentblue);
          color: var(--text-accent-hover);
          border: 1px solid transparent;
      }

      &:not(:disabled):active, &:not(:disabled).active {
          background-color: var(--surface-base-pressed-accentblue);
          outline: 0;
          box-shadow: none;
          border: 1px solid transparent;
          color: var(--text-accent-hover);
        }

      &:focus:active {
          box-shadow: none;
      }
  }

  //Default disable class
  &.disabled {
      background-color: var(--surface-disabled);
      color: var(--text-disabled);
      cursor: not-allowed;
      pointer-events: none;
  }

  //Small button class
  &.bh-sm {
      height: 30px;
      padding: 0 8px;

      &.bh-loading {
          &::after {
              width: 16px;
              height: 16px;
              border-width: 1px;
          }
      }
  }

  //Large button class
  &.bh-lg {
      height: 48px;

      &[href] {
          line-height: 48px;
      }

      &.bh-loading {
          &::after {
              width: 24px;
              height: 24px;
          }
      }
  }

  &[href] {
      line-height: 36px;
  }

  //Default loading class
  &.bh-loading {
      color: transparent !important;
      position: relative;

      &::after {
          content: '';
          position: absolute;
          display: block;
          width: 20px;
          height: 20px;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
          border-radius: 50%;
          border-top-color: transparent;
          transform-origin: center center;
          animation: rotate 2s infinite linear;
      }

      &:hover {
          color: transparent;
      }
  }

  &--icon-l,
  &--icon-r {
      display: flex;
      align-items: center;
      gap: 8px;
  }

  svg {
      width: 24px;
      flex: 0 0 24px;
      vertical-align: middle;

      path {
          fill: var(--icon-inverse);
      }
  }
}

/* Animations */
@keyframes rotate {
  0% {
      transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
      transform: translate(-50%, -50%) rotate(360deg);
  }
}
