$input-height: 26px;
$btn-border-radius: 8px;

.btn {
  --btn-bg-color: rgb(from var(--theme-base) r g b / 6%);
  --btn-text-color: var(--theme-base);
  --btn-hover-bg-color: rgb(from var(--theme-base) r g b / 12%);
  --btn-hover-text-color: var(--theme-base);

  background-color: var(--btn-bg-color);
  color: var(--btn-text-color);

  &:hover,
  &:focus-visible {
    background-color: var(--btn-hover-bg-color);
    color: var(--btn-hover-text-color);
  }

  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-family: inherit;
  line-height: $input-height;
  height: $input-height;
  font-weight: 700;
  outline: 0;
  border: 0;
  padding: 0 1rem;
  min-width: 88px;
  border-radius: $btn-border-radius;
  transition: background 0.15s ease-in-out,
  color 0.15s ease-in-out;
  justify-content: center;
  text-align: center;
  cursor: pointer;

  &:hover,
  &:focus {
    font-weight: 700;
    outline: 0;
    border: 0;
    box-shadow: none;
  }

  &:focus-visible {
    outline-style: solid;
    outline-offset: 0.14rem;
    outline-width: 2px;
    outline-color: var(--theme-base);
  }

  &.btn-icon {
    display: flex;
    align-items: center;

    i {
      font-size: 1rem;
      margin-left: -3px;
    }
  }

  &:disabled {
    opacity: 0.6;
  }

  .title-popup {
    position: absolute;
    width: max-content;
    top: 2.1rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    background-color: color-mix(in srgb,
        var(--theme-base) 10%,
        var(--query-editor-bg));
    user-select: none;
    opacity: 0;
    pointer-events: none;
  }

  &:hover .title-popup {
    animation: fadeInAfterDelay 0.8s forwards;
  }
}

@keyframes fadeInAfterDelay {

  0%,
  75% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

.btn-primary {
  --btn-bg-color: var(--theme-base);
  --btn-text-color: var(--query-editor-bg);
  --btn-hover-bg-color: rgb(from var(--theme-base) r g b / 87%);
  --btn-hover-text-color: var(--query-editor-bg);
}

.btn.btn-flat {
  --btn-bg-color: rgb(from var(--theme-base) r g b / 6%);
  --btn-text-color: var(--theme-base);
  --btn-hover-bg-color: rgb(from var(--theme-base) r g b / 12%);
  --btn-hover-text-color: var(--theme-base);
}

.btn.btn-flat-2 {
  --btn-bg-color: var(--query-editor-bg);
  --btn-text-color: color-mix(in srgb, var(--text-dark) 90%, var(--query-editor-bg));
  --btn-hover-bg-color: color-mix(in srgb,
      var(--theme-base) 10%,
      var(--query-editor-bg));
  --btn-hover-text-color: var(--text-dark);
}
