.copyable-code {
  display: inline-flex;
  align-items: center;
  color: color.$white;
  font-size: 12px;
  position: relative;
  background: color.$ui-gray-800;
  border-radius: 2px;

  pre {
    padding: scale.$sm-2 scale.$sm-2;
  }

  code {
    font-size: inherit;
    position: relative;
    background: none;
    padding: 0 scale.$sm-2;
    border-radius: 0;
    color: inherit;
    border: none;

    &::before {
      content: '$';
      opacity: 0.5;
      margin-right: scale.$sm-2;
    }
  }

  button {
    display: flex;
    color: color.$white;
    background: none;
    border: none;
    border-left: 1px solid rgb(var(--background));
    border-radius: 0 2px 2px 0;
    padding: 4px;
    cursor: pointer;
    outline: none;
    align-items: center;
    transition: background ease 0.2s;

    &.copy-success {
      background: color.$green-400;
    }

    .icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 12px;
      height: 12px;
      font-size: 12px;
    }
  }
}

.copyable-code.block {
  display: block;

  pre {
    margin: 0;
    padding-left: 0;
    overflow: auto;

    &::-webkit-scrollbar {
      height: scale.$sm-3;
    }

    &::-webkit-scrollbar-track {
      background: transparent;
    }

    &::-webkit-scrollbar-thumb {
      background: color.$ui-cool-gray-300;
      border-radius: scale.$sm-3;
    }

    &::-webkit-scrollbar-button {
      width: scale.$sm-1;
    }

    code {
      padding-right: scale.$lg-4;
    }
  }

  button {
    display: flex;
    color: color.$white;
    background: linear-gradient(
      to right,
      rgba(color.$ui-gray-800, 0),
      color.$ui-gray-800,
      color.$ui-gray-800
    );
    border: none;
    border-radius: 0 3px 3px 0;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    margin: 0;
    padding: 6px;
    cursor: pointer;
    outline: none;
    transition: color ease 0.2s;

    &.copy-success {
      color: color.$green-300;
    }

    .icon {
      width: 18px;
      height: 18px;
    }
  }
}
