@import "../../../themes/core/colors";
@import "button-base";
@import "button-theme";
$size: 48px;

.qms-btn-icon {
  @include base;
  @include typo;
}

.qms-btn-icon {
  &:not([disabled]):hover {
    text-decoration: none;
  }

  .qms-btn-icon-wrapper > * {
    vertical-align: middle;
  }

  &::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
  }

  &:not([disabled]):focus {
    &:not(:active) {
      &::after {
        //   animation: ripple 1s ease-out;
      }
    }
  }
}

// Button Icon
.qms-btn-icon {
  padding: 0;
  min-width: 0;
  width: $size;
  height: $size;
  line-height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  border: none;
  background: transparent;

  &:focus {
    outline: 0;
  }

  &:not([disabled]):focus {
    &:not(:focus-visible) {
      box-shadow: none;
    }
  }
  // Button Light
  &.qms-light {
    color: black(0.6);

    &:not([disabled]):hover,
    &:not([disabled]):focus {
      background-color: black(0.08);
      color: $default-color;
    }

    &:not([disabled]):active {
      background-color: black(0.24);
      color: $default-color;
    }

    // Disable button
    &.qms-btn-disabled {
      color: black(0.24);
      background-color: transparent;
    }

    // Button light
    &:not(.qms-btn-disabled).active-icon {
      color: $primary;

      &:not([disabled]):hover,
      &:not([disabled]):focus {
        background-color: $primary-light-3-opacity;
        color: $primary;
      }
   
      &:not([disabled]):active {
        background-color: $primary-light-6-opacity;
        color: $primary;
      }
    }
  }

  // Button Dark
  &.qms-dark {
    color: white;

    &:not([disabled]):hover,
    &:not([disabled]):focus {
      background-color: white(0.08);
    }

    &:not([disabled]):active {
      background-color: white(0.24);
    }

    &.qms-btn-disabled {
      color: white(0.24);
      background-color: transparent;
    }

    &.active-icon {
      color: $secondary-lighter;

      &:not([disabled]):hover,
      &:not([disabled]):focus {
        background-color: white(0.08);
      }

      &:not([disabled]):active {
        background-color: white(0.24);
      }
    }
  }

  .qms-button-focus-overlay {
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.35, 0, 0.25, 1),
      background-color 200ms cubic-bezier(0.35, 0, 0.25, 1);
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    position: absolute;
    pointer-events: none;
    border-radius: inherit;
  }

  .qms-btn-icon-wrapper {
    .mat-icon {
      vertical-align: middle;
      line-height: 24px;
    }
  }
}

// Button Icon Have Caption
.icon-wrapper {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;

  &.light {
    &.disabled {
      .caption {
        color: black(0.24);
        cursor: default;
        background-color: transparent;
      }
    }

    &.active {
      .caption {
        color: $primary;
      }
    }

    &:not(.disabled):hover {
      .caption {
        color: $default-color;
      }
    }
    &:not(.disabled):focus {
      .caption {
        color: black(0.6);
      }
    }
    &:not(.disabled):active {
      .caption {
        color: $default-color;
      }
    }
    .caption {
      color: black(0.6);
    }
  }

  &.dark {
    &.disabled {
      .caption {
        color: white(0.24);
        cursor: default;
        background-color: transparent;
      }
    }

    &.active {
      .caption {
        color: $secondary-lighter;
      }
    }

    .caption {
      color: white;
    }
  }

  .caption {
    font-size: 0.75rem;
    line-height: 16px;
    font-family: "Open Sans";
    font-weight: 400;
  }
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 1;
  }
  20% {
    transform: scale(25, 25);
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(40, 40);
  }
}
