@import './Button.vars.less';
  
/* Button Styles */
.wds-Button {
  display: inline-flex;
  flex: none;
  width: auto;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  font-weight: var(--Button-font-weight);
  font-size: var(--Button-font-size);
  letter-spacing: var(--Button-letter-spacing);
  line-height: var(--Button-line-height);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  word-wrap: break-word;
  appearance: none;
  background-color: var(--Button-background);
  border: none;
  border-radius: var(--Button-border-radius);
  color: var(--Button-color);
  cursor: pointer;
  padding: var(--Button-padding);
  
  &:focus {
    text-decoration: none;
  }

  &:hover {
    background-color: var(--Button-hover-background);
    text-decoration: none;
  }

  &:active {
    background-color: var(--Button-active-background);
    text-decoration: none;
  }

  &:disabled {
    mix-blend-mode: luminosity;
    opacity: 0.45;
    cursor: not-allowed;

    &:hover,
    &:active {
      background-color: var(--Button-background);
    }
  }

  // Priority modifiers
  &--secondary {
    --Button-background: var(--Button-secondary-background);
    --Button-hover-background: var(--Button-secondary-hover-background);
    --Button-active-background: var(--Button-secondary-active-background);
    --Button-color: var(--Button-secondary-color);
  }

  &--tertiary {
    --Button-background: var(--Button-tertiary-background);
    --Button-hover-background: var(--Button-tertiary-hover-background);
    --Button-active-background: var(--Button-tertiary-active-background);
    --Button-color: var(--Button-tertiary-color);

    .wds-Button-icon--right {
      color: var(--color-interactive-primary);
    }
  }

  &--minimal {
    --Button-background: var(--Button-minimal-background);
    --Button-hover-background: var(--Button-minimal-hover-background);
    --Button-active-background: var(--Button-minimal-active-background);
    --Button-color: var(--Button-minimal-color);

    text-decoration: underline;

    &:hover,
    &:hover:active {
      text-decoration: underline;
    }
  }

  // Negative styles
  &--negative {

    &.wds-Button--primary {
      --Button-background: var(--Button-primary-negative-background);
      --Button-hover-background: var(--Button-primary-negative-hover-background);
      --Button-active-background: var(--Button-primary-negative-active-background);
      --Button-color: var(--Button-primary-negative-color);
      --Button-avatar-border-color: var(--Button-primary-netative-avatar-border-color);
    }

    &.wds-Button--secondary {
      --Button-background: var(--Button-secondary-negative-background);
      --Button-hover-background: var(--Button-secondary-negative-hover-background);
      --Button-active-background: var(--Button-secondary-negative-active-background);
      --Button-color: var(--Button-secondary-negative-color);
      --Button-avatar-border-color: var(--Button-secondary-netative-avatar-border-color);
    }
  }

  // Size modifiers
  &--small {
    --Button-padding: var(--Button-size-small-padding);
    --Button-line-height: 22px;
    --Button-font-size: var(--font-size-14);
    --Button-letter-spacing: -0.006em;

    .wds-Button-icon--left {
      margin-right: var(--size-4);
      :dir(rtl) & {
        margin-right: 0;
        margin-left: var(--size-4);
      }
    }
  }

  &--medium {
    --Button-padding: var(--Button-size-medium-padding);
  }

  &--large {
    --Button-padding: var(--Button-size-large-padding);
  }

  &--iconOnly {
    padding: 0;
  }

  // Width mofidiers
  &--block {
    width: 100%;
  }

  &-avatars {
    display: inline-flex;
    margin-right: 5px;
    margin-left: calc(var(--size-4) * -1);

    :dir(rtl) & {
      margin-right: 0;
      margin-left: 5px;
    }

    .np-circle {
      --circle-border-color: var(--Button-avatar-border-color);
    }

    .np-avatar-view .np-avatar-view-content {
      color: var(--Button-color);
    }
  }

  // Icon styles
  &-icon {
    display: inline-block;

    &--left {
      margin-right: var(--size-8);
      :dir(rtl) & {
        margin-right: 0;
        margin-left: var(--size-8);
      }
    }

    &--right {
      margin-left: var(--size-4);
      :dir(rtl) & {
        margin-left: 0;
        margin-right: var(--size-4);
      }
    }
  }

  &-content {
    position: relative;

    &--loading {
      .wds-Button-label,
      .wds-Button-media,
      .wds-Button-icon {
        visibility: hidden;
        opacity: 0;
      }
    }
  }

  &-label {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
  }

  &-loader {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;

    .process-circle {
      stroke: var(--Button-color);
    }
  }
}

/* RTL Styles */
:dir(rtl) {
  .wds-Button {
    .tw-icon-chevron-right,
    .tw-icon-arrow-right {
      transform: rotate(180deg);
    }
  
    .tw-icon-chevron-left,
    .tw-icon-arrow-left {
      transform: rotate(180deg);
    }
  }
}