@import '../variables';

:root {
  --loader-color: #1967d2;
  --itf-spinner-border-color: rgba(97, 97, 97, 0.29);
  --itf-spinner-main-color: rgb(100, 100, 100);
  --itf-spinner-white-border-color: rgba(158, 158, 158, 0.29);
  --itf-spinner-white-main-color: rgb(155, 155, 155);
  --itf-loading-bg-color: rgba(255, 255, 255, .4);
}

[data-theme="dark"] {
  --itf-spinner-border-color: rgba(158, 158, 158, 0.29);
  --itf-spinner-main-color: rgb(155, 155, 155);
  --itf-spinner-white-border-color: rgba(97, 97, 97, 0.29);
  --itf-spinner-white-main-color: rgb(100, 100, 100);
  --itf-loading-bg-color: rgba($dark-body-bg, .75);
}

.itf-spinner {
  text-indent: -9999em;
  border-radius: 50%;
  cursor: progress;
  display: inline-block;
  overflow: hidden;
  -webkit-transition: all 200ms ease-out;
  transition: all 200ms ease-out;
  vertical-align: top;
  width: 1.5rem;
  height: 1.5rem;
  border-width: 2px;
  border-style: solid;
  border-color: var(--itf-spinner-border-color);
  border-top-color: var(--itf-spinner-main-color);
  -webkit-animation: spinner 0.7s linear infinite;
  animation: spinner 0.7s linear infinite;
  mix-blend-mode: difference;

  &.itf-spinner__white {
    border-color: var(--itf-spinner-white-border-color);
    border-top-color: var(--itf-spinner-white-main-color);
  }
}

.itf-loading {
  position: absolute;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}
.itf-loading-wrapper {
  position: relative;
  pointer-events: none;
  user-select: none;

  .itf-loading {
    cursor: progress;
    pointer-events: all;
    background-color: var(--itf-loading-bg-color);
    opacity: 1;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    color: var(--loader-color);
    backdrop-filter: blur(5px);

    &-message {
      text-align: center;
      position: absolute;
      top: 50%;
      left: 50%;
      margin-top: -16px;
      margin-left: -16px;
    }
    &-icon {
      @extend .itf-spinner;

      position: absolute;
      z-index: 4;
      top: 50%;
      left: 50%;
      margin-top: -16px;
      margin-left: -16px;
      height: 32px;
      width: 32px;
      background-color: transparent !important;
    }

    &-text {
      padding: 0 !important;
      background-color: transparent !important;
    }
  }
}

@-webkit-keyframes spinner {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

@keyframes spinner {
  0% {
    -webkit-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
